diff --git a/.github/workflows/dashboard-ci.yml b/.github/workflows/dashboard-ci.yml index 15d22228c..84aebb017 100644 --- a/.github/workflows/dashboard-ci.yml +++ b/.github/workflows/dashboard-ci.yml @@ -10,7 +10,7 @@ on: workflow_dispatch: inputs: environment: - description: "Environment (network) for workflow execution, e.g. `goerli`" + description: "Environment (network) for workflow execution, e.g. `sepolia`" required: false upstream_builds: description: "Upstream builds" @@ -42,7 +42,10 @@ jobs: run: git config --global url."https://".insteadOf git:// - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --ignore-scripts --frozen-lockfile + + - name: Run token-dashboard post-install script + run: yarn run postinstall - name: Check formatting run: yarn format @@ -74,7 +77,7 @@ jobs: @keep-network/keep-ecdsa \ @keep-network/tbtc \ @keep-network/coverage-pools \ - @keep-network/random-beacon + @keep-network/random-beacon --ignore-scripts - name: Run postinstall script # `yarn upgrade` doesn't trigger the `postinstall` script. @@ -84,9 +87,9 @@ jobs: run: yarn build env: PUBLIC_URL: /${{ github.head_ref }} - CHAIN_ID: 5 - ETH_HOSTNAME_HTTP: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} - ETH_HOSTNAME_WS: ${{ secrets.GOERLI_ETH_HOSTNAME_WS }} + CHAIN_ID: 11155111 + ETH_HOSTNAME_HTTP: ${{ secrets.SEPOLIA_ETH_HOSTNAME_HTTP }} + ETH_HOSTNAME_WS: ${{ secrets.SEPOLIA_ETH_HOSTNAME_WS }} NODE_OPTIONS: --max_old_space_size=4096 ELECTRUM_PROTOCOL: ${{ secrets.TESTNET_ELECTRUMX_PROTOCOL }} ELECTRUM_HOST: ${{ secrets.TESTNET_ELECTRUMX_HOST }} @@ -98,7 +101,7 @@ jobs: # run: yarn test # This job will be triggered for PR updates. It will build the dashboard - # using `dapp-development-goerli`-taggeed packages which contain contracts + # using `dapp-development-sepolia`-taggeed packages which contain contracts # with values modified to help with the testing of dashboard. The code will be # published to # https://preview.dashboard.test.threshold.network/${{ github.head_ref }}/index.html @@ -109,18 +112,18 @@ jobs: if: github.event_name == 'pull_request' uses: ./.github/workflows/reusable-build-and-publish.yml with: - environment: goerli + environment: sepolia useUpstreamBuilds: false - # We use `dapp-development-goerli`-taggeed packages with modified + # We use `dapp-development-sepolia`-taggeed packages with modified # contracts. They contain modifications that help with the testing of # dashboard features. - dependentPackagesTag: dapp-development-goerli + dependentPackagesTag: dapp-development-sepolia gcpBucketName: preview.dashboard.test.threshold.network gcpBucketPath: ${{ github.head_ref }} preview: true secrets: - ethUrlHttp: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} - ethUrlWS: ${{ secrets.GOERLI_ETH_HOSTNAME_WS }} + ethUrlHttp: ${{ secrets.SEPOLIA_ETH_HOSTNAME_HTTP }} + ethUrlWS: ${{ secrets.SEPOLIA_ETH_HOSTNAME_WS }} gcpServiceKey: ${{ secrets.KEEP_TEST_CI_UPLOAD_DAPP_JSON_KEY_BASE64 }} electrumProtocol: ${{ secrets.TESTNET_ELECTRUMX_PROTOCOL }} electrumHost: ${{ secrets.TESTNET_ELECTRUMX_HOST }} @@ -144,14 +147,14 @@ jobs: uses: ./.github/workflows/reusable-build-and-publish.yml with: requireApproval: true - environment: goerli + environment: sepolia useUpstreamBuilds: true upstreamBuilds: ${{ github.event.inputs.upstream_builds }} gcpBucketName: dashboard.test.threshold.network preview: false secrets: - ethUrlHttp: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} - ethUrlWS: ${{ secrets.GOERLI_ETH_HOSTNAME_WS }} + ethUrlHttp: ${{ secrets.SEPOLIA_ETH_HOSTNAME_HTTP }} + ethUrlWS: ${{ secrets.SEPOLIA_ETH_HOSTNAME_WS }} gcpServiceKey: ${{ secrets.KEEP_TEST_CI_UPLOAD_DAPP_JSON_KEY_BASE64 }} electrumProtocol: ${{ secrets.TESTNET_ELECTRUMX_PROTOCOL }} electrumHost: ${{ secrets.TESTNET_ELECTRUMX_HOST }} @@ -170,14 +173,14 @@ jobs: if: github.event_name == 'push' uses: ./.github/workflows/reusable-build-and-publish.yml with: - environment: goerli + environment: sepolia useUpstreamBuilds: false - dependentPackagesTag: goerli + dependentPackagesTag: sepolia gcpBucketName: dashboard.test.threshold.network preview: false secrets: - ethUrlHttp: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} - ethUrlWS: ${{ secrets.GOERLI_ETH_HOSTNAME_WS }} + ethUrlHttp: ${{ secrets.SEPOLIA_ETH_HOSTNAME_HTTP }} + ethUrlWS: ${{ secrets.SEPOLIA_ETH_HOSTNAME_WS }} gcpServiceKey: ${{ secrets.KEEP_TEST_CI_UPLOAD_DAPP_JSON_KEY_BASE64 }} electrumProtocol: ${{ secrets.TESTNET_ELECTRUMX_PROTOCOL }} electrumHost: ${{ secrets.TESTNET_ELECTRUMX_HOST }} diff --git a/.github/workflows/dashboard-mainnet.yml b/.github/workflows/dashboard-mainnet.yml index 1b972d9c8..1e24f5b33 100644 --- a/.github/workflows/dashboard-mainnet.yml +++ b/.github/workflows/dashboard-mainnet.yml @@ -30,7 +30,10 @@ jobs: run: git config --global url."https://".insteadOf git:// - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --ignore-scripts --frozen-lockfile + + - name: Run token-dashboard post-install script + run: yarn run postinstall # FIXME: It's work in progress, the contracts are not yet published. # - name: Resolve latest mainnet contracts diff --git a/.github/workflows/reusable-build-and-publish.yml b/.github/workflows/reusable-build-and-publish.yml index 96ca5f537..06c2ab14d 100644 --- a/.github/workflows/reusable-build-and-publish.yml +++ b/.github/workflows/reusable-build-and-publish.yml @@ -7,11 +7,10 @@ on: required: false default: false type: boolean - # Currently the action only supports `environment` = `goerli`. environment: description: > - The environment on which the action should be used. For example `goerli`. - Will be used to deterine environment variables and decide which legacy + The environment on which the action should be used. For example `sepolia`. + Will be used to determine environment variables and decide which legacy packages should be used for building. required: true type: string @@ -28,7 +27,7 @@ on: description: > Tag which should be used to pull latest non-legacy `threshold-network` and `keep-network` packages with contracts (required if - `useUpstreamBuilds==false`). For example `dapp-dev-goerli`. + `useUpstreamBuilds==false`). For example `dapp-dev-sepolia`. required: false type: string gcpBucketName: @@ -102,7 +101,11 @@ jobs: - name: Install dependencies shell: bash - run: yarn install --frozen-lockfile + run: yarn install --ignore-scripts --frozen-lockfile + + - name: Run token-dashboard post-install script + shell: bash + run: yarn run postinstall - name: Get upstream packages versions if: inputs.useUpstreamBuilds == true @@ -114,48 +117,42 @@ jobs: threshold-contracts-version = github.com/threshold-network/solidity-contracts#version random-beacon-contracts-version = github.com/keep-network/keep-core/random-beacon#version + # Currently we only support `environment` = `sepolia`. We provide explicit + # version of the `solidity-contracts` package, because using `sepolia` tag + # results in `expected manifest` error - probably caused by bug in Yarn: + # https://github.com/yarnpkg/yarn/issues/4731. - name: Set packages versions shell: bash id: set-packages-versions + env: + TC_VERSION_MAPPING: '{"sepolia": "1.3.0-sepolia.0", "dapp-development-sepolia": "1.3.0-dapp-dev-sepolia.0"}' run: | if [ ${{ inputs.useUpstreamBuilds }} = 'false' ]; then - echo "threshold-contracts-version=${{ inputs.dependentPackagesTag }}" >> $GITHUB_OUTPUT + echo "threshold-contracts-version=${{ fromJson(env.TC_VERSION_MAPPING)[inputs.dependentPackagesTag] || inputs.dependentPackagesTag }}" >> $GITHUB_OUTPUT echo "random-beacon-contracts-version=${{ inputs.dependentPackagesTag }}" >> $GITHUB_OUTPUT else echo "threshold-contracts-version=${{ steps.upstream-builds-query.outputs.threshold-contracts-version }}" >> $GITHUB_OUTPUT echo "random-beacon-contracts-version=${{ steps.upstream-builds-query.outputs.random-beacon-contracts-version }}" >> $GITHUB_OUTPUT fi - # Currently we only support `environment` = `goerli`. We provide explicit - # version of the `keep-core` package, because using `goerli` tag results - # in `expected manifest` error - probably caused by bug in Yarn: - # https://github.com/yarnpkg/yarn/issues/4731. - # In the `package.json` there are two different versions of # `coverage-pools` used. This is done to allow using contracts from two # different cov pool versions on the mainnet (needed for computations of # the TVL-related fields) - one relates to KEEP token cov pool (<2.0.0) # and one to to T token one (>=2.0.0). - # On the testnet environmet we currently don't have the T token cov pool - # deployed. The latest `goerli`- tagged version of the cov-pools package - # (`1.1.0-goerli.0`) contains KEEP-token related contracts. We want to - # stick to this version (we'll need to update it once we switch to - # Sepolia). For the `@threshold-network/coverage-pools` ideally we'd want - # to use a T token related pool, which if deployed for given environment, - # should be present in the latest `goerli`/`sepolia` package. If the - # T-related pool is not yet deployed for given environment, KEEP-related - # cov-pool contracts will be used in all TVL computations (which differs - # from the mainnet behavior, but is acceptable on the test env). - + # On the testnet environmet we currently don't have the KEEP token cov + # pool deployed. The T-related cov-pool contracts will be used in all TVL + # computations (which differs from the mainnet behavior, but is acceptable + # on the test env). - name: Resolve contracts shell: bash run: | yarn upgrade \ @threshold-network/solidity-contracts@${{ steps.set-packages-versions.outputs.threshold-contracts-version }} \ - @keep-network/keep-core@1.8.1-goerli.0 \ + @keep-network/keep-core@${{ inputs.environment }} \ @keep-network/keep-ecdsa@${{ inputs.environment }} \ @keep-network/tbtc@${{ inputs.environment }} \ - @keep-network/coverage-pools@1.1.0-goerli.0 \ + @keep-network/coverage-pools@${{ inputs.environment }} \ @threshold-network/coverage-pools@npm:@keep-network/coverage-pools@${{ inputs.environment }} \ @keep-network/random-beacon@${{ steps.set-packages-versions.outputs.random-beacon-contracts-version }} diff --git a/README.md b/README.md index d8ca59b2c..a3e9575f2 100644 --- a/README.md +++ b/README.md @@ -41,16 +41,16 @@ To make sure the changes made in local depository of `components` lib are implem `yarn add-components-lib` -# Run T dapp against the Görli network +# Run T dapp against the Sepolia network ## Update the `.env` file: ``` -REACT_APP_SUPPORTED_CHAIN_ID=5 +REACT_APP_SUPPORTED_CHAIN_ID=11155111 REACT_APP_ETH_HOSTNAME_HTTP= REACT_APP_ETH_HOSTNAME_WS= // We can skip this env variable- the dapp uses the correct address -// of Multicall contract for Görli under the hood. +// of Multicall contract for Sepolia under the hood. REACT_APP_MULTICALL_ADDRESS=$MULTICALL_ADDRESS ``` @@ -58,29 +58,28 @@ REACT_APP_MULTICALL_ADDRESS=$MULTICALL_ADDRESS `yarn` -## Install Görli contracts +## Install Sepolia contracts ``` -yarn upgrade @keep-network/coverage-pools@goerli \ - @keep-network/ecdsa@goerli \ - @keep-network/keep-core@goerli \ - @keep-network/keep-ecdsa@goerli \ - @keep-network/random-beacon@goerli \ - @keep-network/tbtc@goerli \ - @keep-network/tbtc-v2@goerli \ - @keep-network/tbtc-v2.ts@goerli \ - @threshold-network/coverage-pools@npm:@keep-network/coverage-pools@goerli \ - @threshold-network/solidity-contracts@goerli +yarn upgrade @keep-network/coverage-pools@sepolia \ + @keep-network/ecdsa@sepolia \ + @keep-network/keep-core@sepolia \ + @keep-network/keep-ecdsa@sepolia \ + @keep-network/random-beacon@sepolia \ + @keep-network/tbtc@sepolia \ + @keep-network/tbtc-v2@sepolia \ + @threshold-network/coverage-pools@npm:@keep-network/coverage-pools@sepolia \ + @threshold-network/solidity-contracts@sepolia ``` -**NOTE 1:** We use the same Goerli versions for both +**NOTE 1:** We use the same Sepolia versions for both `@keep-network/coverage-pools` and `@threshold-network/coverage-pools`, because -we don't have the newest version of the package on Goerli network, only on the +we don't have the v1 version of the package on Sepolia network, only on the Mainnet. **NOTE 2:** If you encounter an `expected manifest` error while executing this, then try providing an explicit version of the `keep-core` package: -`@keep-network/keep-core@1.8.1-goerli.0` +`@keep-network/keep-core@1.8.1-sepolia.0` The error is probably caused by a bug in Yarn: https://github.com/yarnpkg/yarn/issues/4731. @@ -111,7 +110,7 @@ The following procedure allows to deploy T token dashboard to production: `releases/mainnet/`. Release branch should never be merged to `main` and creating a PR with a release branch is not required. Dependencies and project version needs to be updated on the release branch. - All `-dev`, `-goerli` dependencies need to be updated to mainnet versions. + All `-dev`, `-sepolia` dependencies need to be updated to mainnet versions. See [this commit](https://github.com/threshold-network/token-dashboard/commit/5452b68886ebc514d941a087973dfa9ac3802a7e) for `v1.0.0` release as a good example. 2. Preview of the release branch will be uploaded to `preview.dashboard.threshold.network` diff --git a/src/components/Navbar/NetworkButton.tsx b/src/components/Navbar/NetworkButton.tsx index 1a1a2f345..bbdedb85b 100644 --- a/src/components/Navbar/NetworkButton.tsx +++ b/src/components/Navbar/NetworkButton.tsx @@ -28,7 +28,7 @@ const NetworkButton: FC<{ chainId?: number }> = ({ chainId }) => { icon: , bg: "gray.700", }, - [ChainID.Goerli]: { + [ChainID.Sepolia]: { icon: ( diff --git a/src/threshold-ts/staking/goerli-artifacts/NuCypherStakingEscrow.json b/src/threshold-ts/staking/dapp-development-sepolia-artifacts/NuCypherStakingEscrow.json similarity index 50% rename from src/threshold-ts/staking/goerli-artifacts/NuCypherStakingEscrow.json rename to src/threshold-ts/staking/dapp-development-sepolia-artifacts/NuCypherStakingEscrow.json index 4562db7bf..5ba1d5c36 100644 --- a/src/threshold-ts/staking/goerli-artifacts/NuCypherStakingEscrow.json +++ b/src/threshold-ts/staking/dapp-development-sepolia-artifacts/NuCypherStakingEscrow.json @@ -1,5 +1,5 @@ { - "address": "0xd696d5a9b083959587F30e487038529a876b08C2", + "address": "0x64f78cA737D7942e757A76C1c434b390B8131E0d", "abi": [ { "inputs": [ @@ -165,28 +165,28 @@ "type": "function" } ], - "transactionHash": "0xd37c78cb966dc26be4e4a1ea10d866949648ceecca195aae23ef2407fa2f0dd8", + "transactionHash": "0xb06124f0fcd065511e18cb7cf5e757772b738639d3ffc1957b713101b560114e", "receipt": { "to": null, "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", - "contractAddress": "0xd696d5a9b083959587F30e487038529a876b08C2", - "transactionIndex": 11, - "gasUsed": "327718", + "contractAddress": "0x64f78cA737D7942e757A76C1c434b390B8131E0d", + "transactionIndex": 85, + "gasUsed": "327800", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x87d3532886402a0506d91ba8d7327a35e3e4533e15ebc3f8ae2257f3315d6dfa", - "transactionHash": "0xd37c78cb966dc26be4e4a1ea10d866949648ceecca195aae23ef2407fa2f0dd8", + "blockHash": "0x35dc230bd683070d869d0a1de2a878a6341e25adb5298e81072e4845c3fe3e36", + "transactionHash": "0xb06124f0fcd065511e18cb7cf5e757772b738639d3ffc1957b713101b560114e", "logs": [], - "blockNumber": 7681408, - "cumulativeGasUsed": "5155418", + "blockNumber": 4648085, + "cumulativeGasUsed": "8303901", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "c42403a734f7dc0bc16cac52ab22d6ca", - "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"getAllTokens\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"investigators\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"requestMerge\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setStaker\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"penalty\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"investigator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"slashStaker\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"stakerInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"internalType\":\"struct NuCypherTokenStakingMock.StakerStruct\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"stakers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"slashStaker(address,uint256,address,uint256)\":{\"params\":{\"investigator\":\"Investigator\",\"penalty\":\"Penalty\",\"reward\":\"Reward for the investigator\",\"staker\":\"Staker's address\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getAllTokens(address)\":{\"notice\":\"Get all tokens belonging to the staker\"},\"requestMerge(address,address)\":{\"notice\":\"Request merge between NuCypher staking contract and T staking contract. Returns amount of staked tokens\"},\"slashStaker(address,uint256,address,uint256)\":{\"notice\":\"Slash the staker's stake and reward the investigator\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/TokenStakingTestSet.sol\":\"NuCypherTokenStakingMock\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() initializer {}\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\\n // contract may have been reentered.\\n require(_initializing ? _isConstructor() : !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} modifier, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n function _isConstructor() private view returns (bool) {\\n return !AddressUpgradeable.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x372b0bc04e3b4c074559bbbfb1317afddb56de5504158ca25a7f9cd403980445\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev 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 /**\\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\",\"keccak256\":\"0x6777f3fccb5dab95a9088ef62c41bee0198fd92e50d7c94f0e3733788af4079e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3e26a49d2fa5ef8338b8a9467c91e54f417cb07e849b1cc0f4ebc4d2a147938e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x55cf2bd9fc76704ddcdc19834cd288b7de00fc0f298a40ea16a954ae8991db2d\",\"license\":\"MIT\"},\"@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 v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.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 /**\\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\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\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 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 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 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 /**\\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\",\"keccak256\":\"0x516a22876c1fab47f49b1bc22b4614491cd05338af8bd2e7b382da090a079990\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.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 SafeCast {\\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\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"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\"},\"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/staking/IApplication.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\\n/// @title Application interface for Threshold Network applications\\n/// @notice Generic interface for an application. Application is an external\\n/// smart contract or a set of smart contracts utilizing functionalities\\n/// offered by Threshold Network. Applications authorized for the given\\n/// staking provider are eligible to slash the stake delegated to that\\n/// staking provider.\\ninterface IApplication {\\n /// @dev Event emitted by `withdrawRewards` function.\\n event RewardsWithdrawn(address indexed stakingProvider, uint96 amount);\\n\\n /// @notice Withdraws application rewards for the given staking provider.\\n /// Rewards are withdrawn to the staking provider's beneficiary\\n /// address set in the staking contract.\\n /// @dev Emits `RewardsWithdrawn` event.\\n function withdrawRewards(address stakingProvider) external;\\n\\n /// @notice Used by T staking contract to inform the application that the\\n /// authorized amount for the given staking provider increased.\\n /// The application may do any necessary housekeeping. The\\n /// application must revert the transaction in case the\\n /// authorization is below the minimum required.\\n function authorizationIncreased(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Used by T staking contract to inform the application that the\\n /// authorization decrease for the given staking provider has been\\n /// requested. The application should mark the authorization as\\n /// pending decrease and respond to the staking contract with\\n /// `approveAuthorizationDecrease` at its discretion. It may\\n /// happen right away but it also may happen several months later.\\n /// If there is already a pending authorization decrease request\\n /// for the application, and the application does not agree for\\n /// overwriting it, the function should revert.\\n function authorizationDecreaseRequested(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Used by T staking contract to inform the application the\\n /// authorization has been decreased for the given staking provider\\n /// involuntarily, as a result of slashing. Lets the application to\\n /// do any housekeeping neccessary. Called with 250k gas limit and\\n /// does not revert the transaction if\\n /// `involuntaryAuthorizationDecrease` call failed.\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Returns the amount of application rewards available for\\n /// withdrawal for the given staking provider.\\n function availableRewards(address stakingProvider)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice The minimum authorization amount required for the staking\\n /// provider so that they can participate in the application.\\n function minimumAuthorization() external view returns (uint96);\\n}\\n\",\"keccak256\":\"0x43d707dccc548bf48ad316d9652450cb297203234d251132cdc6b97508eb44c5\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/ILegacyTokenStaking.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\\n/// @title IKeepTokenStaking\\n/// @notice Interface for Keep TokenStaking contract\\ninterface IKeepTokenStaking {\\n /// @notice Seize provided token amount from every member in the misbehaved\\n /// operators array. The tattletale is rewarded with 5% of the total seized\\n /// amount scaled by the reward adjustment parameter and the rest 95% is burned.\\n /// @param amountToSeize Token amount to seize from every misbehaved operator.\\n /// @param rewardMultiplier Reward adjustment in percentage. Min 1% and 100% max.\\n /// @param tattletale Address to receive the 5% reward.\\n /// @param misbehavedOperators Array of addresses to seize the tokens from.\\n function seize(\\n uint256 amountToSeize,\\n uint256 rewardMultiplier,\\n address tattletale,\\n address[] memory misbehavedOperators\\n ) external;\\n\\n /// @notice Gets stake delegation info for the given operator.\\n /// @param operator Operator address.\\n /// @return amount The amount of tokens the given operator delegated.\\n /// @return createdAt The time when the stake has been delegated.\\n /// @return undelegatedAt The time when undelegation has been requested.\\n /// If undelegation has not been requested, 0 is returned.\\n function getDelegationInfo(address operator)\\n external\\n view\\n returns (\\n uint256 amount,\\n uint256 createdAt,\\n uint256 undelegatedAt\\n );\\n\\n /// @notice Gets the stake owner for the specified operator address.\\n /// @return Stake owner address.\\n function ownerOf(address operator) external view returns (address);\\n\\n /// @notice Gets the beneficiary for the specified operator address.\\n /// @return Beneficiary address.\\n function beneficiaryOf(address operator)\\n external\\n view\\n returns (address payable);\\n\\n /// @notice Gets the authorizer for the specified operator address.\\n /// @return Authorizer address.\\n function authorizerOf(address operator) external view returns (address);\\n\\n /// @notice Gets the eligible stake balance of the specified address.\\n /// An eligible stake is a stake that passed the initialization period\\n /// and is not currently undelegating. Also, the operator had to approve\\n /// the specified operator contract.\\n ///\\n /// Operator with a minimum required amount of eligible stake can join the\\n /// network and participate in new work selection.\\n ///\\n /// @param operator address of stake operator.\\n /// @param operatorContract address of operator contract.\\n /// @return balance an uint256 representing the eligible stake balance.\\n function eligibleStake(address operator, address operatorContract)\\n external\\n view\\n returns (uint256 balance);\\n}\\n\\n/// @title INuCypherStakingEscrow\\n/// @notice Interface for NuCypher StakingEscrow contract\\ninterface INuCypherStakingEscrow {\\n /// @notice Slash the staker's stake and reward the investigator\\n /// @param staker Staker's address\\n /// @param penalty Penalty\\n /// @param investigator Investigator\\n /// @param reward Reward for the investigator\\n function slashStaker(\\n address staker,\\n uint256 penalty,\\n address investigator,\\n uint256 reward\\n ) external;\\n\\n /// @notice Request merge between NuCypher staking contract and T staking contract.\\n /// Returns amount of staked tokens\\n function requestMerge(address staker, address stakingProvider)\\n external\\n returns (uint256);\\n\\n /// @notice Get all tokens belonging to the staker\\n function getAllTokens(address staker) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x807d42d248e94c1f2269c7aa27031302a1225525e1405010424dd91adcc092ab\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/IStaking.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\\n/// @title Interface of Threshold Network staking contract\\n/// @notice The staking contract enables T owners to have their wallets offline\\n/// and their stake managed by staking providers on their behalf.\\n/// The staking contract does not define operator role. The operator\\n/// responsible for running off-chain client software is appointed by\\n/// the staking provider in the particular application utilizing the\\n/// staking contract. All off-chain client software should be able\\n/// to run without exposing operator's or staking provider\\u2019s private\\n/// key and should not require any owner\\u2019s keys at all. The stake\\n/// delegation optimizes the network throughput without compromising the\\n/// security of the owners\\u2019 stake.\\ninterface IStaking {\\n enum StakeType {\\n NU,\\n KEEP,\\n T\\n }\\n\\n //\\n //\\n // Delegating a stake\\n //\\n //\\n\\n /// @notice Creates a delegation with `msg.sender` owner with the given\\n /// staking provider, beneficiary, and authorizer. Transfers the\\n /// given amount of T to the staking contract.\\n /// @dev The owner of the delegation needs to have the amount approved to\\n /// transfer to the staking contract.\\n function stake(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer,\\n uint96 amount\\n ) external;\\n\\n /// @notice Copies delegation from the legacy KEEP staking contract to T\\n /// staking contract. No tokens are transferred. Caches the active\\n /// stake amount from KEEP staking contract. Can be called by\\n /// anyone.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function stakeKeep(address stakingProvider) external;\\n\\n /// @notice Copies delegation from the legacy NU staking contract to T\\n /// staking contract, additionally appointing staking provider,\\n /// beneficiary and authorizer roles. Caches the amount staked in NU\\n /// staking contract. Can be called only by the original delegation\\n /// owner.\\n function stakeNu(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer\\n ) external;\\n\\n /// @notice Refresh Keep stake owner. Can be called only by the old owner\\n /// or their staking provider.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function refreshKeepStakeOwner(address stakingProvider) external;\\n\\n /// @notice Allows the Governance to set the minimum required stake amount.\\n /// This amount is required to protect against griefing the staking\\n /// contract and individual applications are allowed to require\\n /// higher minimum stakes if necessary.\\n function setMinimumStakeAmount(uint96 amount) external;\\n\\n //\\n //\\n // Authorizing an application\\n //\\n //\\n\\n /// @notice Allows the Governance to approve the particular application\\n /// before individual stake authorizers are able to authorize it.\\n function approveApplication(address application) external;\\n\\n /// @notice Increases the authorization of the given staking provider for\\n /// the given application by the given amount. Can only be called by\\n /// the authorizer for that staking provider.\\n /// @dev Calls `authorizationIncreased(address stakingProvider, uint256 amount)`\\n /// on the given application to notify the application about\\n /// authorization change. See `IApplication`.\\n function increaseAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external;\\n\\n /// @notice Requests decrease of the authorization for the given staking\\n /// provider on the given application by the provided amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application if the application agrees for that. If the\\n /// application does not agree for overwriting, the function\\n /// reverts.\\n /// @dev Calls `authorizationDecreaseRequested(address stakingProvider, uint256 amount)`\\n /// on the given application. See `IApplication`.\\n function requestAuthorizationDecrease(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external;\\n\\n /// @notice Requests decrease of all authorizations for the given staking\\n /// provider on all applications by all authorized amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application.\\n /// @dev Calls `authorizationDecreaseRequested(address stakingProvider, uint256 amount)`\\n /// for each authorized application. See `IApplication`.\\n function requestAuthorizationDecrease(address stakingProvider) external;\\n\\n /// @notice Called by the application at its discretion to approve the\\n /// previously requested authorization decrease request. Can only be\\n /// called by the application that was previously requested to\\n /// decrease the authorization for that staking provider.\\n /// Returns resulting authorized amount for the application.\\n function approveAuthorizationDecrease(address stakingProvider)\\n external\\n returns (uint96);\\n\\n /// @notice Decreases the authorization for the given `stakingProvider` on\\n /// the given disabled `application`, for all authorized amount.\\n /// Can be called by anyone.\\n function forceDecreaseAuthorization(\\n address stakingProvider,\\n address application\\n ) external;\\n\\n /// @notice Pauses the given application\\u2019s eligibility to slash stakes.\\n /// Besides that stakers can't change authorization to the application.\\n /// Can be called only by the Panic Button of the particular\\n /// application. The paused application can not slash stakes until\\n /// it is approved again by the Governance using `approveApplication`\\n /// function. Should be used only in case of an emergency.\\n function pauseApplication(address application) external;\\n\\n /// @notice Disables the given application. The disabled application can't\\n /// slash stakers. Also stakers can't increase authorization to that\\n /// application but can decrease without waiting by calling\\n /// `requestAuthorizationDecrease` at any moment. Can be called only\\n /// by the governance. The disabled application can't be approved\\n /// again. Should be used only in case of an emergency.\\n function disableApplication(address application) external;\\n\\n /// @notice Sets the Panic Button role for the given application to the\\n /// provided address. Can only be called by the Governance. If the\\n /// Panic Button for the given application should be disabled, the\\n /// role address should be set to 0x0 address.\\n function setPanicButton(address application, address panicButton) external;\\n\\n /// @notice Sets the maximum number of applications one staking provider can\\n /// have authorized. Used to protect against DoSing slashing queue.\\n /// Can only be called by the Governance.\\n function setAuthorizationCeiling(uint256 ceiling) external;\\n\\n //\\n //\\n // Stake top-up\\n //\\n //\\n\\n /// @notice Increases the amount of the stake for the given staking provider.\\n /// @dev The sender of this transaction needs to have the amount approved to\\n /// transfer to the staking contract.\\n function topUp(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Propagates information about stake top-up from the legacy KEEP\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpKeep(address stakingProvider) external;\\n\\n /// @notice Propagates information about stake top-up from the legacy NU\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpNu(address stakingProvider) external;\\n\\n //\\n //\\n // Undelegating a stake (unstaking)\\n //\\n //\\n\\n /// @notice Reduces the liquid T stake amount by the provided amount and\\n /// withdraws T to the owner. Reverts if there is at least one\\n /// authorization higher than the sum of the legacy stake and\\n /// remaining liquid T stake or if the unstake amount is higher than\\n /// the liquid T stake amount. Can be called only by the delegation\\n /// owner or the staking provider.\\n function unstakeT(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Sets the legacy KEEP staking contract active stake amount cached\\n /// in T staking contract to 0. Reverts if the amount of liquid T\\n /// staked in T staking contract is lower than the highest\\n /// application authorization. This function allows to unstake from\\n /// KEEP staking contract and still being able to operate in T\\n /// network and earning rewards based on the liquid T staked. Can be\\n /// called only by the delegation owner or the staking provider.\\n function unstakeKeep(address stakingProvider) external;\\n\\n /// @notice Reduces cached legacy NU stake amount by the provided amount.\\n /// Reverts if there is at least one authorization higher than the\\n /// sum of remaining legacy NU stake and liquid T stake for that\\n /// staking provider or if the untaked amount is higher than the\\n /// cached legacy stake amount. If succeeded, the legacy NU stake\\n /// can be partially or fully undelegated on the legacy staking\\n /// contract. This function allows to unstake from NU staking\\n /// contract and still being able to operate in T network and\\n /// earning rewards based on the liquid T staked. Can be called only\\n /// by the delegation owner or the staking provider.\\n function unstakeNu(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Sets cached legacy stake amount to 0, sets the liquid T stake\\n /// amount to 0 and withdraws all liquid T from the stake to the\\n /// owner. Reverts if there is at least one non-zero authorization.\\n /// Can be called only by the delegation owner or the staking\\n /// provider.\\n function unstakeAll(address stakingProvider) external;\\n\\n //\\n //\\n // Keeping information in sync\\n //\\n //\\n\\n /// @notice Notifies about the discrepancy between legacy KEEP active stake\\n /// and the amount cached in T staking contract. Slashes the staking\\n /// provider in case the amount cached is higher than the actual\\n /// active stake amount in KEEP staking contract. Needs to update\\n /// authorizations of all affected applications and execute an\\n /// involuntary allocation decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyKeepStakeDiscrepancy(address stakingProvider) external;\\n\\n /// @notice Notifies about the discrepancy between legacy NU active stake\\n /// and the amount cached in T staking contract. Slashes the\\n /// staking provider in case the amount cached is higher than the\\n /// actual active stake amount in NU staking contract. Needs to\\n /// update authorizations of all affected applications and execute\\n /// an involuntary allocation decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyNuStakeDiscrepancy(address stakingProvider) external;\\n\\n /// @notice Sets the penalty amount for stake discrepancy and reward\\n /// multiplier for reporting it. The penalty is seized from the\\n /// delegated stake, and 5% of the penalty, scaled by the\\n /// multiplier, is given to the notifier. The rest of the tokens are\\n /// burned. Can only be called by the Governance. See `seize` function.\\n function setStakeDiscrepancyPenalty(\\n uint96 penalty,\\n uint256 rewardMultiplier\\n ) external;\\n\\n /// @notice Sets reward in T tokens for notification of misbehaviour\\n /// of one staking provider. Can only be called by the governance.\\n function setNotificationReward(uint96 reward) external;\\n\\n /// @notice Transfer some amount of T tokens as reward for notifications\\n /// of misbehaviour\\n function pushNotificationReward(uint96 reward) external;\\n\\n /// @notice Withdraw some amount of T tokens from notifiers treasury.\\n /// Can only be called by the governance.\\n function withdrawNotificationReward(address recipient, uint96 amount)\\n external;\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount that should be slashed from each one of them. Can only be\\n /// called by application authorized for all staking providers in\\n /// the array.\\n function slash(uint96 amount, address[] memory stakingProviders) external;\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each staking\\n /// provider from notifiers treasury. Can only be called by\\n /// application authorized for all staking providers in the array.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultipier,\\n address notifier,\\n address[] memory stakingProviders\\n ) external;\\n\\n /// @notice Takes the given number of queued slashing operations and\\n /// processes them. Receives 5% of the slashed amount.\\n /// Executes `involuntaryAllocationDecrease` function on each\\n /// affected application.\\n function processSlashing(uint256 count) external;\\n\\n //\\n //\\n // Auxiliary functions\\n //\\n //\\n\\n /// @notice Returns the authorized stake amount of the staking provider for\\n /// the application.\\n function authorizedStake(address stakingProvider, address application)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice Returns staked amount of T, Keep and Nu for the specified\\n /// staking provider.\\n /// @dev All values are in T denomination\\n function stakes(address stakingProvider)\\n external\\n view\\n returns (\\n uint96 tStake,\\n uint96 keepInTStake,\\n uint96 nuInTStake\\n );\\n\\n /// @notice Returns start staking timestamp.\\n /// @dev This value is set at most once.\\n function getStartStakingTimestamp(address stakingProvider)\\n external\\n view\\n returns (uint256);\\n\\n /// @notice Returns staked amount of NU for the specified staking provider.\\n function stakedNu(address stakingProvider) external view returns (uint256);\\n\\n /// @notice Gets the stake owner, the beneficiary and the authorizer\\n /// for the specified staking provider address.\\n /// @return owner Stake owner address.\\n /// @return beneficiary Beneficiary address.\\n /// @return authorizer Authorizer address.\\n function rolesOf(address stakingProvider)\\n external\\n view\\n returns (\\n address owner,\\n address payable beneficiary,\\n address authorizer\\n );\\n\\n /// @notice Returns length of application array\\n function getApplicationsLength() external view returns (uint256);\\n\\n /// @notice Returns length of slashing queue\\n function getSlashingQueueLength() external view returns (uint256);\\n\\n /// @notice Returns minimum possible stake for T, KEEP or NU in T\\n /// denomination.\\n /// @dev For example, suppose the given staking provider has 10 T, 20 T\\n /// worth of KEEP, and 30 T worth of NU all staked, and the maximum\\n /// application authorization is 40 T, then `getMinStaked` for\\n /// that staking provider returns:\\n /// * 0 T if KEEP stake type specified i.e.\\n /// min = 40 T max - (10 T + 30 T worth of NU) = 0 T\\n /// * 10 T if NU stake type specified i.e.\\n /// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T\\n /// * 0 T if T stake type specified i.e.\\n /// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T\\n /// In other words, the minimum stake amount for the specified\\n /// stake type is the minimum amount of stake of the given type\\n /// needed to satisfy the maximum application authorization given the\\n /// staked amounts of the other stake types for that staking provider.\\n function getMinStaked(address stakingProvider, StakeType stakeTypes)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice Returns available amount to authorize for the specified application\\n function getAvailableToAuthorize(\\n address stakingProvider,\\n address application\\n ) external view returns (uint96);\\n}\\n\",\"keccak256\":\"0x5fde659b8fe5fffb695e55d84df1b1efe89978470d2d7a42f287d92a7fcc8b79\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/KeepStake.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 \\\"./ILegacyTokenStaking.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title KEEP ManagedGrant contract interface\\ninterface IManagedGrant {\\n function grantee() external view returns (address);\\n}\\n\\n/// @title KEEP stake owner resolver\\n/// @notice T network staking contract supports existing KEEP stakes by allowing\\n/// KEEP stakers to use their stakes in T network and weights them based\\n/// on KEEP<>T token ratio. KEEP stake owner is cached in T staking\\n/// contract and used to restrict access to all functions only owner or\\n/// operator should call. To cache KEEP stake owner in T staking\\n/// contract, T staking contract first needs to resolve the owner.\\n///\\n/// Resolving liquid KEEP stake owner is easy. Resolving token grant\\n/// stake owner is complicated and not possible to do on-chain from\\n/// a contract external to KEEP TokenStaking contract. Keep TokenStaking\\n/// knows the grant ID but does not expose it externally.\\n///\\n/// KeepStake contract addresses this problem by exposing\\n/// operator-owner mappings snapshotted off-chain based on events and\\n/// information publicly available from KEEP TokenStaking contract and\\n/// KEEP TokenGrant contract. Additionally, it gives the Governance\\n/// ability to add new mappings in case they are ever needed; in\\n/// practice, this will be needed only if someone decides to stake their\\n/// KEEP token grant in KEEP network after 2021-11-11 when the snapshot\\n/// was taken.\\n///\\n/// Operator-owner pairs were snapshotted 2021-11-11 in the following\\n/// way:\\n/// 1. Fetch all TokenStaking events from KEEP staking contract.\\n/// 2. Filter out undelegated operators.\\n/// 3. Filter out canceled delegations.\\n/// 4. Fetch grant stake information from KEEP TokenGrant for that\\n/// operator to determine if we are dealing with grant delegation.\\n/// 5. Fetch grantee address from KEEP TokenGrant contract.\\n/// 6. Check if we are dealing with ManagedGrant by looking for all\\n/// created ManagedGrants and comparing their address against grantee\\n/// address fetched from TokenGrant contract.\\ncontract KeepStake is Ownable {\\n IKeepTokenStaking public immutable keepTokenStaking;\\n\\n mapping(address => address) public operatorToManagedGrant;\\n mapping(address => address) public operatorToGrantee;\\n\\n constructor(IKeepTokenStaking _keepTokenStaking) {\\n keepTokenStaking = _keepTokenStaking;\\n }\\n\\n /// @notice Allows the Governance to set new operator-managed grant pair.\\n /// This function should only be called for managed grants if\\n /// the snapshot does include this pair.\\n function setManagedGrant(address operator, address managedGrant)\\n external\\n onlyOwner\\n {\\n operatorToManagedGrant[operator] = managedGrant;\\n }\\n\\n /// @notice Allows the Governance to set new operator-grantee pair.\\n /// This function should only be called for non-managed grants if\\n /// the snapshot does include this pair.\\n function setGrantee(address operator, address grantee) external onlyOwner {\\n operatorToGrantee[operator] = grantee;\\n }\\n\\n /// @notice Resolves KEEP stake owner for the provided operator address.\\n /// Reverts if could not resolve the owner.\\n function resolveOwner(address operator) external view returns (address) {\\n address owner = operatorToManagedGrant[operator];\\n if (owner != address(0)) {\\n return IManagedGrant(owner).grantee();\\n }\\n\\n owner = operatorToGrantee[operator];\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = resolveSnapshottedManagedGrantees(operator);\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = resolveSnapshottedGrantees(operator);\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = keepTokenStaking.ownerOf(operator);\\n require(owner != address(0), \\\"Could not resolve the owner\\\");\\n\\n return owner;\\n }\\n\\n function resolveSnapshottedManagedGrantees(address operator)\\n internal\\n view\\n returns (address)\\n {\\n if (operator == 0x855A951162B1B93D70724484d5bdc9D00B56236B) {\\n return\\n IManagedGrant(0xFADbF758307A054C57B365Db1De90acA71feaFE5)\\n .grantee();\\n }\\n if (operator == 0xF1De9490Bf7298b5F350cE74332Ad7cf8d5cB181) {\\n return\\n IManagedGrant(0xAEd493Aaf3E76E83b29E151848b71eF4544f92f1)\\n .grantee();\\n }\\n if (operator == 0x39d2aCBCD80d80080541C6eed7e9feBb8127B2Ab) {\\n return\\n IManagedGrant(0xA2fa09D6f8C251422F5fde29a0BAd1C53dEfAe66)\\n .grantee();\\n }\\n if (operator == 0xd66cAE89FfBc6E50e6b019e45c1aEc93Dec54781) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0x2eBE08379f4fD866E871A9b9E1d5C695154C6A9F) {\\n return\\n IManagedGrant(0xd00c0d43b747C33726B3f0ff4BDA4b72dc53c6E9)\\n .grantee();\\n }\\n if (operator == 0xA97c34278162b556A527CFc01B53eb4DDeDFD223) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x6C76d49322C9f8761A1623CEd89A31490cdB649d) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x4a41c7a884d119eaaefE471D0B3a638226408382) {\\n return\\n IManagedGrant(0xcdf3d216d82a463Ce82971F2F5DA3d8f9C5f093A)\\n .grantee();\\n }\\n if (operator == 0x9c06Feb7Ebc8065ee11Cd5E8EEdaAFb2909A7087) {\\n return\\n IManagedGrant(0x45119cd98d145283762BA9eBCAea75F72D188733)\\n .grantee();\\n }\\n if (operator == 0x9bD818Ab6ACC974f2Cf2BD2EBA7a250126Accb9F) {\\n return\\n IManagedGrant(0x6E535043377067621954ee84065b0bd7357e7aBa)\\n .grantee();\\n }\\n if (operator == 0x1d803c89760F8B4057DB15BCb3B8929E0498D310) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x3101927DEeC27A2bfA6c4a6316e3A221f631dB91) {\\n return\\n IManagedGrant(0x178Bf1946feD0e2362fdF8bcD3f91F0701a012C6)\\n .grantee();\\n }\\n if (operator == 0x9d9b187E478bC62694A7bED216Fc365de87F280C) {\\n return\\n IManagedGrant(0xFBad17CFad6cb00D726c65501D69FdC13Ca5477c)\\n .grantee();\\n }\\n if (operator == 0xd977144724Bc77FaeFAe219F958AE3947205d0b5) {\\n return\\n IManagedGrant(0x087B442BFd4E42675cf2df5fa566F87d7A96Fb12)\\n .grantee();\\n }\\n if (operator == 0x045E511f53DeBF55c9C0B4522f14F602f7C7cA81) {\\n return\\n IManagedGrant(0xFcfe8C036C414a15cF871071c483687095caF7D6)\\n .grantee();\\n }\\n if (operator == 0x3Dd301b3c96A282d8092E1e6f6846f24172D45C1) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x5d84DEB482E770479154028788Df79aA7C563aA4) {\\n return\\n IManagedGrant(0x9D1a179c469a8BdD0b683A9f9250246cc47e8fBE)\\n .grantee();\\n }\\n if (operator == 0x1dF927B69A97E8140315536163C029d188e8573b) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x617daCE069Fbd41993491de211b4DfccdAcbd348) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x650A9eD18Df873cad98C88dcaC8170531cAD2399) {\\n return\\n IManagedGrant(0x1Df7324A3aD20526DFa02Cc803eD2D97Cac81F3b)\\n .grantee();\\n }\\n if (operator == 0x07C9a8f8264221906b7b8958951Ce4753D39628B) {\\n return\\n IManagedGrant(0x305D12b4d70529Cd618dA7399F5520701E510041)\\n .grantee();\\n }\\n if (operator == 0x63eB4c3DD0751F9BE7070A01156513C227fa1eF6) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0xc6349eEC31048787676b6297ba71721376A8DdcF) {\\n return\\n IManagedGrant(0xac1a985E75C6a0b475b9c807Ad0705a988Be2D99)\\n .grantee();\\n }\\n if (operator == 0x3B945f9C0C8737e44f8e887d4F04B5B3A491Ac4d) {\\n return\\n IManagedGrant(0x82e17477726E8D9D2C237745cA9989631582eE98)\\n .grantee();\\n }\\n if (operator == 0xF35343299a4f80Dd5D917bbe5ddd54eBB820eBd4) {\\n return\\n IManagedGrant(0xCC88c15506251B62ccCeebA193e100d6bBC9a30D)\\n .grantee();\\n }\\n if (operator == 0x3B9e5ae72d068448bB96786989c0d86FBC0551D1) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0xB2D53Be158Cb8451dFc818bD969877038c1BdeA1) {\\n return\\n IManagedGrant(0xaE55e3800f0A3feaFdcE535A8C0fab0fFdB90DEe)\\n .grantee();\\n }\\n if (operator == 0xF6dbF7AFe05b8Bb6f198eC7e69333c98D3C4608C) {\\n return\\n IManagedGrant(0xbb8D24a20c20625f86739824014C3cBAAAb26700)\\n .grantee();\\n }\\n if (operator == 0xB62Fc1ADfFb2ab832041528C8178358338d85f76) {\\n return\\n IManagedGrant(0x9ED98fD1C29018B9342CB8F57A3073B9695f0c02)\\n .grantee();\\n }\\n if (operator == 0x9bC8d30d971C9e74298112803036C05db07D73e3) {\\n return\\n IManagedGrant(0x66beda757939f8e505b5Eb883cd02C8d4a11Bca2)\\n .grantee();\\n }\\n\\n return address(0);\\n }\\n\\n function resolveSnapshottedGrantees(address operator)\\n internal\\n pure\\n returns (address)\\n {\\n if (operator == 0x1147ccFB4AEFc6e587a23b78724Ef20Ec6e474D4) {\\n return 0x3FB49dA4375Ef9019f17990D04c6d5daD482D80a;\\n }\\n if (operator == 0x4c21541f95a00C03C75F38C71DC220bd27cbbEd9) {\\n return 0xC897cfeE43a8d827F76D4226994D5CE5EBBe2571;\\n }\\n if (operator == 0x7E6332d18719a5463d3867a1a892359509589a3d) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0x8Bd660A764Ca14155F3411a4526a028b6316CB3E) {\\n return 0xf6f372DfAeCC1431186598c304e91B79Ce115766;\\n }\\n if (operator == 0x4F4f0D0dfd93513B3f4Cb116Fe9d0A005466F725) {\\n return 0x8b055ac1c4dd287E2a46D4a52d61FE76FB551bD0;\\n }\\n if (operator == 0x1DF0250027fEC876d8876d1ac7A392c9098F1a1e) {\\n return 0xE408fFa969707Ce5d7aA3e5F8d44674Fa4b26219;\\n }\\n if (operator == 0x860EF3f83B6adFEF757F98345c3B8DdcFCA9d152) {\\n return 0x08a3633AAb8f3E436DEA204288Ee26Fe094406b0;\\n }\\n if (operator == 0xe3a2d16dA142E6B190A5d9F7e0C07cc460B58A5F) {\\n return 0x875f8fFCDDeD63B5d8Cf54be4E4b82FE6c6E249C;\\n }\\n if (operator == 0xBDE07f1cA107Ef319b0Bb26eBF1d0a5b4c97ffc1) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0xE86181D6b672d78D33e83029fF3D0ef4A601B4C4) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0xb7c561e2069aCaE2c4480111B1606790BB4E13fE) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0x526c013f8382B050d32d86e7090Ac84De22EdA4D) {\\n return 0x61C6E5DDacded540CD08066C08cbc096d22D91f4;\\n }\\n\\n return address(0);\\n }\\n}\\n\",\"keccak256\":\"0xc75f6be595ec0e0c885d689786808a53b70c0a170a53dd344228359dc6aaf178\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/TokenStaking.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 \\\"./IApplication.sol\\\";\\nimport \\\"./ILegacyTokenStaking.sol\\\";\\nimport \\\"./IStaking.sol\\\";\\nimport \\\"./KeepStake.sol\\\";\\nimport \\\"../governance/Checkpoints.sol\\\";\\nimport \\\"../token/T.sol\\\";\\nimport \\\"../utils/PercentUtils.sol\\\";\\nimport \\\"../utils/SafeTUpgradeable.sol\\\";\\nimport \\\"../vending/VendingMachine.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\n\\n/// @notice TokenStaking is the main staking contract of the Threshold Network.\\n/// Apart from the basic usage of enabling T stakes, it also acts as a\\n/// sort of \\\"meta-staking\\\" contract, accepting existing legacy NU/KEEP\\n/// stakes. Additionally, it serves as application manager for the apps\\n/// that run on the Threshold Network. Note that legacy NU/KEEP staking\\n/// contracts see TokenStaking as an application (e.g., slashing is\\n/// requested by TokenStaking and performed by the legacy contracts).\\n/// @dev TokenStaking is upgradeable, using OpenZeppelin's Upgradeability\\n/// framework. As such, it is required to satisfy OZ's guidelines, like\\n/// restrictions on constructors, immutable variables, base contracts and\\n/// libraries. See https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable\\ncontract TokenStaking is Initializable, IStaking, Checkpoints {\\n using SafeTUpgradeable for T;\\n using PercentUtils for uint256;\\n using SafeCastUpgradeable for uint256;\\n\\n enum ApplicationStatus {\\n NOT_APPROVED,\\n APPROVED,\\n PAUSED,\\n DISABLED\\n }\\n\\n struct StakingProviderInfo {\\n uint96 nuInTStake;\\n address owner;\\n uint96 keepInTStake;\\n address payable beneficiary;\\n uint96 tStake;\\n address authorizer;\\n mapping(address => AppAuthorization) authorizations;\\n address[] authorizedApplications;\\n uint256 startStakingTimestamp;\\n }\\n\\n struct AppAuthorization {\\n uint96 authorized;\\n uint96 deauthorizing;\\n }\\n\\n struct ApplicationInfo {\\n ApplicationStatus status;\\n address panicButton;\\n }\\n\\n struct SlashingEvent {\\n address stakingProvider;\\n uint96 amount;\\n }\\n\\n uint256 internal constant SLASHING_REWARD_PERCENT = 5;\\n uint256 internal constant MIN_STAKE_TIME = 24 hours;\\n uint256 internal constant GAS_LIMIT_AUTHORIZATION_DECREASE = 250000;\\n uint256 internal constant CONVERSION_DIVISOR = 10**(18 - 3);\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n T internal immutable token;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IKeepTokenStaking internal immutable keepStakingContract;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n KeepStake internal immutable keepStake;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n INuCypherStakingEscrow internal immutable nucypherStakingContract;\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable keepRatio;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable nucypherRatio;\\n\\n address public governance;\\n uint96 public minTStakeAmount;\\n uint256 public authorizationCeiling;\\n uint96 public stakeDiscrepancyPenalty;\\n uint256 public stakeDiscrepancyRewardMultiplier;\\n\\n uint256 public notifiersTreasury;\\n uint256 public notificationReward;\\n\\n mapping(address => StakingProviderInfo) internal stakingProviders;\\n mapping(address => ApplicationInfo) public applicationInfo;\\n address[] public applications;\\n\\n SlashingEvent[] public slashingQueue;\\n uint256 public slashingQueueIndex;\\n\\n event Staked(\\n StakeType indexed stakeType,\\n address indexed owner,\\n address indexed stakingProvider,\\n address beneficiary,\\n address authorizer,\\n uint96 amount\\n );\\n event MinimumStakeAmountSet(uint96 amount);\\n event ApplicationStatusChanged(\\n address indexed application,\\n ApplicationStatus indexed newStatus\\n );\\n event AuthorizationIncreased(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationDecreaseRequested(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationDecreaseApproved(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationInvoluntaryDecreased(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount,\\n bool indexed successfulCall\\n );\\n event PanicButtonSet(\\n address indexed application,\\n address indexed panicButton\\n );\\n event AuthorizationCeilingSet(uint256 ceiling);\\n event ToppedUp(address indexed stakingProvider, uint96 amount);\\n event Unstaked(address indexed stakingProvider, uint96 amount);\\n event TokensSeized(\\n address indexed stakingProvider,\\n uint96 amount,\\n bool indexed discrepancy\\n );\\n event StakeDiscrepancyPenaltySet(uint96 penalty, uint256 rewardMultiplier);\\n event NotificationRewardSet(uint96 reward);\\n event NotificationRewardPushed(uint96 reward);\\n event NotificationRewardWithdrawn(address recipient, uint96 amount);\\n event NotifierRewarded(address indexed notifier, uint256 amount);\\n event SlashingProcessed(\\n address indexed caller,\\n uint256 count,\\n uint256 tAmount\\n );\\n event OwnerRefreshed(\\n address indexed stakingProvider,\\n address indexed oldOwner,\\n address indexed newOwner\\n );\\n event GovernanceTransferred(address oldGovernance, address newGovernance);\\n\\n modifier onlyGovernance() {\\n require(governance == msg.sender, \\\"Caller is not the governance\\\");\\n _;\\n }\\n\\n modifier onlyPanicButtonOf(address application) {\\n require(\\n applicationInfo[application].panicButton == msg.sender,\\n \\\"Caller is not the panic button\\\"\\n );\\n _;\\n }\\n\\n modifier onlyAuthorizerOf(address stakingProvider) {\\n //slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].authorizer == msg.sender,\\n \\\"Not authorizer\\\"\\n );\\n _;\\n }\\n\\n modifier onlyOwnerOrStakingProvider(address stakingProvider) {\\n //slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].owner != address(0) &&\\n (stakingProvider == msg.sender ||\\n stakingProviders[stakingProvider].owner == msg.sender),\\n \\\"Not owner or provider\\\"\\n );\\n _;\\n }\\n\\n /// @param _token Address of T token contract\\n /// @param _keepStakingContract Address of Keep staking contract\\n /// @param _nucypherStakingContract Address of NuCypher staking contract\\n /// @param _keepVendingMachine Address of Keep vending machine\\n /// @param _nucypherVendingMachine Address of NuCypher vending machine\\n /// @param _keepStake Address of Keep contract with grant owners\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n T _token,\\n IKeepTokenStaking _keepStakingContract,\\n INuCypherStakingEscrow _nucypherStakingContract,\\n VendingMachine _keepVendingMachine,\\n VendingMachine _nucypherVendingMachine,\\n KeepStake _keepStake\\n ) {\\n // calls to check contracts are working\\n require(\\n _token.totalSupply() > 0 &&\\n _keepStakingContract.ownerOf(address(0)) == address(0) &&\\n _nucypherStakingContract.getAllTokens(address(0)) == 0 &&\\n AddressUpgradeable.isContract(address(_keepStake)),\\n \\\"Wrong input parameters\\\"\\n );\\n token = _token;\\n keepStakingContract = _keepStakingContract;\\n keepStake = _keepStake;\\n nucypherStakingContract = _nucypherStakingContract;\\n\\n keepRatio = _keepVendingMachine.ratio();\\n nucypherRatio = _nucypherVendingMachine.ratio();\\n }\\n\\n function initialize() external initializer {\\n _transferGovernance(msg.sender);\\n }\\n\\n //\\n //\\n // Delegating a stake\\n //\\n //\\n\\n /// @notice Creates a delegation with `msg.sender` owner with the given\\n /// staking provider, beneficiary, and authorizer. Transfers the\\n /// given amount of T to the staking contract.\\n /// @dev The owner of the delegation needs to have the amount approved to\\n /// transfer to the staking contract.\\n function stake(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer,\\n uint96 amount\\n ) external override {\\n require(\\n stakingProvider != address(0) &&\\n beneficiary != address(0) &&\\n authorizer != address(0),\\n \\\"Parameters must be specified\\\"\\n );\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n (, uint256 createdAt, ) = keepStakingContract.getDelegationInfo(\\n stakingProvider\\n );\\n require(\\n createdAt == 0 && stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n require(\\n amount > 0 && amount >= minTStakeAmount,\\n \\\"Amount is less than minimum\\\"\\n );\\n stakingProviderStruct.owner = msg.sender;\\n stakingProviderStruct.authorizer = authorizer;\\n stakingProviderStruct.beneficiary = beneficiary;\\n\\n stakingProviderStruct.tStake = amount;\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, amount);\\n\\n emit Staked(\\n StakeType.T,\\n msg.sender,\\n stakingProvider,\\n beneficiary,\\n authorizer,\\n amount\\n );\\n token.safeTransferFrom(msg.sender, address(this), amount);\\n }\\n\\n /// @notice Copies delegation from the legacy KEEP staking contract to T\\n /// staking contract. No tokens are transferred. Caches the active\\n /// stake amount from KEEP staking contract. Can be called by\\n /// anyone.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function stakeKeep(address stakingProvider) external override {\\n require(stakingProvider != address(0), \\\"Parameters must be specified\\\");\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n\\n require(\\n stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n\\n uint96 tAmount = getKeepAmountInT(stakingProvider);\\n require(tAmount != 0, \\\"Nothing to sync\\\");\\n\\n stakingProviderStruct.keepInTStake = tAmount;\\n stakingProviderStruct.owner = keepStake.resolveOwner(stakingProvider);\\n stakingProviderStruct.authorizer = keepStakingContract.authorizerOf(\\n stakingProvider\\n );\\n stakingProviderStruct.beneficiary = keepStakingContract.beneficiaryOf(\\n stakingProvider\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, tAmount);\\n\\n emit Staked(\\n StakeType.KEEP,\\n stakingProviderStruct.owner,\\n stakingProvider,\\n stakingProviderStruct.beneficiary,\\n stakingProviderStruct.authorizer,\\n tAmount\\n );\\n }\\n\\n /// @notice Copies delegation from the legacy NU staking contract to T\\n /// staking contract, additionally appointing beneficiary and\\n /// authorizer roles. Caches the amount staked in NU staking\\n /// contract. Can be called only by the original delegation owner.\\n function stakeNu(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer\\n ) external override {\\n require(\\n stakingProvider != address(0) &&\\n beneficiary != address(0) &&\\n authorizer != address(0),\\n \\\"Parameters must be specified\\\"\\n );\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n (, uint256 createdAt, ) = keepStakingContract.getDelegationInfo(\\n stakingProvider\\n );\\n require(\\n createdAt == 0 && stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n\\n uint96 tAmount = getNuAmountInT(msg.sender, stakingProvider);\\n require(tAmount > 0, \\\"Nothing to sync\\\");\\n\\n stakingProviderStruct.nuInTStake = tAmount;\\n stakingProviderStruct.owner = msg.sender;\\n stakingProviderStruct.authorizer = authorizer;\\n stakingProviderStruct.beneficiary = beneficiary;\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, tAmount);\\n\\n emit Staked(\\n StakeType.NU,\\n msg.sender,\\n stakingProvider,\\n beneficiary,\\n authorizer,\\n tAmount\\n );\\n }\\n\\n /// @notice Refresh Keep stake owner. Can be called only by the old owner\\n /// or their staking provider.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function refreshKeepStakeOwner(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n address newOwner = keepStake.resolveOwner(stakingProvider);\\n\\n emit OwnerRefreshed(\\n stakingProvider,\\n stakingProviderStruct.owner,\\n newOwner\\n );\\n stakingProviderStruct.owner = newOwner;\\n }\\n\\n /// @notice Allows the Governance to set the minimum required stake amount.\\n /// This amount is required to protect against griefing the staking\\n /// contract and individual applications are allowed to require\\n /// higher minimum stakes if necessary.\\n /// @dev Staking providers are not required to maintain a minimum T stake\\n /// all the time. 24 hours after the delegation, T stake can be reduced\\n /// below the minimum stake. The minimum stake in the staking contract\\n /// is just to protect against griefing stake operation. Please note\\n /// that each application may have its own minimum authorization though\\n /// and the authorization can not be higher than the stake.\\n function setMinimumStakeAmount(uint96 amount)\\n external\\n override\\n onlyGovernance\\n {\\n minTStakeAmount = amount;\\n emit MinimumStakeAmountSet(amount);\\n }\\n\\n //\\n //\\n // Authorizing an application\\n //\\n //\\n\\n /// @notice Allows the Governance to approve the particular application\\n /// before individual stake authorizers are able to authorize it.\\n function approveApplication(address application)\\n external\\n override\\n onlyGovernance\\n {\\n require(application != address(0), \\\"Parameters must be specified\\\");\\n ApplicationInfo storage info = applicationInfo[application];\\n require(\\n info.status == ApplicationStatus.NOT_APPROVED ||\\n info.status == ApplicationStatus.PAUSED,\\n \\\"Can't approve application\\\"\\n );\\n\\n if (info.status == ApplicationStatus.NOT_APPROVED) {\\n applications.push(application);\\n }\\n info.status = ApplicationStatus.APPROVED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.APPROVED);\\n }\\n\\n /// @notice Increases the authorization of the given staking provider for\\n /// the given application by the given amount. Can only be called by\\n /// the given staking provider\\u2019s authorizer.\\n /// @dev Calls `authorizationIncreased` callback on the given application to\\n /// notify the application about authorization change.\\n /// See `IApplication`.\\n function increaseAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external override onlyAuthorizerOf(stakingProvider) {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[application];\\n uint96 fromAmount = authorization.authorized;\\n if (fromAmount == 0) {\\n require(\\n authorizationCeiling == 0 ||\\n stakingProviderStruct.authorizedApplications.length <\\n authorizationCeiling,\\n \\\"Too many applications\\\"\\n );\\n stakingProviderStruct.authorizedApplications.push(application);\\n }\\n\\n uint96 availableTValue = getAvailableToAuthorize(\\n stakingProvider,\\n application\\n );\\n require(availableTValue >= amount, \\\"Not enough stake to authorize\\\");\\n authorization.authorized += amount;\\n emit AuthorizationIncreased(\\n stakingProvider,\\n application,\\n fromAmount,\\n authorization.authorized\\n );\\n IApplication(application).authorizationIncreased(\\n stakingProvider,\\n fromAmount,\\n authorization.authorized\\n );\\n }\\n\\n /// @notice Requests decrease of all authorizations for the given staking\\n /// provider on all applications by all authorized amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application.\\n /// @dev Calls `authorizationDecreaseRequested` callback\\n /// for each authorized application. See `IApplication`.\\n function requestAuthorizationDecrease(address stakingProvider) external {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 deauthorizing = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address application = stakingProviderStruct.authorizedApplications[\\n i\\n ];\\n uint96 authorized = stakingProviderStruct\\n .authorizations[application]\\n .authorized;\\n if (authorized > 0) {\\n requestAuthorizationDecrease(\\n stakingProvider,\\n application,\\n authorized\\n );\\n deauthorizing += authorized;\\n }\\n }\\n\\n require(deauthorizing > 0, \\\"Nothing was authorized\\\");\\n }\\n\\n /// @notice Called by the application at its discretion to approve the\\n /// previously requested authorization decrease request. Can only be\\n /// called by the application that was previously requested to\\n /// decrease the authorization for that staking provider.\\n /// Returns resulting authorized amount for the application.\\n function approveAuthorizationDecrease(address stakingProvider)\\n external\\n override\\n returns (uint96)\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[msg.sender];\\n require(authorization.deauthorizing > 0, \\\"No deauthorizing in process\\\");\\n\\n uint96 fromAmount = authorization.authorized;\\n authorization.authorized -= authorization.deauthorizing;\\n authorization.deauthorizing = 0;\\n emit AuthorizationDecreaseApproved(\\n stakingProvider,\\n msg.sender,\\n fromAmount,\\n authorization.authorized\\n );\\n\\n // remove application from an array\\n if (authorization.authorized == 0) {\\n cleanAuthorizedApplications(stakingProviderStruct, 1);\\n }\\n\\n return authorization.authorized;\\n }\\n\\n /// @notice Decreases the authorization for the given `stakingProvider` on\\n /// the given disabled `application`, for all authorized amount.\\n /// Can be called by anyone.\\n function forceDecreaseAuthorization(\\n address stakingProvider,\\n address application\\n ) external override {\\n require(\\n applicationInfo[application].status == ApplicationStatus.DISABLED,\\n \\\"Application is not disabled\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[application];\\n uint96 fromAmount = authorization.authorized;\\n require(fromAmount > 0, \\\"Application is not authorized\\\");\\n authorization.authorized = 0;\\n authorization.deauthorizing = 0;\\n\\n emit AuthorizationDecreaseApproved(\\n stakingProvider,\\n application,\\n fromAmount,\\n 0\\n );\\n cleanAuthorizedApplications(stakingProviderStruct, 1);\\n }\\n\\n /// @notice Pauses the given application\\u2019s eligibility to slash stakes.\\n /// Besides that stakers can't change authorization to the application.\\n /// Can be called only by the Panic Button of the particular\\n /// application. The paused application can not slash stakes until\\n /// it is approved again by the Governance using `approveApplication`\\n /// function. Should be used only in case of an emergency.\\n function pauseApplication(address application)\\n external\\n override\\n onlyPanicButtonOf(application)\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Can't pause application\\\"\\n );\\n applicationStruct.status = ApplicationStatus.PAUSED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.PAUSED);\\n }\\n\\n /// @notice Disables the given application. The disabled application can't\\n /// slash stakers. Also stakers can't increase authorization to that\\n /// application but can decrease without waiting by calling\\n /// `forceDecreaseAuthorization` at any moment. Can be called only\\n /// by the governance. The disabled application can't be approved\\n /// again. Should be used only in case of an emergency.\\n function disableApplication(address application)\\n external\\n override\\n onlyGovernance\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED ||\\n applicationStruct.status == ApplicationStatus.PAUSED,\\n \\\"Can't disable application\\\"\\n );\\n applicationStruct.status = ApplicationStatus.DISABLED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.DISABLED);\\n }\\n\\n /// @notice Sets the Panic Button role for the given application to the\\n /// provided address. Can only be called by the Governance. If the\\n /// Panic Button for the given application should be disabled, the\\n /// role address should be set to 0x0 address.\\n function setPanicButton(address application, address panicButton)\\n external\\n override\\n onlyGovernance\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n applicationStruct.panicButton = panicButton;\\n emit PanicButtonSet(application, panicButton);\\n }\\n\\n /// @notice Sets the maximum number of applications one staking provider can\\n /// have authorized. Used to protect against DoSing slashing queue.\\n /// Can only be called by the Governance.\\n function setAuthorizationCeiling(uint256 ceiling)\\n external\\n override\\n onlyGovernance\\n {\\n authorizationCeiling = ceiling;\\n emit AuthorizationCeilingSet(ceiling);\\n }\\n\\n //\\n //\\n // Stake top-up\\n //\\n //\\n\\n /// @notice Increases the amount of the stake for the given staking provider.\\n /// @dev The sender of this transaction needs to have the amount approved to\\n /// transfer to the staking contract.\\n function topUp(address stakingProvider, uint96 amount) external override {\\n require(\\n stakingProviders[stakingProvider].owner != address(0),\\n \\\"Nothing to top-up\\\"\\n );\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n stakingProviderStruct.tStake += amount;\\n emit ToppedUp(stakingProvider, amount);\\n increaseStakeCheckpoint(stakingProvider, amount);\\n token.safeTransferFrom(msg.sender, address(this), amount);\\n }\\n\\n /// @notice Propagates information about stake top-up from the legacy KEEP\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpKeep(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 tAmount = getKeepAmountInT(stakingProvider);\\n require(\\n tAmount > stakingProviderStruct.keepInTStake,\\n \\\"Nothing to top-up\\\"\\n );\\n\\n uint96 toppedUp = tAmount - stakingProviderStruct.keepInTStake;\\n emit ToppedUp(stakingProvider, toppedUp);\\n stakingProviderStruct.keepInTStake = tAmount;\\n increaseStakeCheckpoint(stakingProvider, toppedUp);\\n }\\n\\n /// @notice Propagates information about stake top-up from the legacy NU\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpNu(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 tAmount = getNuAmountInT(\\n stakingProviderStruct.owner,\\n stakingProvider\\n );\\n require(\\n tAmount > stakingProviderStruct.nuInTStake,\\n \\\"Nothing to top-up\\\"\\n );\\n\\n uint96 toppedUp = tAmount - stakingProviderStruct.nuInTStake;\\n emit ToppedUp(stakingProvider, toppedUp);\\n stakingProviderStruct.nuInTStake = tAmount;\\n increaseStakeCheckpoint(stakingProvider, toppedUp);\\n }\\n\\n //\\n //\\n // Undelegating a stake (unstaking)\\n //\\n //\\n\\n /// @notice Reduces the liquid T stake amount by the provided amount and\\n /// withdraws T to the owner. Reverts if there is at least one\\n /// authorization higher than the sum of the legacy stake and\\n /// remaining liquid T stake or if the unstake amount is higher than\\n /// the liquid T stake amount. Can be called only by the owner or\\n /// the staking provider. Can only be called when 24h passed since\\n /// the stake has been delegated.\\n function unstakeT(address stakingProvider, uint96 amount)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n amount > 0 &&\\n amount + getMinStaked(stakingProvider, StakeType.T) <=\\n stakingProviderStruct.tStake,\\n \\\"Too much to unstake\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n stakingProviderStruct.tStake -= amount;\\n decreaseStakeCheckpoint(stakingProvider, amount);\\n emit Unstaked(stakingProvider, amount);\\n token.safeTransfer(stakingProviderStruct.owner, amount);\\n }\\n\\n /// @notice Sets the legacy KEEP staking contract active stake amount cached\\n /// in T staking contract to 0. Reverts if the amount of liquid T\\n /// staked in T staking contract is lower than the highest\\n /// application authorization. This function allows to unstake from\\n /// KEEP staking contract and still being able to operate in T\\n /// network and earning rewards based on the liquid T staked. Can be\\n /// called only by the delegation owner or the staking provider.\\n /// Can only be called when 24h passed since the stake has been\\n /// delegated.\\n /// @dev This function (or `unstakeAll`) must be called before\\n /// `undelegate`/`undelegateAt` in Keep staking contract. Otherwise\\n /// provider can be slashed by `notifyKeepStakeDiscrepancy` method.\\n function unstakeKeep(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 keepInTStake = stakingProviderStruct.keepInTStake;\\n require(keepInTStake != 0, \\\"Nothing to unstake\\\");\\n require(\\n getMinStaked(stakingProvider, StakeType.KEEP) == 0,\\n \\\"Keep stake still authorized\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n emit Unstaked(stakingProvider, keepInTStake);\\n stakingProviderStruct.keepInTStake = 0;\\n decreaseStakeCheckpoint(stakingProvider, keepInTStake);\\n }\\n\\n /// @notice Reduces cached legacy NU stake amount by the provided amount.\\n /// Reverts if there is at least one authorization higher than the\\n /// sum of remaining legacy NU stake and liquid T stake for that\\n /// staking provider or if the untaked amount is higher than the\\n /// cached legacy stake amount. If succeeded, the legacy NU stake\\n /// can be partially or fully undelegated on the legacy staking\\n /// contract. This function allows to unstake from NU staking\\n /// contract and still being able to operate in T network and\\n /// earning rewards based on the liquid T staked. Can be called only\\n /// by the delegation owner or the staking provider. Can only be\\n /// called when 24h passed since the stake has been delegated.\\n /// @dev This function (or `unstakeAll`) must be called before `withdraw`\\n /// in NuCypher staking contract. Otherwise NU tokens can't be\\n /// unlocked.\\n /// @param stakingProvider Staking provider address\\n /// @param amount Amount of NU to unstake in T denomination\\n function unstakeNu(address stakingProvider, uint96 amount)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n // rounding amount to guarantee exact T<>NU conversion in both ways,\\n // so there's no remainder after unstaking\\n (, uint96 tRemainder) = convertFromT(amount, nucypherRatio);\\n amount -= tRemainder;\\n require(\\n amount > 0 &&\\n amount + getMinStaked(stakingProvider, StakeType.NU) <=\\n stakingProviderStruct.nuInTStake,\\n \\\"Too much to unstake\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n stakingProviderStruct.nuInTStake -= amount;\\n decreaseStakeCheckpoint(stakingProvider, amount);\\n emit Unstaked(stakingProvider, amount);\\n }\\n\\n /// @notice Sets cached legacy stake amount to 0, sets the liquid T stake\\n /// amount to 0 and withdraws all liquid T from the stake to the\\n /// owner. Reverts if there is at least one non-zero authorization.\\n /// Can be called only by the delegation owner or the staking\\n /// provider. Can only be called when 24h passed since the stake\\n /// has been delegated.\\n function unstakeAll(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n stakingProviderStruct.authorizedApplications.length == 0,\\n \\\"Stake still authorized\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n uint96 unstaked = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n emit Unstaked(stakingProvider, unstaked);\\n uint96 amount = stakingProviderStruct.tStake;\\n stakingProviderStruct.tStake = 0;\\n stakingProviderStruct.keepInTStake = 0;\\n stakingProviderStruct.nuInTStake = 0;\\n decreaseStakeCheckpoint(stakingProvider, unstaked);\\n\\n if (amount > 0) {\\n token.safeTransfer(stakingProviderStruct.owner, amount);\\n }\\n }\\n\\n //\\n //\\n // Keeping information in sync\\n //\\n //\\n\\n /// @notice Notifies about the discrepancy between legacy KEEP active stake\\n /// and the amount cached in T staking contract. Slashes the staking\\n /// provider in case the amount cached is higher than the actual\\n /// active stake amount in KEEP staking contract. Needs to update\\n /// authorizations of all affected applications and execute an\\n /// involuntary authorization decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyKeepStakeDiscrepancy(address stakingProvider)\\n external\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(stakingProviderStruct.keepInTStake > 0, \\\"Nothing to slash\\\");\\n\\n (uint256 keepStakeAmount, , uint256 undelegatedAt) = keepStakingContract\\n .getDelegationInfo(stakingProvider);\\n\\n (uint96 realKeepInTStake, ) = convertToT(keepStakeAmount, keepRatio);\\n uint96 oldKeepInTStake = stakingProviderStruct.keepInTStake;\\n\\n require(\\n oldKeepInTStake > realKeepInTStake || undelegatedAt != 0,\\n \\\"There is no discrepancy\\\"\\n );\\n stakingProviderStruct.keepInTStake = realKeepInTStake;\\n seizeKeep(\\n stakingProviderStruct,\\n stakingProvider,\\n stakeDiscrepancyPenalty,\\n stakeDiscrepancyRewardMultiplier\\n );\\n\\n uint96 slashedAmount = realKeepInTStake -\\n stakingProviderStruct.keepInTStake;\\n emit TokensSeized(stakingProvider, slashedAmount, true);\\n if (undelegatedAt != 0) {\\n stakingProviderStruct.keepInTStake = 0;\\n }\\n\\n decreaseStakeCheckpoint(\\n stakingProvider,\\n oldKeepInTStake - stakingProviderStruct.keepInTStake\\n );\\n\\n authorizationDecrease(\\n stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n }\\n\\n /// @notice Notifies about the discrepancy between legacy NU active stake\\n /// and the amount cached in T staking contract. Slashes the\\n /// staking provider in case the amount cached is higher than the\\n /// actual active stake amount in NU staking contract. Needs to\\n /// update authorizations of all affected applications and execute an\\n /// involuntary authorization decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n /// @dev Real discrepancy between T and Nu is impossible.\\n /// This method is a safeguard in case of bugs in NuCypher staking\\n /// contract\\n function notifyNuStakeDiscrepancy(address stakingProvider)\\n external\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(stakingProviderStruct.nuInTStake > 0, \\\"Nothing to slash\\\");\\n\\n uint256 nuStakeAmount = nucypherStakingContract.getAllTokens(\\n stakingProviderStruct.owner\\n );\\n (uint96 realNuInTStake, ) = convertToT(nuStakeAmount, nucypherRatio);\\n uint96 oldNuInTStake = stakingProviderStruct.nuInTStake;\\n require(oldNuInTStake > realNuInTStake, \\\"There is no discrepancy\\\");\\n\\n stakingProviderStruct.nuInTStake = realNuInTStake;\\n seizeNu(\\n stakingProviderStruct,\\n stakeDiscrepancyPenalty,\\n stakeDiscrepancyRewardMultiplier\\n );\\n\\n uint96 slashedAmount = realNuInTStake -\\n stakingProviderStruct.nuInTStake;\\n emit TokensSeized(stakingProvider, slashedAmount, true);\\n authorizationDecrease(\\n stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n decreaseStakeCheckpoint(\\n stakingProvider,\\n oldNuInTStake - stakingProviderStruct.nuInTStake\\n );\\n }\\n\\n /// @notice Sets the penalty amount for stake discrepancy and reward\\n /// multiplier for reporting it. The penalty is seized from the\\n /// delegated stake, and 5% of the penalty, scaled by the\\n /// multiplier, is given to the notifier. The rest of the tokens are\\n /// burned. Can only be called by the Governance. See `seize` function.\\n function setStakeDiscrepancyPenalty(\\n uint96 penalty,\\n uint256 rewardMultiplier\\n ) external override onlyGovernance {\\n stakeDiscrepancyPenalty = penalty;\\n stakeDiscrepancyRewardMultiplier = rewardMultiplier;\\n emit StakeDiscrepancyPenaltySet(penalty, rewardMultiplier);\\n }\\n\\n /// @notice Sets reward in T tokens for notification of misbehaviour\\n /// of one staking provider. Can only be called by the governance.\\n function setNotificationReward(uint96 reward)\\n external\\n override\\n onlyGovernance\\n {\\n notificationReward = reward;\\n emit NotificationRewardSet(reward);\\n }\\n\\n /// @notice Transfer some amount of T tokens as reward for notifications\\n /// of misbehaviour\\n function pushNotificationReward(uint96 reward) external override {\\n require(reward > 0, \\\"Parameters must be specified\\\");\\n notifiersTreasury += reward;\\n emit NotificationRewardPushed(reward);\\n token.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraw some amount of T tokens from notifiers treasury.\\n /// Can only be called by the governance.\\n function withdrawNotificationReward(address recipient, uint96 amount)\\n external\\n override\\n onlyGovernance\\n {\\n require(amount <= notifiersTreasury, \\\"Not enough tokens\\\");\\n notifiersTreasury -= amount;\\n emit NotificationRewardWithdrawn(recipient, amount);\\n token.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount that should be slashed from each one of them. Can only be\\n /// called by application authorized for all staking providers in\\n /// the array.\\n /// @dev This method doesn't emit events for providers that are added to\\n /// the queue. If necessary events can be added to the application\\n /// level.\\n function slash(uint96 amount, address[] memory _stakingProviders)\\n external\\n override\\n {\\n notify(amount, 0, address(0), _stakingProviders);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each provider from\\n /// notifiers treasury. Can only be called by application\\n /// authorized for all staking providers in the array.\\n /// @dev This method doesn't emit events for staking providers that are\\n /// added to the queue. If necessary events can be added to the\\n /// application level.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) external override {\\n notify(amount, rewardMultiplier, notifier, _stakingProviders);\\n }\\n\\n /// @notice Takes the given number of queued slashing operations and\\n /// processes them. Receives 5% of the slashed amount.\\n /// Executes `involuntaryAuthorizationDecrease` function on each\\n /// affected application.\\n function processSlashing(uint256 count) external virtual override {\\n require(\\n slashingQueueIndex < slashingQueue.length && count > 0,\\n \\\"Nothing to process\\\"\\n );\\n\\n uint256 maxIndex = slashingQueueIndex + count;\\n maxIndex = MathUpgradeable.min(maxIndex, slashingQueue.length);\\n count = maxIndex - slashingQueueIndex;\\n uint96 tAmountToBurn = 0;\\n\\n uint256 index = slashingQueueIndex;\\n for (; index < maxIndex; index++) {\\n SlashingEvent storage slashing = slashingQueue[index];\\n tAmountToBurn += processSlashing(slashing);\\n }\\n slashingQueueIndex = index;\\n\\n uint256 tProcessorReward = uint256(tAmountToBurn).percent(\\n SLASHING_REWARD_PERCENT\\n );\\n notifiersTreasury += tAmountToBurn - tProcessorReward.toUint96();\\n emit SlashingProcessed(msg.sender, count, tProcessorReward);\\n if (tProcessorReward > 0) {\\n token.safeTransfer(msg.sender, tProcessorReward);\\n }\\n }\\n\\n /// @notice Delegate voting power from the stake associated to the\\n /// `stakingProvider` to a `delegatee` address. Caller must be the\\n /// owner of this stake.\\n function delegateVoting(address stakingProvider, address delegatee)\\n external\\n {\\n delegate(stakingProvider, delegatee);\\n }\\n\\n /// @notice Transfers ownership of the contract to `newGuvnor`.\\n function transferGovernance(address newGuvnor)\\n external\\n virtual\\n onlyGovernance\\n {\\n _transferGovernance(newGuvnor);\\n }\\n\\n //\\n //\\n // Auxiliary functions\\n //\\n //\\n\\n /// @notice Returns the authorized stake amount of the staking provider for\\n /// the application.\\n function authorizedStake(address stakingProvider, address application)\\n external\\n view\\n override\\n returns (uint96)\\n {\\n return\\n stakingProviders[stakingProvider]\\n .authorizations[application]\\n .authorized;\\n }\\n\\n /// @notice Returns staked amount of T, Keep and Nu for the specified\\n /// staking provider.\\n /// @dev All values are in T denomination\\n function stakes(address stakingProvider)\\n external\\n view\\n override\\n returns (\\n uint96 tStake,\\n uint96 keepInTStake,\\n uint96 nuInTStake\\n )\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n tStake = stakingProviderStruct.tStake;\\n keepInTStake = stakingProviderStruct.keepInTStake;\\n nuInTStake = stakingProviderStruct.nuInTStake;\\n }\\n\\n /// @notice Returns start staking timestamp.\\n /// @dev This value is set at most once.\\n function getStartStakingTimestamp(address stakingProvider)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return stakingProviders[stakingProvider].startStakingTimestamp;\\n }\\n\\n /// @notice Returns staked amount of NU for the specified staking provider.\\n function stakedNu(address stakingProvider)\\n external\\n view\\n override\\n returns (uint256 nuAmount)\\n {\\n (nuAmount, ) = convertFromT(\\n stakingProviders[stakingProvider].nuInTStake,\\n nucypherRatio\\n );\\n }\\n\\n /// @notice Gets the stake owner, the beneficiary and the authorizer\\n /// for the specified staking provider address.\\n /// @return owner Stake owner address.\\n /// @return beneficiary Beneficiary address.\\n /// @return authorizer Authorizer address.\\n function rolesOf(address stakingProvider)\\n external\\n view\\n override\\n returns (\\n address owner,\\n address payable beneficiary,\\n address authorizer\\n )\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n owner = stakingProviderStruct.owner;\\n beneficiary = stakingProviderStruct.beneficiary;\\n authorizer = stakingProviderStruct.authorizer;\\n }\\n\\n /// @notice Returns length of application array\\n function getApplicationsLength() external view override returns (uint256) {\\n return applications.length;\\n }\\n\\n /// @notice Returns length of slashing queue\\n function getSlashingQueueLength() external view override returns (uint256) {\\n return slashingQueue.length;\\n }\\n\\n /// @notice Requests decrease of the authorization for the given staking\\n /// provider on the given application by the provided amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application if the application agrees for that. If the\\n /// application does not agree for overwriting, the function\\n /// reverts.\\n /// @dev Calls `authorizationDecreaseRequested` callback on the given\\n /// application. See `IApplication`.\\n function requestAuthorizationDecrease(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) public override onlyAuthorizerOf(stakingProvider) {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n\\n AppAuthorization storage authorization = stakingProviders[\\n stakingProvider\\n ].authorizations[application];\\n require(\\n authorization.authorized >= amount,\\n \\\"Amount exceeds authorized\\\"\\n );\\n\\n authorization.deauthorizing = amount;\\n uint96 deauthorizingTo = authorization.authorized - amount;\\n emit AuthorizationDecreaseRequested(\\n stakingProvider,\\n application,\\n authorization.authorized,\\n deauthorizingTo\\n );\\n IApplication(application).authorizationDecreaseRequested(\\n stakingProvider,\\n authorization.authorized,\\n deauthorizingTo\\n );\\n }\\n\\n /// @notice Returns minimum possible stake for T, KEEP or NU in T denomination\\n /// @dev For example, suppose the given staking provider has 10 T, 20 T worth\\n /// of KEEP, and 30 T worth of NU all staked, and the maximum\\n /// application authorization is 40 T, then `getMinStaked` for\\n /// that staking provider returns:\\n /// * 0 T if KEEP stake type specified i.e.\\n /// min = 40 T max - (10 T + 30 T worth of NU) = 0 T\\n /// * 10 T if NU stake type specified i.e.\\n /// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T\\n /// * 0 T if T stake type specified i.e.\\n /// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T\\n /// In other words, the minimum stake amount for the specified\\n /// stake type is the minimum amount of stake of the given type\\n /// needed to satisfy the maximum application authorization given\\n /// the staked amounts of the other stake types for that staking\\n /// provider.\\n function getMinStaked(address stakingProvider, StakeType stakeTypes)\\n public\\n view\\n override\\n returns (uint96)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint256 maxAuthorization = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address application = stakingProviderStruct.authorizedApplications[\\n i\\n ];\\n maxAuthorization = MathUpgradeable.max(\\n maxAuthorization,\\n stakingProviderStruct.authorizations[application].authorized\\n );\\n }\\n\\n if (maxAuthorization == 0) {\\n return 0;\\n }\\n if (stakeTypes != StakeType.T) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.tStake\\n );\\n }\\n if (stakeTypes != StakeType.NU) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.nuInTStake\\n );\\n }\\n if (stakeTypes != StakeType.KEEP) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.keepInTStake\\n );\\n }\\n return maxAuthorization.toUint96();\\n }\\n\\n /// @notice Returns available amount to authorize for the specified\\n /// application.\\n function getAvailableToAuthorize(\\n address stakingProvider,\\n address application\\n ) public view override returns (uint96 availableTValue) {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n availableTValue =\\n stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n availableTValue -= stakingProviderStruct\\n .authorizations[application]\\n .authorized;\\n }\\n\\n /// @notice Delegate voting power from the stake associated to the\\n /// `stakingProvider` to a `delegatee` address. Caller must be the owner\\n /// of this stake.\\n /// @dev Original abstract function defined in Checkpoints contract had two\\n /// parameters, `delegator` and `delegatee`. Here we override it and\\n /// comply with the same signature but the semantics of the first\\n /// parameter changes to the `stakingProvider` address.\\n function delegate(address stakingProvider, address delegatee)\\n internal\\n virtual\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n stakingProviderStruct.owner == msg.sender,\\n \\\"Caller is not owner\\\"\\n );\\n uint96 stakingProviderBalance = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n address oldDelegatee = delegates(stakingProvider);\\n _delegates[stakingProvider] = delegatee;\\n emit DelegateChanged(stakingProvider, oldDelegatee, delegatee);\\n moveVotingPower(oldDelegatee, delegatee, stakingProviderBalance);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each staking\\n /// provider from notifiers treasury. Can only be called by\\n /// application authorized for all staking providers in the array.\\n function notify(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) internal {\\n require(\\n amount > 0 && _stakingProviders.length > 0,\\n \\\"Parameters must be specified\\\"\\n );\\n\\n ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n uint256 queueLength = slashingQueue.length;\\n for (uint256 i = 0; i < _stakingProviders.length; i++) {\\n address stakingProvider = _stakingProviders[i];\\n uint256 amountToSlash = MathUpgradeable.min(\\n stakingProviders[stakingProvider]\\n .authorizations[msg.sender]\\n .authorized,\\n amount\\n );\\n if (\\n //slither-disable-next-line incorrect-equality\\n amountToSlash == 0\\n ) {\\n continue;\\n }\\n slashingQueue.push(\\n SlashingEvent(stakingProvider, amountToSlash.toUint96())\\n );\\n }\\n\\n if (notifier != address(0)) {\\n uint256 reward = ((slashingQueue.length - queueLength) *\\n notificationReward).percent(rewardMultiplier);\\n reward = MathUpgradeable.min(reward, notifiersTreasury);\\n emit NotifierRewarded(notifier, reward);\\n if (reward != 0) {\\n notifiersTreasury -= reward;\\n token.safeTransfer(notifier, reward);\\n }\\n }\\n }\\n\\n /// @notice Processes one specified slashing event.\\n /// Executes `involuntaryAuthorizationDecrease` function on each\\n /// affected application.\\n //slither-disable-next-line dead-code\\n function processSlashing(SlashingEvent storage slashing)\\n internal\\n returns (uint96 tAmountToBurn)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n slashing.stakingProvider\\n ];\\n uint96 tAmountToSlash = slashing.amount;\\n uint96 oldStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n // slash T\\n if (stakingProviderStruct.tStake > 0) {\\n if (tAmountToSlash <= stakingProviderStruct.tStake) {\\n tAmountToBurn = tAmountToSlash;\\n } else {\\n tAmountToBurn = stakingProviderStruct.tStake;\\n }\\n stakingProviderStruct.tStake -= tAmountToBurn;\\n tAmountToSlash -= tAmountToBurn;\\n }\\n\\n // slash KEEP\\n if (tAmountToSlash > 0 && stakingProviderStruct.keepInTStake > 0) {\\n (uint256 keepStakeAmount, , ) = keepStakingContract\\n .getDelegationInfo(slashing.stakingProvider);\\n (uint96 tAmount, ) = convertToT(keepStakeAmount, keepRatio);\\n stakingProviderStruct.keepInTStake = tAmount;\\n\\n tAmountToSlash = seizeKeep(\\n stakingProviderStruct,\\n slashing.stakingProvider,\\n tAmountToSlash,\\n 100\\n );\\n }\\n\\n // slash NU\\n if (tAmountToSlash > 0 && stakingProviderStruct.nuInTStake > 0) {\\n // synchronization skipped due to impossibility of real discrepancy\\n tAmountToSlash = seizeNu(\\n stakingProviderStruct,\\n tAmountToSlash,\\n 100\\n );\\n }\\n\\n uint96 slashedAmount = slashing.amount - tAmountToSlash;\\n emit TokensSeized(slashing.stakingProvider, slashedAmount, false);\\n authorizationDecrease(\\n slashing.stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n uint96 newStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n decreaseStakeCheckpoint(slashing.stakingProvider, oldStake - newStake);\\n }\\n\\n /// @notice Synchronize authorizations (if needed) after slashing stake\\n function authorizationDecrease(\\n address stakingProvider,\\n StakingProviderInfo storage stakingProviderStruct,\\n uint96 slashedAmount\\n ) internal {\\n uint96 totalStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.nuInTStake +\\n stakingProviderStruct.keepInTStake;\\n uint256 applicationsToDelete = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address authorizedApplication = stakingProviderStruct\\n .authorizedApplications[i];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[authorizedApplication];\\n uint96 fromAmount = authorization.authorized;\\n\\n authorization.authorized -= MathUpgradeable\\n .min(fromAmount, slashedAmount)\\n .toUint96();\\n\\n if (authorization.authorized > totalStake) {\\n authorization.authorized = totalStake;\\n }\\n\\n bool successful = true;\\n //slither-disable-next-line calls-loop\\n try\\n IApplication(authorizedApplication)\\n .involuntaryAuthorizationDecrease{\\n gas: GAS_LIMIT_AUTHORIZATION_DECREASE\\n }(stakingProvider, fromAmount, authorization.authorized)\\n {} catch {\\n successful = false;\\n }\\n if (authorization.deauthorizing > authorization.authorized) {\\n authorization.deauthorizing = authorization.authorized;\\n }\\n emit AuthorizationInvoluntaryDecreased(\\n stakingProvider,\\n authorizedApplication,\\n fromAmount,\\n authorization.authorized,\\n successful\\n );\\n if (authorization.authorized == 0) {\\n applicationsToDelete++;\\n }\\n }\\n if (applicationsToDelete > 0) {\\n cleanAuthorizedApplications(\\n stakingProviderStruct,\\n applicationsToDelete\\n );\\n }\\n }\\n\\n /// @notice Convert amount from T to Keep and call `seize` in Keep staking contract.\\n /// Returns remainder of slashing amount in T\\n /// @dev Note this internal function doesn't update stake checkpoints\\n function seizeKeep(\\n StakingProviderInfo storage stakingProviderStruct,\\n address stakingProvider,\\n uint96 tAmountToSlash,\\n uint256 rewardMultiplier\\n ) internal returns (uint96) {\\n if (stakingProviderStruct.keepInTStake == 0) {\\n return tAmountToSlash;\\n }\\n\\n uint96 tPenalty;\\n if (tAmountToSlash <= stakingProviderStruct.keepInTStake) {\\n tPenalty = tAmountToSlash;\\n } else {\\n tPenalty = stakingProviderStruct.keepInTStake;\\n }\\n\\n (uint256 keepPenalty, uint96 tRemainder) = convertFromT(\\n tPenalty,\\n keepRatio\\n );\\n if (keepPenalty == 0) {\\n return tAmountToSlash;\\n }\\n tPenalty -= tRemainder;\\n stakingProviderStruct.keepInTStake -= tPenalty;\\n tAmountToSlash -= tPenalty;\\n\\n address[] memory stakingProviderWrapper = new address[](1);\\n stakingProviderWrapper[0] = stakingProvider;\\n keepStakingContract.seize(\\n keepPenalty,\\n rewardMultiplier,\\n msg.sender,\\n stakingProviderWrapper\\n );\\n return tAmountToSlash;\\n }\\n\\n /// @notice Convert amount from T to NU and call `slashStaker` in NuCypher staking contract.\\n /// Returns remainder of slashing amount in T\\n /// @dev Note this internal function doesn't update the stake checkpoints\\n function seizeNu(\\n StakingProviderInfo storage stakingProviderStruct,\\n uint96 tAmountToSlash,\\n uint256 rewardMultiplier\\n ) internal returns (uint96) {\\n if (stakingProviderStruct.nuInTStake == 0) {\\n return tAmountToSlash;\\n }\\n\\n uint96 tPenalty;\\n if (tAmountToSlash <= stakingProviderStruct.nuInTStake) {\\n tPenalty = tAmountToSlash;\\n } else {\\n tPenalty = stakingProviderStruct.nuInTStake;\\n }\\n\\n (uint256 nuPenalty, uint96 tRemainder) = convertFromT(\\n tPenalty,\\n nucypherRatio\\n );\\n if (nuPenalty == 0) {\\n return tAmountToSlash;\\n }\\n tPenalty -= tRemainder;\\n stakingProviderStruct.nuInTStake -= tPenalty;\\n tAmountToSlash -= tPenalty;\\n\\n uint256 nuReward = nuPenalty.percent(SLASHING_REWARD_PERCENT).percent(\\n rewardMultiplier\\n );\\n nucypherStakingContract.slashStaker(\\n stakingProviderStruct.owner,\\n nuPenalty,\\n msg.sender,\\n nuReward\\n );\\n return tAmountToSlash;\\n }\\n\\n /// @notice Removes application with zero authorization from authorized\\n /// applications array\\n function cleanAuthorizedApplications(\\n StakingProviderInfo storage stakingProviderStruct,\\n uint256 numberToDelete\\n ) internal {\\n uint256 length = stakingProviderStruct.authorizedApplications.length;\\n if (numberToDelete == length) {\\n delete stakingProviderStruct.authorizedApplications;\\n return;\\n }\\n\\n uint256 deleted = 0;\\n uint256 index = 0;\\n uint256 newLength = length - numberToDelete;\\n while (index < newLength && deleted < numberToDelete) {\\n address application = stakingProviderStruct.authorizedApplications[\\n index\\n ];\\n if (\\n stakingProviderStruct.authorizations[application].authorized ==\\n 0\\n ) {\\n stakingProviderStruct.authorizedApplications[\\n index\\n ] = stakingProviderStruct.authorizedApplications[\\n length - deleted - 1\\n ];\\n deleted++;\\n } else {\\n index++;\\n }\\n }\\n\\n for (index = newLength; index < length; index++) {\\n stakingProviderStruct.authorizedApplications.pop();\\n }\\n }\\n\\n /// @notice Creates new checkpoints due to a change of stake amount\\n /// @param _delegator Address of the staking provider acting as delegator\\n /// @param _amount Amount of T to increment\\n /// @param increase True if the change is an increase, false if a decrease\\n function newStakeCheckpoint(\\n address _delegator,\\n uint96 _amount,\\n bool increase\\n ) internal {\\n if (_amount == 0) {\\n return;\\n }\\n writeCheckpoint(\\n _totalSupplyCheckpoints,\\n increase ? add : subtract,\\n _amount\\n );\\n address delegatee = delegates(_delegator);\\n if (delegatee != address(0)) {\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[delegatee],\\n increase ? add : subtract,\\n _amount\\n );\\n emit DelegateVotesChanged(delegatee, oldWeight, newWeight);\\n }\\n }\\n\\n /// @notice Creates new checkpoints due to an increment of a stakers' stake\\n /// @param _delegator Address of the staking provider acting as delegator\\n /// @param _amount Amount of T to increment\\n function increaseStakeCheckpoint(address _delegator, uint96 _amount)\\n internal\\n {\\n newStakeCheckpoint(_delegator, _amount, true);\\n }\\n\\n /// @notice Creates new checkpoints due to a decrease of a stakers' stake\\n /// @param _delegator Address of the stake owner acting as delegator\\n /// @param _amount Amount of T to decrease\\n function decreaseStakeCheckpoint(address _delegator, uint96 _amount)\\n internal\\n {\\n newStakeCheckpoint(_delegator, _amount, false);\\n }\\n\\n /// @notice Returns amount of Nu stake in the NuCypher staking contract for\\n /// the specified staking provider.\\n /// Resulting value in T denomination\\n function getNuAmountInT(address owner, address stakingProvider)\\n internal\\n returns (uint96)\\n {\\n uint256 nuStakeAmount = nucypherStakingContract.requestMerge(\\n owner,\\n stakingProvider\\n );\\n (uint96 tAmount, ) = convertToT(nuStakeAmount, nucypherRatio);\\n return tAmount;\\n }\\n\\n function _transferGovernance(address newGuvnor) internal virtual {\\n address oldGuvnor = governance;\\n governance = newGuvnor;\\n emit GovernanceTransferred(oldGuvnor, newGuvnor);\\n }\\n\\n /// @notice Returns amount of Keep stake in the Keep staking contract for\\n /// the specified staking provider.\\n /// Resulting value in T denomination\\n function getKeepAmountInT(address stakingProvider)\\n internal\\n view\\n returns (uint96)\\n {\\n uint256 keepStakeAmount = keepStakingContract.eligibleStake(\\n stakingProvider,\\n address(this)\\n );\\n (uint96 tAmount, ) = convertToT(keepStakeAmount, keepRatio);\\n return tAmount;\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` legacy\\n /// tokens for the given `ratio`, and the remainder that can't be\\n /// converted.\\n function convertToT(uint256 amount, uint256 ratio)\\n internal\\n pure\\n returns (uint96 tAmount, uint256 remainder)\\n {\\n remainder = amount % CONVERSION_DIVISOR;\\n uint256 convertibleAmount = amount - remainder;\\n tAmount = ((convertibleAmount * ratio) / CONVERSION_DIVISOR).toUint96();\\n }\\n\\n /// @notice Returns the amount of legacy tokens that's obtained from\\n /// `tAmount` T tokens for the given `ratio`, and the T remainder\\n /// that can't be converted.\\n function convertFromT(uint96 tAmount, uint256 ratio)\\n internal\\n pure\\n returns (uint256 amount, uint96 tRemainder)\\n {\\n //slither-disable-next-line weak-prng\\n tRemainder = (tAmount % ratio).toUint96();\\n uint256 convertibleAmount = tAmount - tRemainder;\\n amount = (convertibleAmount * CONVERSION_DIVISOR) / ratio;\\n }\\n}\\n\",\"keccak256\":\"0x4b311da20db9e2aac39ff93caa7235d738f9127b7260ced418fa4aa9cb456999\",\"license\":\"GPL-3.0-or-later\"},\"contracts/test/TokenStakingTestSet.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"../staking/ILegacyTokenStaking.sol\\\";\\nimport \\\"../staking/IApplication.sol\\\";\\nimport \\\"../staking/TokenStaking.sol\\\";\\n\\ncontract KeepTokenStakingMock is IKeepTokenStaking {\\n using PercentUtils for uint256;\\n\\n struct OperatorStruct {\\n address owner;\\n address payable beneficiary;\\n address authorizer;\\n uint256 createdAt;\\n uint256 undelegatedAt;\\n uint256 amount;\\n mapping(address => bool) eligibility;\\n }\\n\\n mapping(address => OperatorStruct) internal operators;\\n mapping(address => uint256) public tattletales;\\n\\n function setOperator(\\n address operator,\\n address owner,\\n address payable beneficiary,\\n address authorizer,\\n uint256 createdAt,\\n uint256 undelegatedAt,\\n uint256 amount\\n ) external {\\n OperatorStruct storage operatorStrut = operators[operator];\\n operatorStrut.owner = owner;\\n operatorStrut.beneficiary = beneficiary;\\n operatorStrut.authorizer = authorizer;\\n operatorStrut.createdAt = createdAt;\\n operatorStrut.undelegatedAt = undelegatedAt;\\n operatorStrut.amount = amount;\\n }\\n\\n function setEligibility(\\n address operator,\\n address application,\\n bool isEligible\\n ) external {\\n operators[operator].eligibility[application] = isEligible;\\n }\\n\\n function setAmount(address operator, uint256 amount) external {\\n operators[operator].amount = amount;\\n }\\n\\n function setUndelegatedAt(address operator, uint256 undelegatedAt)\\n external\\n {\\n operators[operator].undelegatedAt = undelegatedAt;\\n }\\n\\n function seize(\\n uint256 amountToSeize,\\n uint256 rewardMultiplier,\\n address tattletale,\\n address[] memory misbehavedOperators\\n ) external override {\\n require(amountToSeize > 0, \\\"Amount to slash must be greater than zero\\\");\\n // assumed only one will be slashed (per call)\\n require(\\n misbehavedOperators.length == 1,\\n \\\"Only one operator per call in tests\\\"\\n );\\n address operator = misbehavedOperators[0];\\n operators[operator].amount -= amountToSeize;\\n tattletales[tattletale] += amountToSeize.percent(5).percent(\\n rewardMultiplier\\n );\\n }\\n\\n function getDelegationInfo(address operator)\\n external\\n view\\n override\\n returns (\\n uint256 amount,\\n uint256 createdAt,\\n uint256 undelegatedAt\\n )\\n {\\n amount = operators[operator].amount;\\n createdAt = operators[operator].createdAt;\\n undelegatedAt = operators[operator].undelegatedAt;\\n }\\n\\n function ownerOf(address operator)\\n external\\n view\\n override\\n returns (address)\\n {\\n return operators[operator].owner;\\n }\\n\\n function beneficiaryOf(address operator)\\n external\\n view\\n override\\n returns (address payable)\\n {\\n return operators[operator].beneficiary;\\n }\\n\\n function authorizerOf(address operator)\\n external\\n view\\n override\\n returns (address)\\n {\\n return operators[operator].authorizer;\\n }\\n\\n function eligibleStake(address operator, address operatorContract)\\n external\\n view\\n override\\n returns (uint256 balance)\\n {\\n OperatorStruct storage operatorStrut = operators[operator];\\n if (operatorStrut.eligibility[operatorContract]) {\\n return operatorStrut.amount;\\n }\\n return 0;\\n }\\n}\\n\\ncontract NuCypherTokenStakingMock is INuCypherStakingEscrow {\\n struct StakerStruct {\\n uint256 value;\\n address stakingProvider;\\n }\\n\\n mapping(address => StakerStruct) public stakers;\\n mapping(address => uint256) public investigators;\\n\\n function setStaker(address staker, uint256 value) external {\\n stakers[staker].value = value;\\n }\\n\\n function slashStaker(\\n address staker,\\n uint256 penalty,\\n address investigator,\\n uint256 reward\\n ) external override {\\n require(penalty > 0, \\\"Amount to slash must be greater than zero\\\");\\n stakers[staker].value -= penalty;\\n investigators[investigator] += reward;\\n }\\n\\n function requestMerge(address staker, address stakingProvider)\\n external\\n override\\n returns (uint256)\\n {\\n StakerStruct storage stakerStruct = stakers[staker];\\n require(\\n stakerStruct.stakingProvider == address(0) ||\\n stakerStruct.stakingProvider == stakingProvider,\\n \\\"Another provider was already set for this staker\\\"\\n );\\n if (stakerStruct.stakingProvider == address(0)) {\\n stakerStruct.stakingProvider = stakingProvider;\\n }\\n return stakers[staker].value;\\n }\\n\\n function getAllTokens(address staker)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return stakers[staker].value;\\n }\\n\\n function stakerInfo(address staker)\\n public\\n view\\n returns (StakerStruct memory)\\n {\\n return stakers[staker];\\n }\\n}\\n\\ncontract VendingMachineMock {\\n uint256 public constant FLOATING_POINT_DIVISOR = 10**15;\\n\\n uint256 public immutable ratio;\\n\\n constructor(uint96 _wrappedTokenAllocation, uint96 _tTokenAllocation) {\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n}\\n\\ncontract ApplicationMock is IApplication {\\n struct StakingProviderStruct {\\n uint96 authorized;\\n uint96 deauthorizingTo;\\n }\\n\\n TokenStaking internal immutable tokenStaking;\\n mapping(address => StakingProviderStruct) public stakingProviders;\\n\\n constructor(TokenStaking _tokenStaking) {\\n tokenStaking = _tokenStaking;\\n }\\n\\n function withdrawRewards(address) external {\\n // does nothing\\n }\\n\\n function authorizationIncreased(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) external override {\\n stakingProviders[stakingProvider].authorized = toAmount;\\n }\\n\\n function authorizationDecreaseRequested(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) external override {\\n stakingProviders[stakingProvider].deauthorizingTo = toAmount;\\n }\\n\\n function approveAuthorizationDecrease(address stakingProvider) external {\\n StakingProviderStruct storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n stakingProviderStruct.authorized = tokenStaking\\n .approveAuthorizationDecrease(stakingProvider);\\n }\\n\\n function slash(uint96 amount, address[] memory _stakingProviders) external {\\n tokenStaking.slash(amount, _stakingProviders);\\n }\\n\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) external {\\n tokenStaking.seize(\\n amount,\\n rewardMultiplier,\\n notifier,\\n _stakingProviders\\n );\\n }\\n\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) public virtual override {\\n StakingProviderStruct storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n toAmount != stakingProviderStruct.authorized,\\n \\\"Nothing to decrease\\\"\\n );\\n uint96 decrease = stakingProviderStruct.authorized - toAmount;\\n if (stakingProviderStruct.deauthorizingTo > decrease) {\\n stakingProviderStruct.deauthorizingTo -= decrease;\\n } else {\\n stakingProviderStruct.deauthorizingTo = 0;\\n }\\n stakingProviderStruct.authorized = toAmount;\\n }\\n\\n function availableRewards(address) external pure returns (uint96) {\\n return 0;\\n }\\n\\n function minimumAuthorization() external pure returns (uint96) {\\n return 0;\\n }\\n}\\n\\ncontract BrokenApplicationMock is ApplicationMock {\\n constructor(TokenStaking _tokenStaking) ApplicationMock(_tokenStaking) {}\\n\\n function involuntaryAuthorizationDecrease(\\n address,\\n uint96,\\n uint96\\n ) public pure override {\\n revert(\\\"Broken application\\\");\\n }\\n}\\n\\ncontract ExpensiveApplicationMock is ApplicationMock {\\n uint256[] private dummy;\\n\\n constructor(TokenStaking _tokenStaking) ApplicationMock(_tokenStaking) {}\\n\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) public override {\\n super.involuntaryAuthorizationDecrease(\\n stakingProvider,\\n fromAmount,\\n toAmount\\n );\\n for (uint256 i = 0; i < 12; i++) {\\n dummy.push(i);\\n }\\n }\\n}\\n\\ncontract ManagedGrantMock {\\n address public grantee;\\n\\n //slither-disable-next-line missing-zero-check\\n function setGrantee(address _grantee) external {\\n grantee = _grantee;\\n }\\n}\\n\\ncontract ExtendedTokenStaking is TokenStaking {\\n constructor(\\n T _token,\\n IKeepTokenStaking _keepStakingContract,\\n INuCypherStakingEscrow _nucypherStakingContract,\\n VendingMachine _keepVendingMachine,\\n VendingMachine _nucypherVendingMachine,\\n KeepStake _keepStake\\n )\\n TokenStaking(\\n _token,\\n _keepStakingContract,\\n _nucypherStakingContract,\\n _keepVendingMachine,\\n _nucypherVendingMachine,\\n _keepStake\\n )\\n {}\\n\\n function cleanAuthorizedApplications(\\n address stakingProvider,\\n uint256 numberToDelete\\n ) external {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n cleanAuthorizedApplications(stakingProviderStruct, numberToDelete);\\n }\\n\\n function setAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external {\\n stakingProviders[stakingProvider]\\n .authorizations[application]\\n .authorized = amount;\\n }\\n\\n function setAuthorizedApplications(\\n address stakingProvider,\\n address[] memory _applications\\n ) external {\\n stakingProviders[stakingProvider]\\n .authorizedApplications = _applications;\\n }\\n\\n // to decrease size of test contract\\n function processSlashing(uint256 count) external override {}\\n\\n function getAuthorizedApplications(address stakingProvider)\\n external\\n view\\n returns (address[] memory)\\n {\\n return stakingProviders[stakingProvider].authorizedApplications;\\n }\\n}\\n\",\"keccak256\":\"0x55bd1a8dc0c354ff3be00489028bd31f95fbf8c75a2c28a41f1b2466a7f955be\",\"license\":\"GPL-3.0-or-later\"},\"contracts/token/T.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 \\\"../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\",\"keccak256\":\"0x6265416225fd15b1108fce13d570b53a862a5d256ba2e6329bccf658eccac430\",\"license\":\"GPL-3.0-or-later\"},\"contracts/utils/PercentUtils.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\\nlibrary PercentUtils {\\n // Return `b`% of `a`\\n // 200.percent(40) == 80\\n // Commutative, works both ways\\n function percent(uint256 a, uint256 b) internal pure returns (uint256) {\\n return (a * b) / 100;\\n }\\n\\n // Return `a` as percentage of `b`:\\n // 80.asPercentOf(200) == 40\\n //slither-disable-next-line dead-code\\n function asPercentOf(uint256 a, uint256 b) internal pure returns (uint256) {\\n return (a * 100) / b;\\n }\\n}\\n\",\"keccak256\":\"0xf5feadeff9d504b33058dfd6c2b99d31ecebc152b356272646a7afe6ed638d40\",\"license\":\"GPL-3.0-or-later\"},\"contracts/utils/SafeTUpgradeable.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 \\\"../token/T.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\n/// @notice A wrapper around OpenZeppelin's `SafeERC20Upgradeable` but specific\\n/// to the T token. Use this library in upgradeable contracts. If your\\n/// contract is non-upgradeable, then the traditional `SafeERC20` works.\\n/// The motivation is to prevent upgradeable contracts that use T from\\n/// depending on the `Address` library, which can be problematic since\\n/// it uses `delegatecall`, which is discouraged by OpenZeppelin for use\\n/// in upgradeable contracts.\\n/// @dev This implementation force-casts T to `IERC20Upgradeable` to make it\\n/// work with `SafeERC20Upgradeable`.\\nlibrary SafeTUpgradeable {\\n function safeTransfer(\\n T token,\\n address to,\\n uint256 value\\n ) internal {\\n SafeERC20Upgradeable.safeTransfer(\\n IERC20Upgradeable(address(token)),\\n to,\\n value\\n );\\n }\\n\\n function safeTransferFrom(\\n T token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n SafeERC20Upgradeable.safeTransferFrom(\\n IERC20Upgradeable(address(token)),\\n from,\\n to,\\n value\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf53907099650f9f973ff51c403730e7ae7170a5728fbde49f0f00b0a17775ce7\",\"license\":\"GPL-3.0-or-later\"},\"contracts/vending/VendingMachine.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 \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\nimport \\\"../token/T.sol\\\";\\n\\n/// @title T token vending machine\\n/// @notice Contract implements a special update protocol to enable KEEP/NU\\n/// token holders to wrap their tokens and obtain T tokens according\\n/// to a fixed ratio. This will go on indefinitely and enable NU and\\n/// KEEP token holders to join T network without needing to buy or\\n/// sell any assets. Logistically, anyone holding NU or KEEP can wrap\\n/// those assets in order to upgrade to T. They can also unwrap T in\\n/// order to downgrade back to the underlying asset. There is a separate\\n/// instance of this contract deployed for KEEP holders and a separate\\n/// instance of this contract deployed for NU holders.\\ncontract VendingMachine is IReceiveApproval {\\n using SafeERC20 for IERC20;\\n using SafeERC20 for T;\\n\\n /// @notice Number of decimal places of precision in conversion to/from\\n /// wrapped tokens (assuming typical ERC20 token with 18 decimals).\\n /// This implies that amounts of wrapped tokens below this precision\\n /// won't take part in the conversion. E.g., for a value of 3, then\\n /// for a conversion of 1.123456789 wrapped tokens, only 1.123 is\\n /// convertible (i.e., 3 decimal places), and 0.000456789 is left.\\n uint256 public constant WRAPPED_TOKEN_CONVERSION_PRECISION = 3;\\n\\n /// @notice Divisor for precision purposes, used to represent fractions.\\n uint256 public constant FLOATING_POINT_DIVISOR =\\n 10**(18 - WRAPPED_TOKEN_CONVERSION_PRECISION);\\n\\n /// @notice The token being wrapped to T (KEEP/NU).\\n IERC20 public immutable wrappedToken;\\n\\n /// @notice T token contract.\\n T public immutable tToken;\\n\\n /// @notice The ratio with which T token is converted based on the provided\\n /// token being wrapped (KEEP/NU), expressed in 1e18 precision.\\n ///\\n /// When wrapping:\\n /// x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR\\n ///\\n /// When unwrapping:\\n /// x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\\n uint256 public immutable ratio;\\n\\n /// @notice The total balance of wrapped tokens for the given holder\\n /// account. Only holders that have previously wrapped KEEP/NU to T\\n /// can unwrap, up to the amount previously wrapped.\\n mapping(address => uint256) public wrappedBalance;\\n\\n event Wrapped(\\n address indexed recipient,\\n uint256 wrappedTokenAmount,\\n uint256 tTokenAmount\\n );\\n event Unwrapped(\\n address indexed recipient,\\n uint256 tTokenAmount,\\n uint256 wrappedTokenAmount\\n );\\n\\n /// @notice Sets the reference to `wrappedToken` and `tToken`. Initializes\\n /// conversion `ratio` between wrapped token and T based on the\\n /// provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\\n /// @param _wrappedToken Address to ERC20 token that will be wrapped to T\\n /// @param _tToken Address of T token\\n /// @param _wrappedTokenAllocation The total supply of the token that will be\\n /// wrapped to T\\n /// @param _tTokenAllocation The allocation of T this instance of Vending\\n /// Machine will receive\\n /// @dev Multiplications in this contract can't overflow uint256 as we\\n /// restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to\\n /// 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\\n constructor(\\n IERC20 _wrappedToken,\\n T _tToken,\\n uint96 _wrappedTokenAllocation,\\n uint96 _tTokenAllocation\\n ) {\\n wrappedToken = _wrappedToken;\\n tToken = _tToken;\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n\\n /// @notice Wraps up to the the given `amount` of the token (KEEP/NU) and\\n /// releases T token proportionally to the amount being wrapped with\\n /// respect to the wrap ratio. The token holder needs to have at\\n /// least the given amount of the wrapped token (KEEP/NU) approved\\n /// to transfer to the Vending Machine before calling this function.\\n /// @param amount The amount of KEEP/NU to be wrapped\\n function wrap(uint256 amount) external {\\n _wrap(msg.sender, amount);\\n }\\n\\n /// @notice Wraps up to the given amount of the token (KEEP/NU) and releases\\n /// T token proportionally to the amount being wrapped with respect\\n /// to the wrap ratio. This is a shortcut to `wrap` function that\\n /// avoids a separate approval transaction. Only KEEP/NU token\\n /// is allowed as a caller, so please call this function via\\n /// token's `approveAndCall`.\\n /// @param from Caller's address, must be the same as `wrappedToken` field\\n /// @param amount The amount of KEEP/NU to be wrapped\\n /// @param token Token's address, must be the same as `wrappedToken` field\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(\\n token == address(wrappedToken),\\n \\\"Token is not the wrapped token\\\"\\n );\\n require(\\n msg.sender == address(wrappedToken),\\n \\\"Only wrapped token caller allowed\\\"\\n );\\n _wrap(from, amount);\\n }\\n\\n /// @notice Unwraps up to the given `amount` of T back to the legacy token\\n /// (KEEP/NU) according to the wrap ratio. It can only be called by\\n /// a token holder who previously wrapped their tokens in this\\n /// vending machine contract. The token holder can't unwrap more\\n /// tokens than they originally wrapped. The token holder needs to\\n /// have at least the given amount of T tokens approved to transfer\\n /// to the Vending Machine before calling this function.\\n /// @param amount The amount of T to unwrap back to the collateral (KEEP/NU)\\n function unwrap(uint256 amount) external {\\n _unwrap(msg.sender, amount);\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` wrapped\\n /// tokens (KEEP/NU), and the remainder that can't be upgraded.\\n function conversionToT(uint256 amount)\\n public\\n view\\n returns (uint256 tAmount, uint256 wrappedRemainder)\\n {\\n wrappedRemainder = amount % FLOATING_POINT_DIVISOR;\\n uint256 convertibleAmount = amount - wrappedRemainder;\\n tAmount = (convertibleAmount * ratio) / FLOATING_POINT_DIVISOR;\\n }\\n\\n /// @notice The amount of wrapped tokens (KEEP/NU) that's obtained from\\n /// `amount` T tokens, and the remainder that can't be downgraded.\\n function conversionFromT(uint256 amount)\\n public\\n view\\n returns (uint256 wrappedAmount, uint256 tRemainder)\\n {\\n tRemainder = amount % ratio;\\n uint256 convertibleAmount = amount - tRemainder;\\n wrappedAmount = (convertibleAmount * FLOATING_POINT_DIVISOR) / ratio;\\n }\\n\\n function _wrap(address tokenHolder, uint256 wrappedTokenAmount) internal {\\n (uint256 tTokenAmount, uint256 remainder) = conversionToT(\\n wrappedTokenAmount\\n );\\n wrappedTokenAmount -= remainder;\\n require(wrappedTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n emit Wrapped(tokenHolder, wrappedTokenAmount, tTokenAmount);\\n\\n wrappedBalance[tokenHolder] += wrappedTokenAmount;\\n wrappedToken.safeTransferFrom(\\n tokenHolder,\\n address(this),\\n wrappedTokenAmount\\n );\\n tToken.safeTransfer(tokenHolder, tTokenAmount);\\n }\\n\\n function _unwrap(address tokenHolder, uint256 tTokenAmount) internal {\\n (uint256 wrappedTokenAmount, uint256 remainder) = conversionFromT(\\n tTokenAmount\\n );\\n tTokenAmount -= remainder;\\n require(tTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n require(\\n wrappedBalance[tokenHolder] >= wrappedTokenAmount,\\n \\\"Can not unwrap more than previously wrapped\\\"\\n );\\n\\n emit Unwrapped(tokenHolder, tTokenAmount, wrappedTokenAmount);\\n wrappedBalance[tokenHolder] -= wrappedTokenAmount;\\n tToken.safeTransferFrom(tokenHolder, address(this), tTokenAmount);\\n wrappedToken.safeTransfer(tokenHolder, wrappedTokenAmount);\\n }\\n}\\n\",\"keccak256\":\"0xa4e7de5a9063db09b32ca97fa0fb5d8d1cc7b539387d1b44d74d15d3c2ed4134\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b506104f7806100206000396000f3fe608060405234801561001057600080fd5b506004361061006d5760003560e01c8063178b6de6146100725780633223ff4b146100ae5780633d4fa8e5146100c15780634e745f1f146100ed5780637da5f6a6146101655780639168ae721461018557806399cc218c146101d2575b600080fd5b61009b6100803660046103b9565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61009b6100bc3660046103db565b6101e5565b6100eb6100cf36600461040e565b6001600160a01b03909116600090815260208190526040902055565b005b6101416100fb3660046103b9565b604080518082018252600080825260209182018190526001600160a01b039384168152808252829020825180840190935280548352600101549092169181019190915290565b60408051825181526020928301516001600160a01b031692810192909252016100a5565b61009b6101733660046103b9565b60016020526000908152604090205481565b6101b56101933660046103b9565b600060208190529081526040902080546001909101546001600160a01b031682565b604080519283526001600160a01b039091166020830152016100a5565b6100eb6101e0366004610438565b6102db565b6001600160a01b038083166000908152602081905260408120600181015491929091161580610223575060018101546001600160a01b038481169116145b61028d5760405162461bcd60e51b815260206004820152603060248201527f416e6f746865722070726f76696465722077617320616c72656164792073657460448201526f103337b9103a3434b99039ba30b5b2b960811b60648201526084015b60405180910390fd5b60018101546001600160a01b03166102bd576001810180546001600160a01b0319166001600160a01b0385161790555b5050506001600160a01b031660009081526020819052604090205490565b6000831161033d5760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f20736c617368206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610284565b6001600160a01b03841660009081526020819052604081208054859290610365908490610492565b90915550506001600160a01b038216600090815260016020526040812080548392906103929084906104a9565b909155505050505050565b80356001600160a01b03811681146103b457600080fd5b919050565b6000602082840312156103cb57600080fd5b6103d48261039d565b9392505050565b600080604083850312156103ee57600080fd5b6103f78361039d565b91506104056020840161039d565b90509250929050565b6000806040838503121561042157600080fd5b61042a8361039d565b946020939093013593505050565b6000806000806080858703121561044e57600080fd5b6104578561039d565b93506020850135925061046c6040860161039d565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b6000828210156104a4576104a461047c565b500390565b600082198211156104bc576104bc61047c565b50019056fea264697066735822122041f9efcb70963e42e9921a07e6437e62f0026326ab10afe85c9a10ed397fac0364736f6c63430008090033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061006d5760003560e01c8063178b6de6146100725780633223ff4b146100ae5780633d4fa8e5146100c15780634e745f1f146100ed5780637da5f6a6146101655780639168ae721461018557806399cc218c146101d2575b600080fd5b61009b6100803660046103b9565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61009b6100bc3660046103db565b6101e5565b6100eb6100cf36600461040e565b6001600160a01b03909116600090815260208190526040902055565b005b6101416100fb3660046103b9565b604080518082018252600080825260209182018190526001600160a01b039384168152808252829020825180840190935280548352600101549092169181019190915290565b60408051825181526020928301516001600160a01b031692810192909252016100a5565b61009b6101733660046103b9565b60016020526000908152604090205481565b6101b56101933660046103b9565b600060208190529081526040902080546001909101546001600160a01b031682565b604080519283526001600160a01b039091166020830152016100a5565b6100eb6101e0366004610438565b6102db565b6001600160a01b038083166000908152602081905260408120600181015491929091161580610223575060018101546001600160a01b038481169116145b61028d5760405162461bcd60e51b815260206004820152603060248201527f416e6f746865722070726f76696465722077617320616c72656164792073657460448201526f103337b9103a3434b99039ba30b5b2b960811b60648201526084015b60405180910390fd5b60018101546001600160a01b03166102bd576001810180546001600160a01b0319166001600160a01b0385161790555b5050506001600160a01b031660009081526020819052604090205490565b6000831161033d5760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f20736c617368206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610284565b6001600160a01b03841660009081526020819052604081208054859290610365908490610492565b90915550506001600160a01b038216600090815260016020526040812080548392906103929084906104a9565b909155505050505050565b80356001600160a01b03811681146103b457600080fd5b919050565b6000602082840312156103cb57600080fd5b6103d48261039d565b9392505050565b600080604083850312156103ee57600080fd5b6103f78361039d565b91506104056020840161039d565b90509250929050565b6000806040838503121561042157600080fd5b61042a8361039d565b946020939093013593505050565b6000806000806080858703121561044e57600080fd5b6104578561039d565b93506020850135925061046c6040860161039d565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b6000828210156104a4576104a461047c565b500390565b600082198211156104bc576104bc61047c565b50019056fea264697066735822122041f9efcb70963e42e9921a07e6437e62f0026326ab10afe85c9a10ed397fac0364736f6c63430008090033", + "solcInputHash": "8933389a43c675e66679c9f606d83ebd", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"getAllTokens\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"investigators\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"requestMerge\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setStaker\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"penalty\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"investigator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"slashStaker\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"stakerInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"internalType\":\"struct NuCypherTokenStakingMock.StakerStruct\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"stakers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"slashStaker(address,uint256,address,uint256)\":{\"params\":{\"investigator\":\"Investigator\",\"penalty\":\"Penalty\",\"reward\":\"Reward for the investigator\",\"staker\":\"Staker's address\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getAllTokens(address)\":{\"notice\":\"Get all tokens belonging to the staker\"},\"requestMerge(address,address)\":{\"notice\":\"Request merge between NuCypher staking contract and T staking contract. Returns amount of staked tokens\"},\"slashStaker(address,uint256,address,uint256)\":{\"notice\":\"Slash the staker's stake and reward the investigator\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/TokenStakingTestSet.sol\":\"NuCypherTokenStakingMock\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() initializer {}\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\\n // contract may have been reentered.\\n require(_initializing ? _isConstructor() : !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} modifier, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n function _isConstructor() private view returns (bool) {\\n return !AddressUpgradeable.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x372b0bc04e3b4c074559bbbfb1317afddb56de5504158ca25a7f9cd403980445\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev 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 /**\\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\",\"keccak256\":\"0x6777f3fccb5dab95a9088ef62c41bee0198fd92e50d7c94f0e3733788af4079e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3e26a49d2fa5ef8338b8a9467c91e54f417cb07e849b1cc0f4ebc4d2a147938e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x55cf2bd9fc76704ddcdc19834cd288b7de00fc0f298a40ea16a954ae8991db2d\",\"license\":\"MIT\"},\"@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 v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.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 /**\\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\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\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 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 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 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 /**\\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\",\"keccak256\":\"0x516a22876c1fab47f49b1bc22b4614491cd05338af8bd2e7b382da090a079990\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.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 SafeCast {\\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\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"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\"},\"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/staking/IApplication.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\\n/// @title Application interface for Threshold Network applications\\n/// @notice Generic interface for an application. Application is an external\\n/// smart contract or a set of smart contracts utilizing functionalities\\n/// offered by Threshold Network. Applications authorized for the given\\n/// staking provider are eligible to slash the stake delegated to that\\n/// staking provider.\\ninterface IApplication {\\n /// @dev Event emitted by `withdrawRewards` function.\\n event RewardsWithdrawn(address indexed stakingProvider, uint96 amount);\\n\\n /// @notice Withdraws application rewards for the given staking provider.\\n /// Rewards are withdrawn to the staking provider's beneficiary\\n /// address set in the staking contract.\\n /// @dev Emits `RewardsWithdrawn` event.\\n function withdrawRewards(address stakingProvider) external;\\n\\n /// @notice Used by T staking contract to inform the application that the\\n /// authorized amount for the given staking provider increased.\\n /// The application may do any necessary housekeeping. The\\n /// application must revert the transaction in case the\\n /// authorization is below the minimum required.\\n function authorizationIncreased(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Used by T staking contract to inform the application that the\\n /// authorization decrease for the given staking provider has been\\n /// requested. The application should mark the authorization as\\n /// pending decrease and respond to the staking contract with\\n /// `approveAuthorizationDecrease` at its discretion. It may\\n /// happen right away but it also may happen several months later.\\n /// If there is already a pending authorization decrease request\\n /// for the application, and the application does not agree for\\n /// overwriting it, the function should revert.\\n function authorizationDecreaseRequested(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Used by T staking contract to inform the application the\\n /// authorization has been decreased for the given staking provider\\n /// involuntarily, as a result of slashing. Lets the application to\\n /// do any housekeeping neccessary. Called with 250k gas limit and\\n /// does not revert the transaction if\\n /// `involuntaryAuthorizationDecrease` call failed.\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Returns the amount of application rewards available for\\n /// withdrawal for the given staking provider.\\n function availableRewards(address stakingProvider)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice The minimum authorization amount required for the staking\\n /// provider so that they can participate in the application.\\n function minimumAuthorization() external view returns (uint96);\\n}\\n\",\"keccak256\":\"0x43d707dccc548bf48ad316d9652450cb297203234d251132cdc6b97508eb44c5\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/ILegacyTokenStaking.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\\n/// @title IKeepTokenStaking\\n/// @notice Interface for Keep TokenStaking contract\\ninterface IKeepTokenStaking {\\n /// @notice Seize provided token amount from every member in the misbehaved\\n /// operators array. The tattletale is rewarded with 5% of the total seized\\n /// amount scaled by the reward adjustment parameter and the rest 95% is burned.\\n /// @param amountToSeize Token amount to seize from every misbehaved operator.\\n /// @param rewardMultiplier Reward adjustment in percentage. Min 1% and 100% max.\\n /// @param tattletale Address to receive the 5% reward.\\n /// @param misbehavedOperators Array of addresses to seize the tokens from.\\n function seize(\\n uint256 amountToSeize,\\n uint256 rewardMultiplier,\\n address tattletale,\\n address[] memory misbehavedOperators\\n ) external;\\n\\n /// @notice Gets stake delegation info for the given operator.\\n /// @param operator Operator address.\\n /// @return amount The amount of tokens the given operator delegated.\\n /// @return createdAt The time when the stake has been delegated.\\n /// @return undelegatedAt The time when undelegation has been requested.\\n /// If undelegation has not been requested, 0 is returned.\\n function getDelegationInfo(address operator)\\n external\\n view\\n returns (\\n uint256 amount,\\n uint256 createdAt,\\n uint256 undelegatedAt\\n );\\n\\n /// @notice Gets the stake owner for the specified operator address.\\n /// @return Stake owner address.\\n function ownerOf(address operator) external view returns (address);\\n\\n /// @notice Gets the beneficiary for the specified operator address.\\n /// @return Beneficiary address.\\n function beneficiaryOf(address operator)\\n external\\n view\\n returns (address payable);\\n\\n /// @notice Gets the authorizer for the specified operator address.\\n /// @return Authorizer address.\\n function authorizerOf(address operator) external view returns (address);\\n\\n /// @notice Gets the eligible stake balance of the specified address.\\n /// An eligible stake is a stake that passed the initialization period\\n /// and is not currently undelegating. Also, the operator had to approve\\n /// the specified operator contract.\\n ///\\n /// Operator with a minimum required amount of eligible stake can join the\\n /// network and participate in new work selection.\\n ///\\n /// @param operator address of stake operator.\\n /// @param operatorContract address of operator contract.\\n /// @return balance an uint256 representing the eligible stake balance.\\n function eligibleStake(address operator, address operatorContract)\\n external\\n view\\n returns (uint256 balance);\\n}\\n\\n/// @title INuCypherStakingEscrow\\n/// @notice Interface for NuCypher StakingEscrow contract\\ninterface INuCypherStakingEscrow {\\n /// @notice Slash the staker's stake and reward the investigator\\n /// @param staker Staker's address\\n /// @param penalty Penalty\\n /// @param investigator Investigator\\n /// @param reward Reward for the investigator\\n function slashStaker(\\n address staker,\\n uint256 penalty,\\n address investigator,\\n uint256 reward\\n ) external;\\n\\n /// @notice Request merge between NuCypher staking contract and T staking contract.\\n /// Returns amount of staked tokens\\n function requestMerge(address staker, address stakingProvider)\\n external\\n returns (uint256);\\n\\n /// @notice Get all tokens belonging to the staker\\n function getAllTokens(address staker) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x807d42d248e94c1f2269c7aa27031302a1225525e1405010424dd91adcc092ab\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/IStaking.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\\n/// @title Interface of Threshold Network staking contract\\n/// @notice The staking contract enables T owners to have their wallets offline\\n/// and their stake managed by staking providers on their behalf.\\n/// The staking contract does not define operator role. The operator\\n/// responsible for running off-chain client software is appointed by\\n/// the staking provider in the particular application utilizing the\\n/// staking contract. All off-chain client software should be able\\n/// to run without exposing operator's or staking provider\\u2019s private\\n/// key and should not require any owner\\u2019s keys at all. The stake\\n/// delegation optimizes the network throughput without compromising the\\n/// security of the owners\\u2019 stake.\\ninterface IStaking {\\n enum StakeType {\\n NU,\\n KEEP,\\n T\\n }\\n\\n //\\n //\\n // Delegating a stake\\n //\\n //\\n\\n /// @notice Creates a delegation with `msg.sender` owner with the given\\n /// staking provider, beneficiary, and authorizer. Transfers the\\n /// given amount of T to the staking contract.\\n /// @dev The owner of the delegation needs to have the amount approved to\\n /// transfer to the staking contract.\\n function stake(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer,\\n uint96 amount\\n ) external;\\n\\n /// @notice Copies delegation from the legacy KEEP staking contract to T\\n /// staking contract. No tokens are transferred. Caches the active\\n /// stake amount from KEEP staking contract. Can be called by\\n /// anyone.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function stakeKeep(address stakingProvider) external;\\n\\n /// @notice Copies delegation from the legacy NU staking contract to T\\n /// staking contract, additionally appointing staking provider,\\n /// beneficiary and authorizer roles. Caches the amount staked in NU\\n /// staking contract. Can be called only by the original delegation\\n /// owner.\\n function stakeNu(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer\\n ) external;\\n\\n /// @notice Allows the Governance to set the minimum required stake amount.\\n /// This amount is required to protect against griefing the staking\\n /// contract and individual applications are allowed to require\\n /// higher minimum stakes if necessary.\\n function setMinimumStakeAmount(uint96 amount) external;\\n\\n //\\n //\\n // Authorizing an application\\n //\\n //\\n\\n /// @notice Allows the Governance to approve the particular application\\n /// before individual stake authorizers are able to authorize it.\\n function approveApplication(address application) external;\\n\\n /// @notice Increases the authorization of the given staking provider for\\n /// the given application by the given amount. Can only be called by\\n /// the authorizer for that staking provider.\\n /// @dev Calls `authorizationIncreased(address stakingProvider, uint256 amount)`\\n /// on the given application to notify the application about\\n /// authorization change. See `IApplication`.\\n function increaseAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external;\\n\\n /// @notice Requests decrease of the authorization for the given staking\\n /// provider on the given application by the provided amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application if the application agrees for that. If the\\n /// application does not agree for overwriting, the function\\n /// reverts.\\n /// @dev Calls `authorizationDecreaseRequested(address stakingProvider, uint256 amount)`\\n /// on the given application. See `IApplication`.\\n function requestAuthorizationDecrease(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external;\\n\\n /// @notice Requests decrease of all authorizations for the given staking\\n /// provider on all applications by all authorized amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application.\\n /// @dev Calls `authorizationDecreaseRequested(address stakingProvider, uint256 amount)`\\n /// for each authorized application. See `IApplication`.\\n function requestAuthorizationDecrease(address stakingProvider) external;\\n\\n /// @notice Called by the application at its discretion to approve the\\n /// previously requested authorization decrease request. Can only be\\n /// called by the application that was previously requested to\\n /// decrease the authorization for that staking provider.\\n /// Returns resulting authorized amount for the application.\\n function approveAuthorizationDecrease(address stakingProvider)\\n external\\n returns (uint96);\\n\\n /// @notice Decreases the authorization for the given `stakingProvider` on\\n /// the given disabled `application`, for all authorized amount.\\n /// Can be called by anyone.\\n function forceDecreaseAuthorization(\\n address stakingProvider,\\n address application\\n ) external;\\n\\n /// @notice Pauses the given application\\u2019s eligibility to slash stakes.\\n /// Besides that stakers can't change authorization to the application.\\n /// Can be called only by the Panic Button of the particular\\n /// application. The paused application can not slash stakes until\\n /// it is approved again by the Governance using `approveApplication`\\n /// function. Should be used only in case of an emergency.\\n function pauseApplication(address application) external;\\n\\n /// @notice Disables the given application. The disabled application can't\\n /// slash stakers. Also stakers can't increase authorization to that\\n /// application but can decrease without waiting by calling\\n /// `requestAuthorizationDecrease` at any moment. Can be called only\\n /// by the governance. The disabled application can't be approved\\n /// again. Should be used only in case of an emergency.\\n function disableApplication(address application) external;\\n\\n /// @notice Sets the Panic Button role for the given application to the\\n /// provided address. Can only be called by the Governance. If the\\n /// Panic Button for the given application should be disabled, the\\n /// role address should be set to 0x0 address.\\n function setPanicButton(address application, address panicButton) external;\\n\\n /// @notice Sets the maximum number of applications one staking provider can\\n /// have authorized. Used to protect against DoSing slashing queue.\\n /// Can only be called by the Governance.\\n function setAuthorizationCeiling(uint256 ceiling) external;\\n\\n //\\n //\\n // Stake top-up\\n //\\n //\\n\\n /// @notice Increases the amount of the stake for the given staking provider.\\n /// @dev The sender of this transaction needs to have the amount approved to\\n /// transfer to the staking contract.\\n function topUp(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Propagates information about stake top-up from the legacy KEEP\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpKeep(address stakingProvider) external;\\n\\n /// @notice Propagates information about stake top-up from the legacy NU\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpNu(address stakingProvider) external;\\n\\n //\\n //\\n // Undelegating a stake (unstaking)\\n //\\n //\\n\\n /// @notice Reduces the liquid T stake amount by the provided amount and\\n /// withdraws T to the owner. Reverts if there is at least one\\n /// authorization higher than the sum of the legacy stake and\\n /// remaining liquid T stake or if the unstake amount is higher than\\n /// the liquid T stake amount. Can be called only by the delegation\\n /// owner or the staking provider.\\n function unstakeT(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Sets the legacy KEEP staking contract active stake amount cached\\n /// in T staking contract to 0. Reverts if the amount of liquid T\\n /// staked in T staking contract is lower than the highest\\n /// application authorization. This function allows to unstake from\\n /// KEEP staking contract and still being able to operate in T\\n /// network and earning rewards based on the liquid T staked. Can be\\n /// called only by the delegation owner or the staking provider.\\n function unstakeKeep(address stakingProvider) external;\\n\\n /// @notice Reduces cached legacy NU stake amount by the provided amount.\\n /// Reverts if there is at least one authorization higher than the\\n /// sum of remaining legacy NU stake and liquid T stake for that\\n /// staking provider or if the untaked amount is higher than the\\n /// cached legacy stake amount. If succeeded, the legacy NU stake\\n /// can be partially or fully undelegated on the legacy staking\\n /// contract. This function allows to unstake from NU staking\\n /// contract and still being able to operate in T network and\\n /// earning rewards based on the liquid T staked. Can be called only\\n /// by the delegation owner or the staking provider.\\n function unstakeNu(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Sets cached legacy stake amount to 0, sets the liquid T stake\\n /// amount to 0 and withdraws all liquid T from the stake to the\\n /// owner. Reverts if there is at least one non-zero authorization.\\n /// Can be called only by the delegation owner or the staking\\n /// provider.\\n function unstakeAll(address stakingProvider) external;\\n\\n //\\n //\\n // Keeping information in sync\\n //\\n //\\n\\n /// @notice Notifies about the discrepancy between legacy KEEP active stake\\n /// and the amount cached in T staking contract. Slashes the staking\\n /// provider in case the amount cached is higher than the actual\\n /// active stake amount in KEEP staking contract. Needs to update\\n /// authorizations of all affected applications and execute an\\n /// involuntary allocation decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyKeepStakeDiscrepancy(address stakingProvider) external;\\n\\n /// @notice Notifies about the discrepancy between legacy NU active stake\\n /// and the amount cached in T staking contract. Slashes the\\n /// staking provider in case the amount cached is higher than the\\n /// actual active stake amount in NU staking contract. Needs to\\n /// update authorizations of all affected applications and execute\\n /// an involuntary allocation decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyNuStakeDiscrepancy(address stakingProvider) external;\\n\\n /// @notice Sets the penalty amount for stake discrepancy and reward\\n /// multiplier for reporting it. The penalty is seized from the\\n /// delegated stake, and 5% of the penalty, scaled by the\\n /// multiplier, is given to the notifier. The rest of the tokens are\\n /// burned. Can only be called by the Governance. See `seize` function.\\n function setStakeDiscrepancyPenalty(\\n uint96 penalty,\\n uint256 rewardMultiplier\\n ) external;\\n\\n /// @notice Sets reward in T tokens for notification of misbehaviour\\n /// of one staking provider. Can only be called by the governance.\\n function setNotificationReward(uint96 reward) external;\\n\\n /// @notice Transfer some amount of T tokens as reward for notifications\\n /// of misbehaviour\\n function pushNotificationReward(uint96 reward) external;\\n\\n /// @notice Withdraw some amount of T tokens from notifiers treasury.\\n /// Can only be called by the governance.\\n function withdrawNotificationReward(address recipient, uint96 amount)\\n external;\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount that should be slashed from each one of them. Can only be\\n /// called by application authorized for all staking providers in\\n /// the array.\\n function slash(uint96 amount, address[] memory stakingProviders) external;\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each staking\\n /// provider from notifiers treasury. Can only be called by\\n /// application authorized for all staking providers in the array.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultipier,\\n address notifier,\\n address[] memory stakingProviders\\n ) external;\\n\\n /// @notice Takes the given number of queued slashing operations and\\n /// processes them. Receives 5% of the slashed amount.\\n /// Executes `involuntaryAllocationDecrease` function on each\\n /// affected application.\\n function processSlashing(uint256 count) external;\\n\\n //\\n //\\n // Auxiliary functions\\n //\\n //\\n\\n /// @notice Returns the authorized stake amount of the staking provider for\\n /// the application.\\n function authorizedStake(address stakingProvider, address application)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice Returns staked amount of T, Keep and Nu for the specified\\n /// staking provider.\\n /// @dev All values are in T denomination\\n function stakes(address stakingProvider)\\n external\\n view\\n returns (\\n uint96 tStake,\\n uint96 keepInTStake,\\n uint96 nuInTStake\\n );\\n\\n /// @notice Returns start staking timestamp.\\n /// @dev This value is set at most once.\\n function getStartStakingTimestamp(address stakingProvider)\\n external\\n view\\n returns (uint256);\\n\\n /// @notice Returns staked amount of NU for the specified staking provider.\\n function stakedNu(address stakingProvider) external view returns (uint256);\\n\\n /// @notice Gets the stake owner, the beneficiary and the authorizer\\n /// for the specified staking provider address.\\n /// @return owner Stake owner address.\\n /// @return beneficiary Beneficiary address.\\n /// @return authorizer Authorizer address.\\n function rolesOf(address stakingProvider)\\n external\\n view\\n returns (\\n address owner,\\n address payable beneficiary,\\n address authorizer\\n );\\n\\n /// @notice Returns length of application array\\n function getApplicationsLength() external view returns (uint256);\\n\\n /// @notice Returns length of slashing queue\\n function getSlashingQueueLength() external view returns (uint256);\\n\\n /// @notice Returns minimum possible stake for T, KEEP or NU in T\\n /// denomination.\\n /// @dev For example, suppose the given staking provider has 10 T, 20 T\\n /// worth of KEEP, and 30 T worth of NU all staked, and the maximum\\n /// application authorization is 40 T, then `getMinStaked` for\\n /// that staking provider returns:\\n /// * 0 T if KEEP stake type specified i.e.\\n /// min = 40 T max - (10 T + 30 T worth of NU) = 0 T\\n /// * 10 T if NU stake type specified i.e.\\n /// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T\\n /// * 0 T if T stake type specified i.e.\\n /// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T\\n /// In other words, the minimum stake amount for the specified\\n /// stake type is the minimum amount of stake of the given type\\n /// needed to satisfy the maximum application authorization given the\\n /// staked amounts of the other stake types for that staking provider.\\n function getMinStaked(address stakingProvider, StakeType stakeTypes)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice Returns available amount to authorize for the specified application\\n function getAvailableToAuthorize(\\n address stakingProvider,\\n address application\\n ) external view returns (uint96);\\n}\\n\",\"keccak256\":\"0x45c15ff4a9a47024ce413da249a6a77cc2f20a81909e7536d4c5198c92f3f148\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/KeepStake.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 \\\"./ILegacyTokenStaking.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title KEEP ManagedGrant contract interface\\ninterface IManagedGrant {\\n function grantee() external view returns (address);\\n}\\n\\n/// @title KEEP stake owner resolver\\n/// @notice T network staking contract supports existing KEEP stakes by allowing\\n/// KEEP stakers to use their stakes in T network and weights them based\\n/// on KEEP<>T token ratio. KEEP stake owner is cached in T staking\\n/// contract and used to restrict access to all functions only owner or\\n/// operator should call. To cache KEEP stake owner in T staking\\n/// contract, T staking contract first needs to resolve the owner.\\n///\\n/// Resolving liquid KEEP stake owner is easy. Resolving token grant\\n/// stake owner is complicated and not possible to do on-chain from\\n/// a contract external to KEEP TokenStaking contract. Keep TokenStaking\\n/// knows the grant ID but does not expose it externally.\\n///\\n/// KeepStake contract addresses this problem by exposing\\n/// operator-owner mappings snapshotted off-chain based on events and\\n/// information publicly available from KEEP TokenStaking contract and\\n/// KEEP TokenGrant contract. Additionally, it gives the Governance\\n/// ability to add new mappings in case they are ever needed; in\\n/// practice, this will be needed only if someone decides to stake their\\n/// KEEP token grant in KEEP network after 2021-11-11 when the snapshot\\n/// was taken.\\n///\\n/// Operator-owner pairs were snapshotted 2021-11-11 in the following\\n/// way:\\n/// 1. Fetch all TokenStaking events from KEEP staking contract.\\n/// 2. Filter out undelegated operators.\\n/// 3. Filter out canceled delegations.\\n/// 4. Fetch grant stake information from KEEP TokenGrant for that\\n/// operator to determine if we are dealing with grant delegation.\\n/// 5. Fetch grantee address from KEEP TokenGrant contract.\\n/// 6. Check if we are dealing with ManagedGrant by looking for all\\n/// created ManagedGrants and comparing their address against grantee\\n/// address fetched from TokenGrant contract.\\ncontract KeepStake is Ownable {\\n IKeepTokenStaking public immutable keepTokenStaking;\\n\\n mapping(address => address) public operatorToManagedGrant;\\n mapping(address => address) public operatorToGrantee;\\n\\n constructor(IKeepTokenStaking _keepTokenStaking) {\\n keepTokenStaking = _keepTokenStaking;\\n }\\n\\n /// @notice Allows the Governance to set new operator-managed grant pair.\\n /// This function should only be called for managed grants if\\n /// the snapshot does include this pair.\\n function setManagedGrant(address operator, address managedGrant)\\n external\\n onlyOwner\\n {\\n operatorToManagedGrant[operator] = managedGrant;\\n }\\n\\n /// @notice Allows the Governance to set new operator-grantee pair.\\n /// This function should only be called for non-managed grants if\\n /// the snapshot does include this pair.\\n function setGrantee(address operator, address grantee) external onlyOwner {\\n operatorToGrantee[operator] = grantee;\\n }\\n\\n /// @notice Resolves KEEP stake owner for the provided operator address.\\n /// Reverts if could not resolve the owner.\\n function resolveOwner(address operator) external view returns (address) {\\n address owner = operatorToManagedGrant[operator];\\n if (owner != address(0)) {\\n return IManagedGrant(owner).grantee();\\n }\\n\\n owner = operatorToGrantee[operator];\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = resolveSnapshottedManagedGrantees(operator);\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = resolveSnapshottedGrantees(operator);\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = keepTokenStaking.ownerOf(operator);\\n require(owner != address(0), \\\"Could not resolve the owner\\\");\\n\\n return owner;\\n }\\n\\n function resolveSnapshottedManagedGrantees(address operator)\\n internal\\n view\\n returns (address)\\n {\\n if (operator == 0x855A951162B1B93D70724484d5bdc9D00B56236B) {\\n return\\n IManagedGrant(0xFADbF758307A054C57B365Db1De90acA71feaFE5)\\n .grantee();\\n }\\n if (operator == 0xF1De9490Bf7298b5F350cE74332Ad7cf8d5cB181) {\\n return\\n IManagedGrant(0xAEd493Aaf3E76E83b29E151848b71eF4544f92f1)\\n .grantee();\\n }\\n if (operator == 0x39d2aCBCD80d80080541C6eed7e9feBb8127B2Ab) {\\n return\\n IManagedGrant(0xA2fa09D6f8C251422F5fde29a0BAd1C53dEfAe66)\\n .grantee();\\n }\\n if (operator == 0xd66cAE89FfBc6E50e6b019e45c1aEc93Dec54781) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0x2eBE08379f4fD866E871A9b9E1d5C695154C6A9F) {\\n return\\n IManagedGrant(0xd00c0d43b747C33726B3f0ff4BDA4b72dc53c6E9)\\n .grantee();\\n }\\n if (operator == 0xA97c34278162b556A527CFc01B53eb4DDeDFD223) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x6C76d49322C9f8761A1623CEd89A31490cdB649d) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x4a41c7a884d119eaaefE471D0B3a638226408382) {\\n return\\n IManagedGrant(0xcdf3d216d82a463Ce82971F2F5DA3d8f9C5f093A)\\n .grantee();\\n }\\n if (operator == 0x9c06Feb7Ebc8065ee11Cd5E8EEdaAFb2909A7087) {\\n return\\n IManagedGrant(0x45119cd98d145283762BA9eBCAea75F72D188733)\\n .grantee();\\n }\\n if (operator == 0x9bD818Ab6ACC974f2Cf2BD2EBA7a250126Accb9F) {\\n return\\n IManagedGrant(0x6E535043377067621954ee84065b0bd7357e7aBa)\\n .grantee();\\n }\\n if (operator == 0x1d803c89760F8B4057DB15BCb3B8929E0498D310) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x3101927DEeC27A2bfA6c4a6316e3A221f631dB91) {\\n return\\n IManagedGrant(0x178Bf1946feD0e2362fdF8bcD3f91F0701a012C6)\\n .grantee();\\n }\\n if (operator == 0x9d9b187E478bC62694A7bED216Fc365de87F280C) {\\n return\\n IManagedGrant(0xFBad17CFad6cb00D726c65501D69FdC13Ca5477c)\\n .grantee();\\n }\\n if (operator == 0xd977144724Bc77FaeFAe219F958AE3947205d0b5) {\\n return\\n IManagedGrant(0x087B442BFd4E42675cf2df5fa566F87d7A96Fb12)\\n .grantee();\\n }\\n if (operator == 0x045E511f53DeBF55c9C0B4522f14F602f7C7cA81) {\\n return\\n IManagedGrant(0xFcfe8C036C414a15cF871071c483687095caF7D6)\\n .grantee();\\n }\\n if (operator == 0x3Dd301b3c96A282d8092E1e6f6846f24172D45C1) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x5d84DEB482E770479154028788Df79aA7C563aA4) {\\n return\\n IManagedGrant(0x9D1a179c469a8BdD0b683A9f9250246cc47e8fBE)\\n .grantee();\\n }\\n if (operator == 0x1dF927B69A97E8140315536163C029d188e8573b) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x617daCE069Fbd41993491de211b4DfccdAcbd348) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x650A9eD18Df873cad98C88dcaC8170531cAD2399) {\\n return\\n IManagedGrant(0x1Df7324A3aD20526DFa02Cc803eD2D97Cac81F3b)\\n .grantee();\\n }\\n if (operator == 0x07C9a8f8264221906b7b8958951Ce4753D39628B) {\\n return\\n IManagedGrant(0x305D12b4d70529Cd618dA7399F5520701E510041)\\n .grantee();\\n }\\n if (operator == 0x63eB4c3DD0751F9BE7070A01156513C227fa1eF6) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0xc6349eEC31048787676b6297ba71721376A8DdcF) {\\n return\\n IManagedGrant(0xac1a985E75C6a0b475b9c807Ad0705a988Be2D99)\\n .grantee();\\n }\\n if (operator == 0x3B945f9C0C8737e44f8e887d4F04B5B3A491Ac4d) {\\n return\\n IManagedGrant(0x82e17477726E8D9D2C237745cA9989631582eE98)\\n .grantee();\\n }\\n if (operator == 0xF35343299a4f80Dd5D917bbe5ddd54eBB820eBd4) {\\n return\\n IManagedGrant(0xCC88c15506251B62ccCeebA193e100d6bBC9a30D)\\n .grantee();\\n }\\n if (operator == 0x3B9e5ae72d068448bB96786989c0d86FBC0551D1) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0xB2D53Be158Cb8451dFc818bD969877038c1BdeA1) {\\n return\\n IManagedGrant(0xaE55e3800f0A3feaFdcE535A8C0fab0fFdB90DEe)\\n .grantee();\\n }\\n if (operator == 0xF6dbF7AFe05b8Bb6f198eC7e69333c98D3C4608C) {\\n return\\n IManagedGrant(0xbb8D24a20c20625f86739824014C3cBAAAb26700)\\n .grantee();\\n }\\n if (operator == 0xB62Fc1ADfFb2ab832041528C8178358338d85f76) {\\n return\\n IManagedGrant(0x9ED98fD1C29018B9342CB8F57A3073B9695f0c02)\\n .grantee();\\n }\\n if (operator == 0x9bC8d30d971C9e74298112803036C05db07D73e3) {\\n return\\n IManagedGrant(0x66beda757939f8e505b5Eb883cd02C8d4a11Bca2)\\n .grantee();\\n }\\n\\n return address(0);\\n }\\n\\n function resolveSnapshottedGrantees(address operator)\\n internal\\n pure\\n returns (address)\\n {\\n if (operator == 0x1147ccFB4AEFc6e587a23b78724Ef20Ec6e474D4) {\\n return 0x3FB49dA4375Ef9019f17990D04c6d5daD482D80a;\\n }\\n if (operator == 0x4c21541f95a00C03C75F38C71DC220bd27cbbEd9) {\\n return 0xC897cfeE43a8d827F76D4226994D5CE5EBBe2571;\\n }\\n if (operator == 0x7E6332d18719a5463d3867a1a892359509589a3d) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0x8Bd660A764Ca14155F3411a4526a028b6316CB3E) {\\n return 0xf6f372DfAeCC1431186598c304e91B79Ce115766;\\n }\\n if (operator == 0x4F4f0D0dfd93513B3f4Cb116Fe9d0A005466F725) {\\n return 0x8b055ac1c4dd287E2a46D4a52d61FE76FB551bD0;\\n }\\n if (operator == 0x1DF0250027fEC876d8876d1ac7A392c9098F1a1e) {\\n return 0xE408fFa969707Ce5d7aA3e5F8d44674Fa4b26219;\\n }\\n if (operator == 0x860EF3f83B6adFEF757F98345c3B8DdcFCA9d152) {\\n return 0x08a3633AAb8f3E436DEA204288Ee26Fe094406b0;\\n }\\n if (operator == 0xe3a2d16dA142E6B190A5d9F7e0C07cc460B58A5F) {\\n return 0x875f8fFCDDeD63B5d8Cf54be4E4b82FE6c6E249C;\\n }\\n if (operator == 0xBDE07f1cA107Ef319b0Bb26eBF1d0a5b4c97ffc1) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0xE86181D6b672d78D33e83029fF3D0ef4A601B4C4) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0xb7c561e2069aCaE2c4480111B1606790BB4E13fE) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0x526c013f8382B050d32d86e7090Ac84De22EdA4D) {\\n return 0x61C6E5DDacded540CD08066C08cbc096d22D91f4;\\n }\\n\\n return address(0);\\n }\\n}\\n\",\"keccak256\":\"0xc75f6be595ec0e0c885d689786808a53b70c0a170a53dd344228359dc6aaf178\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/TokenStaking.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 \\\"./IApplication.sol\\\";\\nimport \\\"./ILegacyTokenStaking.sol\\\";\\nimport \\\"./IStaking.sol\\\";\\nimport \\\"./KeepStake.sol\\\";\\nimport \\\"../governance/Checkpoints.sol\\\";\\nimport \\\"../token/T.sol\\\";\\nimport \\\"../utils/PercentUtils.sol\\\";\\nimport \\\"../utils/SafeTUpgradeable.sol\\\";\\nimport \\\"../vending/VendingMachine.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\n\\n/// @notice TokenStaking is the main staking contract of the Threshold Network.\\n/// Apart from the basic usage of enabling T stakes, it also acts as a\\n/// sort of \\\"meta-staking\\\" contract, accepting existing legacy NU/KEEP\\n/// stakes. Additionally, it serves as application manager for the apps\\n/// that run on the Threshold Network. Note that legacy NU/KEEP staking\\n/// contracts see TokenStaking as an application (e.g., slashing is\\n/// requested by TokenStaking and performed by the legacy contracts).\\n/// @dev TokenStaking is upgradeable, using OpenZeppelin's Upgradeability\\n/// framework. As such, it is required to satisfy OZ's guidelines, like\\n/// restrictions on constructors, immutable variables, base contracts and\\n/// libraries. See https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable\\ncontract TokenStaking is Initializable, IStaking, Checkpoints {\\n using SafeTUpgradeable for T;\\n using PercentUtils for uint256;\\n using SafeCastUpgradeable for uint256;\\n\\n enum ApplicationStatus {\\n NOT_APPROVED,\\n APPROVED,\\n PAUSED,\\n DISABLED\\n }\\n\\n struct StakingProviderInfo {\\n uint96 nuInTStake;\\n address owner;\\n uint96 keepInTStake;\\n address payable beneficiary;\\n uint96 tStake;\\n address authorizer;\\n mapping(address => AppAuthorization) authorizations;\\n address[] authorizedApplications;\\n uint256 startStakingTimestamp;\\n }\\n\\n struct AppAuthorization {\\n uint96 authorized;\\n uint96 deauthorizing;\\n }\\n\\n struct ApplicationInfo {\\n ApplicationStatus status;\\n address panicButton;\\n }\\n\\n struct SlashingEvent {\\n address stakingProvider;\\n uint96 amount;\\n }\\n\\n uint256 internal constant SLASHING_REWARD_PERCENT = 5;\\n uint256 internal constant MIN_STAKE_TIME = 120;\\n uint256 internal constant GAS_LIMIT_AUTHORIZATION_DECREASE = 250000;\\n uint256 internal constant CONVERSION_DIVISOR = 10**(18 - 3);\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n T internal immutable token;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IKeepTokenStaking internal immutable keepStakingContract;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n KeepStake internal immutable keepStake;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n INuCypherStakingEscrow internal immutable nucypherStakingContract;\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable keepRatio;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable nucypherRatio;\\n\\n address public governance;\\n uint96 public minTStakeAmount;\\n uint256 public authorizationCeiling;\\n uint96 public stakeDiscrepancyPenalty;\\n uint256 public stakeDiscrepancyRewardMultiplier;\\n\\n uint256 public notifiersTreasury;\\n uint256 public notificationReward;\\n\\n mapping(address => StakingProviderInfo) internal stakingProviders;\\n mapping(address => ApplicationInfo) public applicationInfo;\\n address[] public applications;\\n\\n SlashingEvent[] public slashingQueue;\\n uint256 public slashingQueueIndex;\\n\\n event Staked(\\n StakeType indexed stakeType,\\n address indexed owner,\\n address indexed stakingProvider,\\n address beneficiary,\\n address authorizer,\\n uint96 amount\\n );\\n event MinimumStakeAmountSet(uint96 amount);\\n event ApplicationStatusChanged(\\n address indexed application,\\n ApplicationStatus indexed newStatus\\n );\\n event AuthorizationIncreased(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationDecreaseRequested(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationDecreaseApproved(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationInvoluntaryDecreased(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount,\\n bool indexed successfulCall\\n );\\n event PanicButtonSet(\\n address indexed application,\\n address indexed panicButton\\n );\\n event AuthorizationCeilingSet(uint256 ceiling);\\n event ToppedUp(address indexed stakingProvider, uint96 amount);\\n event Unstaked(address indexed stakingProvider, uint96 amount);\\n event TokensSeized(\\n address indexed stakingProvider,\\n uint96 amount,\\n bool indexed discrepancy\\n );\\n event StakeDiscrepancyPenaltySet(uint96 penalty, uint256 rewardMultiplier);\\n event NotificationRewardSet(uint96 reward);\\n event NotificationRewardPushed(uint96 reward);\\n event NotificationRewardWithdrawn(address recipient, uint96 amount);\\n event NotifierRewarded(address indexed notifier, uint256 amount);\\n event SlashingProcessed(\\n address indexed caller,\\n uint256 count,\\n uint256 tAmount\\n );\\n event OwnerRefreshed(\\n address indexed stakingProvider,\\n address indexed oldOwner,\\n address indexed newOwner\\n );\\n event GovernanceTransferred(address oldGovernance, address newGovernance);\\n\\n modifier onlyGovernance() {\\n require(governance == msg.sender, \\\"Caller is not the governance\\\");\\n _;\\n }\\n\\n modifier onlyPanicButtonOf(address application) {\\n require(\\n applicationInfo[application].panicButton == msg.sender,\\n \\\"Caller is not the panic button\\\"\\n );\\n _;\\n }\\n\\n modifier onlyAuthorizerOf(address stakingProvider) {\\n //slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].authorizer == msg.sender,\\n \\\"Not authorizer\\\"\\n );\\n _;\\n }\\n\\n modifier onlyOwnerOrStakingProvider(address stakingProvider) {\\n //slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].owner != address(0) &&\\n (stakingProvider == msg.sender ||\\n stakingProviders[stakingProvider].owner == msg.sender),\\n \\\"Not owner or provider\\\"\\n );\\n _;\\n }\\n\\n modifier onlyOwnerOf(address stakingProvider) {\\n // slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].owner == msg.sender,\\n \\\"Caller is not owner\\\"\\n );\\n _;\\n }\\n\\n /// @param _token Address of T token contract\\n /// @param _keepStakingContract Address of Keep staking contract\\n /// @param _nucypherStakingContract Address of NuCypher staking contract\\n /// @param _keepVendingMachine Address of Keep vending machine\\n /// @param _nucypherVendingMachine Address of NuCypher vending machine\\n /// @param _keepStake Address of Keep contract with grant owners\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n T _token,\\n IKeepTokenStaking _keepStakingContract,\\n INuCypherStakingEscrow _nucypherStakingContract,\\n VendingMachine _keepVendingMachine,\\n VendingMachine _nucypherVendingMachine,\\n KeepStake _keepStake\\n ) {\\n // calls to check contracts are working\\n require(\\n _token.totalSupply() > 0 &&\\n _keepStakingContract.ownerOf(address(0)) == address(0) &&\\n _nucypherStakingContract.getAllTokens(address(0)) == 0 &&\\n AddressUpgradeable.isContract(address(_keepStake)),\\n \\\"Wrong input parameters\\\"\\n );\\n token = _token;\\n keepStakingContract = _keepStakingContract;\\n keepStake = _keepStake;\\n nucypherStakingContract = _nucypherStakingContract;\\n\\n keepRatio = _keepVendingMachine.ratio();\\n nucypherRatio = _nucypherVendingMachine.ratio();\\n }\\n\\n function initialize() external initializer {\\n _transferGovernance(msg.sender);\\n }\\n\\n //\\n //\\n // Delegating a stake\\n //\\n //\\n\\n /// @notice Creates a delegation with `msg.sender` owner with the given\\n /// staking provider, beneficiary, and authorizer. Transfers the\\n /// given amount of T to the staking contract.\\n /// @dev The owner of the delegation needs to have the amount approved to\\n /// transfer to the staking contract.\\n function stake(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer,\\n uint96 amount\\n ) external override {\\n require(\\n stakingProvider != address(0) &&\\n beneficiary != address(0) &&\\n authorizer != address(0),\\n \\\"Parameters must be specified\\\"\\n );\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n (, uint256 createdAt, ) = keepStakingContract.getDelegationInfo(\\n stakingProvider\\n );\\n require(\\n createdAt == 0 && stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n require(\\n amount > 0 && amount >= minTStakeAmount,\\n \\\"Amount is less than minimum\\\"\\n );\\n stakingProviderStruct.owner = msg.sender;\\n stakingProviderStruct.authorizer = authorizer;\\n stakingProviderStruct.beneficiary = beneficiary;\\n\\n stakingProviderStruct.tStake = amount;\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, amount);\\n\\n emit Staked(\\n StakeType.T,\\n msg.sender,\\n stakingProvider,\\n beneficiary,\\n authorizer,\\n amount\\n );\\n token.safeTransferFrom(msg.sender, address(this), amount);\\n }\\n\\n /// @notice Copies delegation from the legacy KEEP staking contract to T\\n /// staking contract. No tokens are transferred. Caches the active\\n /// stake amount from KEEP staking contract. Can be called by\\n /// anyone.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function stakeKeep(address stakingProvider) external override {\\n require(stakingProvider != address(0), \\\"Parameters must be specified\\\");\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n\\n require(\\n stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n\\n uint96 tAmount = getKeepAmountInT(stakingProvider);\\n require(tAmount != 0, \\\"Nothing to sync\\\");\\n\\n stakingProviderStruct.keepInTStake = tAmount;\\n stakingProviderStruct.owner = keepStake.resolveOwner(stakingProvider);\\n stakingProviderStruct.authorizer = keepStakingContract.authorizerOf(\\n stakingProvider\\n );\\n stakingProviderStruct.beneficiary = keepStakingContract.beneficiaryOf(\\n stakingProvider\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, tAmount);\\n\\n emit Staked(\\n StakeType.KEEP,\\n stakingProviderStruct.owner,\\n stakingProvider,\\n stakingProviderStruct.beneficiary,\\n stakingProviderStruct.authorizer,\\n tAmount\\n );\\n }\\n\\n /// @notice Copies delegation from the legacy NU staking contract to T\\n /// staking contract, additionally appointing beneficiary and\\n /// authorizer roles. Caches the amount staked in NU staking\\n /// contract. Can be called only by the original delegation owner.\\n function stakeNu(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer\\n ) external override {\\n require(\\n stakingProvider != address(0) &&\\n beneficiary != address(0) &&\\n authorizer != address(0),\\n \\\"Parameters must be specified\\\"\\n );\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n (, uint256 createdAt, ) = keepStakingContract.getDelegationInfo(\\n stakingProvider\\n );\\n require(\\n createdAt == 0 && stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n\\n uint96 tAmount = getNuAmountInT(msg.sender, stakingProvider);\\n require(tAmount > 0, \\\"Nothing to sync\\\");\\n\\n stakingProviderStruct.nuInTStake = tAmount;\\n stakingProviderStruct.owner = msg.sender;\\n stakingProviderStruct.authorizer = authorizer;\\n stakingProviderStruct.beneficiary = beneficiary;\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, tAmount);\\n\\n emit Staked(\\n StakeType.NU,\\n msg.sender,\\n stakingProvider,\\n beneficiary,\\n authorizer,\\n tAmount\\n );\\n }\\n\\n /// @notice Allows the Governance to set the minimum required stake amount.\\n /// This amount is required to protect against griefing the staking\\n /// contract and individual applications are allowed to require\\n /// higher minimum stakes if necessary.\\n /// @dev Staking providers are not required to maintain a minimum T stake\\n /// all the time. 24 hours after the delegation, T stake can be reduced\\n /// below the minimum stake. The minimum stake in the staking contract\\n /// is just to protect against griefing stake operation. Please note\\n /// that each application may have its own minimum authorization though\\n /// and the authorization can not be higher than the stake.\\n function setMinimumStakeAmount(uint96 amount)\\n external\\n override\\n onlyGovernance\\n {\\n minTStakeAmount = amount;\\n emit MinimumStakeAmountSet(amount);\\n }\\n\\n //\\n //\\n // Authorizing an application\\n //\\n //\\n\\n /// @notice Allows the Governance to approve the particular application\\n /// before individual stake authorizers are able to authorize it.\\n function approveApplication(address application)\\n external\\n override\\n onlyGovernance\\n {\\n require(application != address(0), \\\"Parameters must be specified\\\");\\n ApplicationInfo storage info = applicationInfo[application];\\n require(\\n info.status == ApplicationStatus.NOT_APPROVED ||\\n info.status == ApplicationStatus.PAUSED,\\n \\\"Can't approve application\\\"\\n );\\n\\n if (info.status == ApplicationStatus.NOT_APPROVED) {\\n applications.push(application);\\n }\\n info.status = ApplicationStatus.APPROVED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.APPROVED);\\n }\\n\\n /// @notice Increases the authorization of the given staking provider for\\n /// the given application by the given amount. Can only be called by\\n /// the given staking provider\\u2019s authorizer.\\n /// @dev Calls `authorizationIncreased` callback on the given application to\\n /// notify the application about authorization change.\\n /// See `IApplication`.\\n function increaseAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external override onlyAuthorizerOf(stakingProvider) {\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[application];\\n uint96 fromAmount = authorization.authorized;\\n if (fromAmount == 0) {\\n require(\\n authorizationCeiling == 0 ||\\n stakingProviderStruct.authorizedApplications.length <\\n authorizationCeiling,\\n \\\"Too many applications\\\"\\n );\\n stakingProviderStruct.authorizedApplications.push(application);\\n }\\n\\n uint96 availableTValue = getAvailableToAuthorize(\\n stakingProvider,\\n application\\n );\\n require(availableTValue >= amount, \\\"Not enough stake to authorize\\\");\\n authorization.authorized += amount;\\n emit AuthorizationIncreased(\\n stakingProvider,\\n application,\\n fromAmount,\\n authorization.authorized\\n );\\n IApplication(application).authorizationIncreased(\\n stakingProvider,\\n fromAmount,\\n authorization.authorized\\n );\\n }\\n\\n /// @notice Requests decrease of all authorizations for the given staking\\n /// provider on all applications by all authorized amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application.\\n /// @dev Calls `authorizationDecreaseRequested` callback\\n /// for each authorized application. See `IApplication`.\\n function requestAuthorizationDecrease(address stakingProvider) external {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 deauthorizing = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address application = stakingProviderStruct.authorizedApplications[\\n i\\n ];\\n uint96 authorized = stakingProviderStruct\\n .authorizations[application]\\n .authorized;\\n if (authorized > 0) {\\n requestAuthorizationDecrease(\\n stakingProvider,\\n application,\\n authorized\\n );\\n deauthorizing += authorized;\\n }\\n }\\n\\n require(deauthorizing > 0, \\\"Nothing was authorized\\\");\\n }\\n\\n /// @notice Called by the application at its discretion to approve the\\n /// previously requested authorization decrease request. Can only be\\n /// called by the application that was previously requested to\\n /// decrease the authorization for that staking provider.\\n /// Returns resulting authorized amount for the application.\\n function approveAuthorizationDecrease(address stakingProvider)\\n external\\n override\\n returns (uint96)\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[msg.sender];\\n require(authorization.deauthorizing > 0, \\\"No deauthorizing in process\\\");\\n\\n uint96 fromAmount = authorization.authorized;\\n authorization.authorized -= authorization.deauthorizing;\\n authorization.deauthorizing = 0;\\n emit AuthorizationDecreaseApproved(\\n stakingProvider,\\n msg.sender,\\n fromAmount,\\n authorization.authorized\\n );\\n\\n // remove application from an array\\n if (authorization.authorized == 0) {\\n cleanAuthorizedApplications(stakingProviderStruct, 1);\\n }\\n\\n return authorization.authorized;\\n }\\n\\n /// @notice Decreases the authorization for the given `stakingProvider` on\\n /// the given disabled `application`, for all authorized amount.\\n /// Can be called by anyone.\\n function forceDecreaseAuthorization(\\n address stakingProvider,\\n address application\\n ) external override {\\n require(\\n applicationInfo[application].status == ApplicationStatus.DISABLED,\\n \\\"Application is not disabled\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[application];\\n uint96 fromAmount = authorization.authorized;\\n require(fromAmount > 0, \\\"Application is not authorized\\\");\\n authorization.authorized = 0;\\n authorization.deauthorizing = 0;\\n\\n emit AuthorizationDecreaseApproved(\\n stakingProvider,\\n application,\\n fromAmount,\\n 0\\n );\\n cleanAuthorizedApplications(stakingProviderStruct, 1);\\n }\\n\\n /// @notice Pauses the given application\\u2019s eligibility to slash stakes.\\n /// Besides that stakers can't change authorization to the application.\\n /// Can be called only by the Panic Button of the particular\\n /// application. The paused application can not slash stakes until\\n /// it is approved again by the Governance using `approveApplication`\\n /// function. Should be used only in case of an emergency.\\n function pauseApplication(address application)\\n external\\n override\\n onlyPanicButtonOf(application)\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Can't pause application\\\"\\n );\\n applicationStruct.status = ApplicationStatus.PAUSED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.PAUSED);\\n }\\n\\n /// @notice Disables the given application. The disabled application can't\\n /// slash stakers. Also stakers can't increase authorization to that\\n /// application but can decrease without waiting by calling\\n /// `forceDecreaseAuthorization` at any moment. Can be called only\\n /// by the governance. The disabled application can't be approved\\n /// again. Should be used only in case of an emergency.\\n function disableApplication(address application)\\n external\\n override\\n onlyGovernance\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED ||\\n applicationStruct.status == ApplicationStatus.PAUSED,\\n \\\"Can't disable application\\\"\\n );\\n applicationStruct.status = ApplicationStatus.DISABLED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.DISABLED);\\n }\\n\\n /// @notice Sets the Panic Button role for the given application to the\\n /// provided address. Can only be called by the Governance. If the\\n /// Panic Button for the given application should be disabled, the\\n /// role address should be set to 0x0 address.\\n function setPanicButton(address application, address panicButton)\\n external\\n override\\n onlyGovernance\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n applicationStruct.panicButton = panicButton;\\n emit PanicButtonSet(application, panicButton);\\n }\\n\\n /// @notice Sets the maximum number of applications one staking provider can\\n /// have authorized. Used to protect against DoSing slashing queue.\\n /// Can only be called by the Governance.\\n function setAuthorizationCeiling(uint256 ceiling)\\n external\\n override\\n onlyGovernance\\n {\\n authorizationCeiling = ceiling;\\n emit AuthorizationCeilingSet(ceiling);\\n }\\n\\n //\\n //\\n // Stake top-up\\n //\\n //\\n\\n /// @notice Increases the amount of the stake for the given staking provider.\\n /// @dev The sender of this transaction needs to have the amount approved to\\n /// transfer to the staking contract.\\n function topUp(address stakingProvider, uint96 amount) external override {\\n require(\\n stakingProviders[stakingProvider].owner != address(0),\\n \\\"Nothing to top-up\\\"\\n );\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n stakingProviderStruct.tStake += amount;\\n emit ToppedUp(stakingProvider, amount);\\n increaseStakeCheckpoint(stakingProvider, amount);\\n token.safeTransferFrom(msg.sender, address(this), amount);\\n }\\n\\n /// @notice Propagates information about stake top-up from the legacy KEEP\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpKeep(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 tAmount = getKeepAmountInT(stakingProvider);\\n require(\\n tAmount > stakingProviderStruct.keepInTStake,\\n \\\"Nothing to top-up\\\"\\n );\\n\\n uint96 toppedUp = tAmount - stakingProviderStruct.keepInTStake;\\n emit ToppedUp(stakingProvider, toppedUp);\\n stakingProviderStruct.keepInTStake = tAmount;\\n increaseStakeCheckpoint(stakingProvider, toppedUp);\\n }\\n\\n /// @notice Propagates information about stake top-up from the legacy NU\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpNu(address stakingProvider)\\n external\\n override\\n onlyOwnerOf(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 tAmount = getNuAmountInT(\\n stakingProviderStruct.owner,\\n stakingProvider\\n );\\n require(\\n tAmount > stakingProviderStruct.nuInTStake,\\n \\\"Nothing to top-up\\\"\\n );\\n\\n uint96 toppedUp = tAmount - stakingProviderStruct.nuInTStake;\\n emit ToppedUp(stakingProvider, toppedUp);\\n stakingProviderStruct.nuInTStake = tAmount;\\n increaseStakeCheckpoint(stakingProvider, toppedUp);\\n }\\n\\n //\\n //\\n // Undelegating a stake (unstaking)\\n //\\n //\\n\\n /// @notice Reduces the liquid T stake amount by the provided amount and\\n /// withdraws T to the owner. Reverts if there is at least one\\n /// authorization higher than the sum of the legacy stake and\\n /// remaining liquid T stake or if the unstake amount is higher than\\n /// the liquid T stake amount. Can be called only by the owner or\\n /// the staking provider. Can only be called when 24h passed since\\n /// the stake has been delegated.\\n function unstakeT(address stakingProvider, uint96 amount)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n amount > 0 &&\\n amount + getMinStaked(stakingProvider, StakeType.T) <=\\n stakingProviderStruct.tStake,\\n \\\"Too much to unstake\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n stakingProviderStruct.tStake -= amount;\\n decreaseStakeCheckpoint(stakingProvider, amount);\\n emit Unstaked(stakingProvider, amount);\\n token.safeTransfer(stakingProviderStruct.owner, amount);\\n }\\n\\n /// @notice Sets the legacy KEEP staking contract active stake amount cached\\n /// in T staking contract to 0. Reverts if the amount of liquid T\\n /// staked in T staking contract is lower than the highest\\n /// application authorization. This function allows to unstake from\\n /// KEEP staking contract and still being able to operate in T\\n /// network and earning rewards based on the liquid T staked. Can be\\n /// called only by the delegation owner or the staking provider.\\n /// Can only be called when 24h passed since the stake has been\\n /// delegated.\\n /// @dev This function (or `unstakeAll`) must be called before\\n /// `undelegate`/`undelegateAt` in Keep staking contract. Otherwise\\n /// provider can be slashed by `notifyKeepStakeDiscrepancy` method.\\n function unstakeKeep(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 keepInTStake = stakingProviderStruct.keepInTStake;\\n require(keepInTStake != 0, \\\"Nothing to unstake\\\");\\n require(\\n getMinStaked(stakingProvider, StakeType.KEEP) == 0,\\n \\\"Keep stake still authorized\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n emit Unstaked(stakingProvider, keepInTStake);\\n stakingProviderStruct.keepInTStake = 0;\\n decreaseStakeCheckpoint(stakingProvider, keepInTStake);\\n }\\n\\n /// @notice Reduces cached legacy NU stake amount by the provided amount.\\n /// Reverts if there is at least one authorization higher than the\\n /// sum of remaining legacy NU stake and liquid T stake for that\\n /// staking provider or if the untaked amount is higher than the\\n /// cached legacy stake amount. If succeeded, the legacy NU stake\\n /// can be partially or fully undelegated on the legacy staking\\n /// contract. This function allows to unstake from NU staking\\n /// contract and still being able to operate in T network and\\n /// earning rewards based on the liquid T staked. Can be called only\\n /// by the delegation owner or the staking provider. Can only be\\n /// called when 24h passed since the stake has been delegated.\\n /// @dev This function (or `unstakeAll`) must be called before `withdraw`\\n /// in NuCypher staking contract. Otherwise NU tokens can't be\\n /// unlocked.\\n /// @param stakingProvider Staking provider address\\n /// @param amount Amount of NU to unstake in T denomination\\n function unstakeNu(address stakingProvider, uint96 amount)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n // rounding amount to guarantee exact T<>NU conversion in both ways,\\n // so there's no remainder after unstaking\\n (, uint96 tRemainder) = convertFromT(amount, nucypherRatio);\\n amount -= tRemainder;\\n require(\\n amount > 0 &&\\n amount + getMinStaked(stakingProvider, StakeType.NU) <=\\n stakingProviderStruct.nuInTStake,\\n \\\"Too much to unstake\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n stakingProviderStruct.nuInTStake -= amount;\\n decreaseStakeCheckpoint(stakingProvider, amount);\\n emit Unstaked(stakingProvider, amount);\\n }\\n\\n /// @notice Sets cached legacy stake amount to 0, sets the liquid T stake\\n /// amount to 0 and withdraws all liquid T from the stake to the\\n /// owner. Reverts if there is at least one non-zero authorization.\\n /// Can be called only by the delegation owner or the staking\\n /// provider. Can only be called when 24h passed since the stake\\n /// has been delegated.\\n function unstakeAll(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n stakingProviderStruct.authorizedApplications.length == 0,\\n \\\"Stake still authorized\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n uint96 unstaked = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n emit Unstaked(stakingProvider, unstaked);\\n uint96 amount = stakingProviderStruct.tStake;\\n stakingProviderStruct.tStake = 0;\\n stakingProviderStruct.keepInTStake = 0;\\n stakingProviderStruct.nuInTStake = 0;\\n decreaseStakeCheckpoint(stakingProvider, unstaked);\\n\\n if (amount > 0) {\\n token.safeTransfer(stakingProviderStruct.owner, amount);\\n }\\n }\\n\\n //\\n //\\n // Keeping information in sync\\n //\\n //\\n\\n /// @notice Notifies about the discrepancy between legacy KEEP active stake\\n /// and the amount cached in T staking contract. Slashes the staking\\n /// provider in case the amount cached is higher than the actual\\n /// active stake amount in KEEP staking contract. Needs to update\\n /// authorizations of all affected applications and execute an\\n /// involuntary authorization decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyKeepStakeDiscrepancy(address stakingProvider)\\n external\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(stakingProviderStruct.keepInTStake > 0, \\\"Nothing to slash\\\");\\n\\n (uint256 keepStakeAmount, , uint256 undelegatedAt) = keepStakingContract\\n .getDelegationInfo(stakingProvider);\\n\\n (uint96 realKeepInTStake, ) = convertToT(keepStakeAmount, keepRatio);\\n uint96 oldKeepInTStake = stakingProviderStruct.keepInTStake;\\n\\n require(\\n oldKeepInTStake > realKeepInTStake || undelegatedAt != 0,\\n \\\"There is no discrepancy\\\"\\n );\\n stakingProviderStruct.keepInTStake = realKeepInTStake;\\n seizeKeep(\\n stakingProviderStruct,\\n stakingProvider,\\n stakeDiscrepancyPenalty,\\n stakeDiscrepancyRewardMultiplier\\n );\\n\\n uint96 slashedAmount = realKeepInTStake -\\n stakingProviderStruct.keepInTStake;\\n emit TokensSeized(stakingProvider, slashedAmount, true);\\n if (undelegatedAt != 0) {\\n stakingProviderStruct.keepInTStake = 0;\\n }\\n\\n decreaseStakeCheckpoint(\\n stakingProvider,\\n oldKeepInTStake - stakingProviderStruct.keepInTStake\\n );\\n\\n authorizationDecrease(\\n stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n }\\n\\n /// @notice Notifies about the discrepancy between legacy NU active stake\\n /// and the amount cached in T staking contract. Slashes the\\n /// staking provider in case the amount cached is higher than the\\n /// actual active stake amount in NU staking contract. Needs to\\n /// update authorizations of all affected applications and execute an\\n /// involuntary authorization decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n /// @dev Real discrepancy between T and Nu is impossible.\\n /// This method is a safeguard in case of bugs in NuCypher staking\\n /// contract\\n function notifyNuStakeDiscrepancy(address stakingProvider)\\n external\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(stakingProviderStruct.nuInTStake > 0, \\\"Nothing to slash\\\");\\n\\n uint256 nuStakeAmount = nucypherStakingContract.getAllTokens(\\n stakingProviderStruct.owner\\n );\\n (uint96 realNuInTStake, ) = convertToT(nuStakeAmount, nucypherRatio);\\n uint96 oldNuInTStake = stakingProviderStruct.nuInTStake;\\n require(oldNuInTStake > realNuInTStake, \\\"There is no discrepancy\\\");\\n\\n stakingProviderStruct.nuInTStake = realNuInTStake;\\n seizeNu(\\n stakingProviderStruct,\\n stakeDiscrepancyPenalty,\\n stakeDiscrepancyRewardMultiplier\\n );\\n\\n uint96 slashedAmount = realNuInTStake -\\n stakingProviderStruct.nuInTStake;\\n emit TokensSeized(stakingProvider, slashedAmount, true);\\n authorizationDecrease(\\n stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n decreaseStakeCheckpoint(\\n stakingProvider,\\n oldNuInTStake - stakingProviderStruct.nuInTStake\\n );\\n }\\n\\n /// @notice Sets the penalty amount for stake discrepancy and reward\\n /// multiplier for reporting it. The penalty is seized from the\\n /// delegated stake, and 5% of the penalty, scaled by the\\n /// multiplier, is given to the notifier. The rest of the tokens are\\n /// burned. Can only be called by the Governance. See `seize` function.\\n function setStakeDiscrepancyPenalty(\\n uint96 penalty,\\n uint256 rewardMultiplier\\n ) external override onlyGovernance {\\n stakeDiscrepancyPenalty = penalty;\\n stakeDiscrepancyRewardMultiplier = rewardMultiplier;\\n emit StakeDiscrepancyPenaltySet(penalty, rewardMultiplier);\\n }\\n\\n /// @notice Sets reward in T tokens for notification of misbehaviour\\n /// of one staking provider. Can only be called by the governance.\\n function setNotificationReward(uint96 reward)\\n external\\n override\\n onlyGovernance\\n {\\n notificationReward = reward;\\n emit NotificationRewardSet(reward);\\n }\\n\\n /// @notice Transfer some amount of T tokens as reward for notifications\\n /// of misbehaviour\\n function pushNotificationReward(uint96 reward) external override {\\n require(reward > 0, \\\"Parameters must be specified\\\");\\n notifiersTreasury += reward;\\n emit NotificationRewardPushed(reward);\\n token.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraw some amount of T tokens from notifiers treasury.\\n /// Can only be called by the governance.\\n function withdrawNotificationReward(address recipient, uint96 amount)\\n external\\n override\\n onlyGovernance\\n {\\n require(amount <= notifiersTreasury, \\\"Not enough tokens\\\");\\n notifiersTreasury -= amount;\\n emit NotificationRewardWithdrawn(recipient, amount);\\n token.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount that should be slashed from each one of them. Can only be\\n /// called by application authorized for all staking providers in\\n /// the array.\\n /// @dev This method doesn't emit events for providers that are added to\\n /// the queue. If necessary events can be added to the application\\n /// level.\\n function slash(uint96 amount, address[] memory _stakingProviders)\\n external\\n override\\n {\\n notify(amount, 0, address(0), _stakingProviders);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each provider from\\n /// notifiers treasury. Can only be called by application\\n /// authorized for all staking providers in the array.\\n /// @dev This method doesn't emit events for staking providers that are\\n /// added to the queue. If necessary events can be added to the\\n /// application level.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) external override {\\n notify(amount, rewardMultiplier, notifier, _stakingProviders);\\n }\\n\\n /// @notice Takes the given number of queued slashing operations and\\n /// processes them. Receives 5% of the slashed amount.\\n /// Executes `involuntaryAuthorizationDecrease` function on each\\n /// affected application.\\n function processSlashing(uint256 count) external virtual override {\\n require(\\n slashingQueueIndex < slashingQueue.length && count > 0,\\n \\\"Nothing to process\\\"\\n );\\n\\n uint256 maxIndex = slashingQueueIndex + count;\\n maxIndex = MathUpgradeable.min(maxIndex, slashingQueue.length);\\n count = maxIndex - slashingQueueIndex;\\n uint96 tAmountToBurn = 0;\\n\\n uint256 index = slashingQueueIndex;\\n for (; index < maxIndex; index++) {\\n SlashingEvent storage slashing = slashingQueue[index];\\n tAmountToBurn += processSlashing(slashing);\\n }\\n slashingQueueIndex = index;\\n\\n uint256 tProcessorReward = uint256(tAmountToBurn).percent(\\n SLASHING_REWARD_PERCENT\\n );\\n notifiersTreasury += tAmountToBurn - tProcessorReward.toUint96();\\n emit SlashingProcessed(msg.sender, count, tProcessorReward);\\n if (tProcessorReward > 0) {\\n token.safeTransfer(msg.sender, tProcessorReward);\\n }\\n }\\n\\n /// @notice Delegate voting power from the stake associated to the\\n /// `stakingProvider` to a `delegatee` address. Caller must be the\\n /// owner of this stake.\\n function delegateVoting(address stakingProvider, address delegatee)\\n external\\n {\\n delegate(stakingProvider, delegatee);\\n }\\n\\n /// @notice Transfers ownership of the contract to `newGuvnor`.\\n function transferGovernance(address newGuvnor)\\n external\\n virtual\\n onlyGovernance\\n {\\n _transferGovernance(newGuvnor);\\n }\\n\\n //\\n //\\n // Auxiliary functions\\n //\\n //\\n\\n /// @notice Returns the authorized stake amount of the staking provider for\\n /// the application.\\n function authorizedStake(address stakingProvider, address application)\\n external\\n view\\n override\\n returns (uint96)\\n {\\n return\\n stakingProviders[stakingProvider]\\n .authorizations[application]\\n .authorized;\\n }\\n\\n /// @notice Returns staked amount of T, Keep and Nu for the specified\\n /// staking provider.\\n /// @dev All values are in T denomination\\n function stakes(address stakingProvider)\\n external\\n view\\n override\\n returns (\\n uint96 tStake,\\n uint96 keepInTStake,\\n uint96 nuInTStake\\n )\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n tStake = stakingProviderStruct.tStake;\\n keepInTStake = stakingProviderStruct.keepInTStake;\\n nuInTStake = stakingProviderStruct.nuInTStake;\\n }\\n\\n /// @notice Returns start staking timestamp.\\n /// @dev This value is set at most once.\\n function getStartStakingTimestamp(address stakingProvider)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return stakingProviders[stakingProvider].startStakingTimestamp;\\n }\\n\\n /// @notice Returns staked amount of NU for the specified staking provider.\\n function stakedNu(address stakingProvider)\\n external\\n view\\n override\\n returns (uint256 nuAmount)\\n {\\n (nuAmount, ) = convertFromT(\\n stakingProviders[stakingProvider].nuInTStake,\\n nucypherRatio\\n );\\n }\\n\\n /// @notice Gets the stake owner, the beneficiary and the authorizer\\n /// for the specified staking provider address.\\n /// @return owner Stake owner address.\\n /// @return beneficiary Beneficiary address.\\n /// @return authorizer Authorizer address.\\n function rolesOf(address stakingProvider)\\n external\\n view\\n override\\n returns (\\n address owner,\\n address payable beneficiary,\\n address authorizer\\n )\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n owner = stakingProviderStruct.owner;\\n beneficiary = stakingProviderStruct.beneficiary;\\n authorizer = stakingProviderStruct.authorizer;\\n }\\n\\n /// @notice Returns length of application array\\n function getApplicationsLength() external view override returns (uint256) {\\n return applications.length;\\n }\\n\\n /// @notice Returns length of slashing queue\\n function getSlashingQueueLength() external view override returns (uint256) {\\n return slashingQueue.length;\\n }\\n\\n /// @notice Requests decrease of the authorization for the given staking\\n /// provider on the given application by the provided amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application if the application agrees for that. If the\\n /// application does not agree for overwriting, the function\\n /// reverts.\\n /// @dev Calls `authorizationDecreaseRequested` callback on the given\\n /// application. See `IApplication`.\\n function requestAuthorizationDecrease(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) public override onlyAuthorizerOf(stakingProvider) {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n\\n AppAuthorization storage authorization = stakingProviders[\\n stakingProvider\\n ].authorizations[application];\\n require(\\n authorization.authorized >= amount,\\n \\\"Amount exceeds authorized\\\"\\n );\\n\\n authorization.deauthorizing = amount;\\n uint96 deauthorizingTo = authorization.authorized - amount;\\n emit AuthorizationDecreaseRequested(\\n stakingProvider,\\n application,\\n authorization.authorized,\\n deauthorizingTo\\n );\\n IApplication(application).authorizationDecreaseRequested(\\n stakingProvider,\\n authorization.authorized,\\n deauthorizingTo\\n );\\n }\\n\\n /// @notice Returns minimum possible stake for T, KEEP or NU in T denomination\\n /// @dev For example, suppose the given staking provider has 10 T, 20 T worth\\n /// of KEEP, and 30 T worth of NU all staked, and the maximum\\n /// application authorization is 40 T, then `getMinStaked` for\\n /// that staking provider returns:\\n /// * 0 T if KEEP stake type specified i.e.\\n /// min = 40 T max - (10 T + 30 T worth of NU) = 0 T\\n /// * 10 T if NU stake type specified i.e.\\n /// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T\\n /// * 0 T if T stake type specified i.e.\\n /// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T\\n /// In other words, the minimum stake amount for the specified\\n /// stake type is the minimum amount of stake of the given type\\n /// needed to satisfy the maximum application authorization given\\n /// the staked amounts of the other stake types for that staking\\n /// provider.\\n function getMinStaked(address stakingProvider, StakeType stakeTypes)\\n public\\n view\\n override\\n returns (uint96)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint256 maxAuthorization = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address application = stakingProviderStruct.authorizedApplications[\\n i\\n ];\\n maxAuthorization = MathUpgradeable.max(\\n maxAuthorization,\\n stakingProviderStruct.authorizations[application].authorized\\n );\\n }\\n\\n if (maxAuthorization == 0) {\\n return 0;\\n }\\n if (stakeTypes != StakeType.T) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.tStake\\n );\\n }\\n if (stakeTypes != StakeType.NU) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.nuInTStake\\n );\\n }\\n if (stakeTypes != StakeType.KEEP) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.keepInTStake\\n );\\n }\\n return maxAuthorization.toUint96();\\n }\\n\\n /// @notice Returns available amount to authorize for the specified\\n /// application.\\n function getAvailableToAuthorize(\\n address stakingProvider,\\n address application\\n ) public view override returns (uint96 availableTValue) {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n availableTValue =\\n stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n availableTValue -= stakingProviderStruct\\n .authorizations[application]\\n .authorized;\\n }\\n\\n /// @notice Delegate voting power from the stake associated to the\\n /// `stakingProvider` to a `delegatee` address. Caller must be the owner\\n /// of this stake.\\n /// @dev Original abstract function defined in Checkpoints contract had two\\n /// parameters, `delegator` and `delegatee`. Here we override it and\\n /// comply with the same signature but the semantics of the first\\n /// parameter changes to the `stakingProvider` address.\\n function delegate(address stakingProvider, address delegatee)\\n internal\\n virtual\\n override\\n onlyOwnerOf(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 stakingProviderBalance = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n address oldDelegatee = delegates(stakingProvider);\\n _delegates[stakingProvider] = delegatee;\\n emit DelegateChanged(stakingProvider, oldDelegatee, delegatee);\\n moveVotingPower(oldDelegatee, delegatee, stakingProviderBalance);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each staking\\n /// provider from notifiers treasury. Can only be called by\\n /// application authorized for all staking providers in the array.\\n function notify(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) internal {\\n require(\\n amount > 0 && _stakingProviders.length > 0,\\n \\\"Parameters must be specified\\\"\\n );\\n\\n ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n uint256 queueLength = slashingQueue.length;\\n for (uint256 i = 0; i < _stakingProviders.length; i++) {\\n address stakingProvider = _stakingProviders[i];\\n uint256 amountToSlash = MathUpgradeable.min(\\n stakingProviders[stakingProvider]\\n .authorizations[msg.sender]\\n .authorized,\\n amount\\n );\\n if (\\n //slither-disable-next-line incorrect-equality\\n amountToSlash == 0\\n ) {\\n continue;\\n }\\n slashingQueue.push(\\n SlashingEvent(stakingProvider, amountToSlash.toUint96())\\n );\\n }\\n\\n if (notifier != address(0)) {\\n uint256 reward = ((slashingQueue.length - queueLength) *\\n notificationReward).percent(rewardMultiplier);\\n reward = MathUpgradeable.min(reward, notifiersTreasury);\\n emit NotifierRewarded(notifier, reward);\\n if (reward != 0) {\\n notifiersTreasury -= reward;\\n token.safeTransfer(notifier, reward);\\n }\\n }\\n }\\n\\n /// @notice Processes one specified slashing event.\\n /// Executes `involuntaryAuthorizationDecrease` function on each\\n /// affected application.\\n //slither-disable-next-line dead-code\\n function processSlashing(SlashingEvent storage slashing)\\n internal\\n returns (uint96 tAmountToBurn)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n slashing.stakingProvider\\n ];\\n uint96 tAmountToSlash = slashing.amount;\\n uint96 oldStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n // slash T\\n if (stakingProviderStruct.tStake > 0) {\\n if (tAmountToSlash <= stakingProviderStruct.tStake) {\\n tAmountToBurn = tAmountToSlash;\\n } else {\\n tAmountToBurn = stakingProviderStruct.tStake;\\n }\\n stakingProviderStruct.tStake -= tAmountToBurn;\\n tAmountToSlash -= tAmountToBurn;\\n }\\n\\n // slash KEEP\\n if (tAmountToSlash > 0 && stakingProviderStruct.keepInTStake > 0) {\\n (uint256 keepStakeAmount, , ) = keepStakingContract\\n .getDelegationInfo(slashing.stakingProvider);\\n (uint96 tAmount, ) = convertToT(keepStakeAmount, keepRatio);\\n stakingProviderStruct.keepInTStake = tAmount;\\n\\n tAmountToSlash = seizeKeep(\\n stakingProviderStruct,\\n slashing.stakingProvider,\\n tAmountToSlash,\\n 100\\n );\\n }\\n\\n // slash NU\\n if (tAmountToSlash > 0 && stakingProviderStruct.nuInTStake > 0) {\\n // synchronization skipped due to impossibility of real discrepancy\\n tAmountToSlash = seizeNu(\\n stakingProviderStruct,\\n tAmountToSlash,\\n 100\\n );\\n }\\n\\n uint96 slashedAmount = slashing.amount - tAmountToSlash;\\n emit TokensSeized(slashing.stakingProvider, slashedAmount, false);\\n authorizationDecrease(\\n slashing.stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n uint96 newStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n decreaseStakeCheckpoint(slashing.stakingProvider, oldStake - newStake);\\n }\\n\\n /// @notice Synchronize authorizations (if needed) after slashing stake\\n function authorizationDecrease(\\n address stakingProvider,\\n StakingProviderInfo storage stakingProviderStruct,\\n uint96 slashedAmount\\n ) internal {\\n uint96 totalStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.nuInTStake +\\n stakingProviderStruct.keepInTStake;\\n uint256 applicationsToDelete = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address authorizedApplication = stakingProviderStruct\\n .authorizedApplications[i];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[authorizedApplication];\\n uint96 fromAmount = authorization.authorized;\\n\\n authorization.authorized -= MathUpgradeable\\n .min(fromAmount, slashedAmount)\\n .toUint96();\\n\\n if (authorization.authorized > totalStake) {\\n authorization.authorized = totalStake;\\n }\\n\\n bool successful = true;\\n //slither-disable-next-line calls-loop\\n try\\n IApplication(authorizedApplication)\\n .involuntaryAuthorizationDecrease{\\n gas: GAS_LIMIT_AUTHORIZATION_DECREASE\\n }(stakingProvider, fromAmount, authorization.authorized)\\n {} catch {\\n successful = false;\\n }\\n if (authorization.deauthorizing > authorization.authorized) {\\n authorization.deauthorizing = authorization.authorized;\\n }\\n emit AuthorizationInvoluntaryDecreased(\\n stakingProvider,\\n authorizedApplication,\\n fromAmount,\\n authorization.authorized,\\n successful\\n );\\n if (authorization.authorized == 0) {\\n applicationsToDelete++;\\n }\\n }\\n if (applicationsToDelete > 0) {\\n cleanAuthorizedApplications(\\n stakingProviderStruct,\\n applicationsToDelete\\n );\\n }\\n }\\n\\n /// @notice Convert amount from T to Keep and call `seize` in Keep staking contract.\\n /// Returns remainder of slashing amount in T\\n /// @dev Note this internal function doesn't update stake checkpoints\\n function seizeKeep(\\n StakingProviderInfo storage stakingProviderStruct,\\n address stakingProvider,\\n uint96 tAmountToSlash,\\n uint256 rewardMultiplier\\n ) internal returns (uint96) {\\n if (stakingProviderStruct.keepInTStake == 0) {\\n return tAmountToSlash;\\n }\\n\\n uint96 tPenalty;\\n if (tAmountToSlash <= stakingProviderStruct.keepInTStake) {\\n tPenalty = tAmountToSlash;\\n } else {\\n tPenalty = stakingProviderStruct.keepInTStake;\\n }\\n\\n (uint256 keepPenalty, uint96 tRemainder) = convertFromT(\\n tPenalty,\\n keepRatio\\n );\\n if (keepPenalty == 0) {\\n return tAmountToSlash;\\n }\\n tPenalty -= tRemainder;\\n stakingProviderStruct.keepInTStake -= tPenalty;\\n tAmountToSlash -= tPenalty;\\n\\n address[] memory stakingProviderWrapper = new address[](1);\\n stakingProviderWrapper[0] = stakingProvider;\\n keepStakingContract.seize(\\n keepPenalty,\\n rewardMultiplier,\\n msg.sender,\\n stakingProviderWrapper\\n );\\n return tAmountToSlash;\\n }\\n\\n /// @notice Convert amount from T to NU and call `slashStaker` in NuCypher staking contract.\\n /// Returns remainder of slashing amount in T\\n /// @dev Note this internal function doesn't update the stake checkpoints\\n function seizeNu(\\n StakingProviderInfo storage stakingProviderStruct,\\n uint96 tAmountToSlash,\\n uint256 rewardMultiplier\\n ) internal returns (uint96) {\\n if (stakingProviderStruct.nuInTStake == 0) {\\n return tAmountToSlash;\\n }\\n\\n uint96 tPenalty;\\n if (tAmountToSlash <= stakingProviderStruct.nuInTStake) {\\n tPenalty = tAmountToSlash;\\n } else {\\n tPenalty = stakingProviderStruct.nuInTStake;\\n }\\n\\n (uint256 nuPenalty, uint96 tRemainder) = convertFromT(\\n tPenalty,\\n nucypherRatio\\n );\\n if (nuPenalty == 0) {\\n return tAmountToSlash;\\n }\\n tPenalty -= tRemainder;\\n stakingProviderStruct.nuInTStake -= tPenalty;\\n tAmountToSlash -= tPenalty;\\n\\n uint256 nuReward = nuPenalty.percent(SLASHING_REWARD_PERCENT).percent(\\n rewardMultiplier\\n );\\n nucypherStakingContract.slashStaker(\\n stakingProviderStruct.owner,\\n nuPenalty,\\n msg.sender,\\n nuReward\\n );\\n return tAmountToSlash;\\n }\\n\\n /// @notice Removes application with zero authorization from authorized\\n /// applications array\\n function cleanAuthorizedApplications(\\n StakingProviderInfo storage stakingProviderStruct,\\n uint256 numberToDelete\\n ) internal {\\n uint256 length = stakingProviderStruct.authorizedApplications.length;\\n if (numberToDelete == length) {\\n delete stakingProviderStruct.authorizedApplications;\\n return;\\n }\\n\\n uint256 deleted = 0;\\n uint256 index = 0;\\n uint256 newLength = length - numberToDelete;\\n while (index < newLength && deleted < numberToDelete) {\\n address application = stakingProviderStruct.authorizedApplications[\\n index\\n ];\\n if (\\n stakingProviderStruct.authorizations[application].authorized ==\\n 0\\n ) {\\n stakingProviderStruct.authorizedApplications[\\n index\\n ] = stakingProviderStruct.authorizedApplications[\\n length - deleted - 1\\n ];\\n deleted++;\\n } else {\\n index++;\\n }\\n }\\n\\n for (index = newLength; index < length; index++) {\\n stakingProviderStruct.authorizedApplications.pop();\\n }\\n }\\n\\n /// @notice Creates new checkpoints due to a change of stake amount\\n /// @param _delegator Address of the staking provider acting as delegator\\n /// @param _amount Amount of T to increment\\n /// @param increase True if the change is an increase, false if a decrease\\n function newStakeCheckpoint(\\n address _delegator,\\n uint96 _amount,\\n bool increase\\n ) internal {\\n if (_amount == 0) {\\n return;\\n }\\n writeCheckpoint(\\n _totalSupplyCheckpoints,\\n increase ? add : subtract,\\n _amount\\n );\\n address delegatee = delegates(_delegator);\\n if (delegatee != address(0)) {\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[delegatee],\\n increase ? add : subtract,\\n _amount\\n );\\n emit DelegateVotesChanged(delegatee, oldWeight, newWeight);\\n }\\n }\\n\\n /// @notice Creates new checkpoints due to an increment of a stakers' stake\\n /// @param _delegator Address of the staking provider acting as delegator\\n /// @param _amount Amount of T to increment\\n function increaseStakeCheckpoint(address _delegator, uint96 _amount)\\n internal\\n {\\n newStakeCheckpoint(_delegator, _amount, true);\\n }\\n\\n /// @notice Creates new checkpoints due to a decrease of a stakers' stake\\n /// @param _delegator Address of the stake owner acting as delegator\\n /// @param _amount Amount of T to decrease\\n function decreaseStakeCheckpoint(address _delegator, uint96 _amount)\\n internal\\n {\\n newStakeCheckpoint(_delegator, _amount, false);\\n }\\n\\n /// @notice Returns amount of Nu stake in the NuCypher staking contract for\\n /// the specified staking provider.\\n /// Resulting value in T denomination\\n function getNuAmountInT(address owner, address stakingProvider)\\n internal\\n returns (uint96)\\n {\\n uint256 nuStakeAmount = nucypherStakingContract.requestMerge(\\n owner,\\n stakingProvider\\n );\\n (uint96 tAmount, ) = convertToT(nuStakeAmount, nucypherRatio);\\n return tAmount;\\n }\\n\\n function _transferGovernance(address newGuvnor) internal virtual {\\n address oldGuvnor = governance;\\n governance = newGuvnor;\\n emit GovernanceTransferred(oldGuvnor, newGuvnor);\\n }\\n\\n /// @notice Returns amount of Keep stake in the Keep staking contract for\\n /// the specified staking provider.\\n /// Resulting value in T denomination\\n function getKeepAmountInT(address stakingProvider)\\n internal\\n view\\n returns (uint96)\\n {\\n uint256 keepStakeAmount = keepStakingContract.eligibleStake(\\n stakingProvider,\\n address(this)\\n );\\n (uint96 tAmount, ) = convertToT(keepStakeAmount, keepRatio);\\n return tAmount;\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` legacy\\n /// tokens for the given `ratio`, and the remainder that can't be\\n /// converted.\\n function convertToT(uint256 amount, uint256 ratio)\\n internal\\n pure\\n returns (uint96 tAmount, uint256 remainder)\\n {\\n remainder = amount % CONVERSION_DIVISOR;\\n uint256 convertibleAmount = amount - remainder;\\n tAmount = ((convertibleAmount * ratio) / CONVERSION_DIVISOR).toUint96();\\n }\\n\\n /// @notice Returns the amount of legacy tokens that's obtained from\\n /// `tAmount` T tokens for the given `ratio`, and the T remainder\\n /// that can't be converted.\\n function convertFromT(uint96 tAmount, uint256 ratio)\\n internal\\n pure\\n returns (uint256 amount, uint96 tRemainder)\\n {\\n //slither-disable-next-line weak-prng\\n tRemainder = (tAmount % ratio).toUint96();\\n uint256 convertibleAmount = tAmount - tRemainder;\\n amount = (convertibleAmount * CONVERSION_DIVISOR) / ratio;\\n }\\n}\\n\",\"keccak256\":\"0x148ee3dfe800335504a81d87af4d5d32e8deb895824661b4483e9c5822dfe9f9\",\"license\":\"GPL-3.0-or-later\"},\"contracts/test/TokenStakingTestSet.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"../staking/ILegacyTokenStaking.sol\\\";\\nimport \\\"../staking/IApplication.sol\\\";\\nimport \\\"../staking/TokenStaking.sol\\\";\\n\\ncontract KeepTokenStakingMock is IKeepTokenStaking {\\n using PercentUtils for uint256;\\n\\n struct OperatorStruct {\\n address owner;\\n address payable beneficiary;\\n address authorizer;\\n uint256 createdAt;\\n uint256 undelegatedAt;\\n uint256 amount;\\n mapping(address => bool) eligibility;\\n }\\n\\n mapping(address => OperatorStruct) internal operators;\\n mapping(address => uint256) public tattletales;\\n\\n function setOperator(\\n address operator,\\n address owner,\\n address payable beneficiary,\\n address authorizer,\\n uint256 createdAt,\\n uint256 undelegatedAt,\\n uint256 amount\\n ) external {\\n OperatorStruct storage operatorStrut = operators[operator];\\n operatorStrut.owner = owner;\\n operatorStrut.beneficiary = beneficiary;\\n operatorStrut.authorizer = authorizer;\\n operatorStrut.createdAt = createdAt;\\n operatorStrut.undelegatedAt = undelegatedAt;\\n operatorStrut.amount = amount;\\n }\\n\\n function setEligibility(\\n address operator,\\n address application,\\n bool isEligible\\n ) external {\\n operators[operator].eligibility[application] = isEligible;\\n }\\n\\n function setAmount(address operator, uint256 amount) external {\\n operators[operator].amount = amount;\\n }\\n\\n function setUndelegatedAt(address operator, uint256 undelegatedAt)\\n external\\n {\\n operators[operator].undelegatedAt = undelegatedAt;\\n }\\n\\n function seize(\\n uint256 amountToSeize,\\n uint256 rewardMultiplier,\\n address tattletale,\\n address[] memory misbehavedOperators\\n ) external override {\\n require(amountToSeize > 0, \\\"Amount to slash must be greater than zero\\\");\\n // assumed only one will be slashed (per call)\\n require(\\n misbehavedOperators.length == 1,\\n \\\"Only one operator per call in tests\\\"\\n );\\n address operator = misbehavedOperators[0];\\n operators[operator].amount -= amountToSeize;\\n tattletales[tattletale] += amountToSeize.percent(5).percent(\\n rewardMultiplier\\n );\\n }\\n\\n function getDelegationInfo(address operator)\\n external\\n view\\n override\\n returns (\\n uint256 amount,\\n uint256 createdAt,\\n uint256 undelegatedAt\\n )\\n {\\n amount = operators[operator].amount;\\n createdAt = operators[operator].createdAt;\\n undelegatedAt = operators[operator].undelegatedAt;\\n }\\n\\n function ownerOf(address operator)\\n external\\n view\\n override\\n returns (address)\\n {\\n return operators[operator].owner;\\n }\\n\\n function beneficiaryOf(address operator)\\n external\\n view\\n override\\n returns (address payable)\\n {\\n return operators[operator].beneficiary;\\n }\\n\\n function authorizerOf(address operator)\\n external\\n view\\n override\\n returns (address)\\n {\\n return operators[operator].authorizer;\\n }\\n\\n function eligibleStake(address operator, address operatorContract)\\n external\\n view\\n override\\n returns (uint256 balance)\\n {\\n OperatorStruct storage operatorStrut = operators[operator];\\n if (operatorStrut.eligibility[operatorContract]) {\\n return operatorStrut.amount;\\n }\\n return 0;\\n }\\n}\\n\\ncontract NuCypherTokenStakingMock is INuCypherStakingEscrow {\\n struct StakerStruct {\\n uint256 value;\\n address stakingProvider;\\n }\\n\\n mapping(address => StakerStruct) public stakers;\\n mapping(address => uint256) public investigators;\\n\\n function setStaker(address staker, uint256 value) external {\\n stakers[staker].value = value;\\n }\\n\\n function slashStaker(\\n address staker,\\n uint256 penalty,\\n address investigator,\\n uint256 reward\\n ) external override {\\n require(penalty > 0, \\\"Amount to slash must be greater than zero\\\");\\n stakers[staker].value -= penalty;\\n investigators[investigator] += reward;\\n }\\n\\n function requestMerge(address staker, address stakingProvider)\\n external\\n override\\n returns (uint256)\\n {\\n StakerStruct storage stakerStruct = stakers[staker];\\n require(\\n stakerStruct.stakingProvider == address(0) ||\\n stakerStruct.stakingProvider == stakingProvider,\\n \\\"Another provider was already set for this staker\\\"\\n );\\n if (stakerStruct.stakingProvider == address(0)) {\\n stakerStruct.stakingProvider = stakingProvider;\\n }\\n return stakers[staker].value;\\n }\\n\\n function getAllTokens(address staker)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return stakers[staker].value;\\n }\\n\\n function stakerInfo(address staker)\\n public\\n view\\n returns (StakerStruct memory)\\n {\\n return stakers[staker];\\n }\\n}\\n\\ncontract VendingMachineMock {\\n uint256 public constant FLOATING_POINT_DIVISOR = 10**15;\\n\\n uint256 public immutable ratio;\\n\\n constructor(uint96 _wrappedTokenAllocation, uint96 _tTokenAllocation) {\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n}\\n\\ncontract ApplicationMock is IApplication {\\n struct StakingProviderStruct {\\n uint96 authorized;\\n uint96 deauthorizingTo;\\n }\\n\\n TokenStaking internal immutable tokenStaking;\\n mapping(address => StakingProviderStruct) public stakingProviders;\\n\\n constructor(TokenStaking _tokenStaking) {\\n tokenStaking = _tokenStaking;\\n }\\n\\n function withdrawRewards(address) external {\\n // does nothing\\n }\\n\\n function authorizationIncreased(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) external override {\\n stakingProviders[stakingProvider].authorized = toAmount;\\n }\\n\\n function authorizationDecreaseRequested(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) external override {\\n stakingProviders[stakingProvider].deauthorizingTo = toAmount;\\n }\\n\\n function approveAuthorizationDecrease(address stakingProvider) external {\\n StakingProviderStruct storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n stakingProviderStruct.authorized = tokenStaking\\n .approveAuthorizationDecrease(stakingProvider);\\n }\\n\\n function slash(uint96 amount, address[] memory _stakingProviders) external {\\n tokenStaking.slash(amount, _stakingProviders);\\n }\\n\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) external {\\n tokenStaking.seize(\\n amount,\\n rewardMultiplier,\\n notifier,\\n _stakingProviders\\n );\\n }\\n\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) public virtual override {\\n StakingProviderStruct storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n toAmount != stakingProviderStruct.authorized,\\n \\\"Nothing to decrease\\\"\\n );\\n uint96 decrease = stakingProviderStruct.authorized - toAmount;\\n if (stakingProviderStruct.deauthorizingTo > decrease) {\\n stakingProviderStruct.deauthorizingTo -= decrease;\\n } else {\\n stakingProviderStruct.deauthorizingTo = 0;\\n }\\n stakingProviderStruct.authorized = toAmount;\\n }\\n\\n function availableRewards(address) external pure returns (uint96) {\\n return 0;\\n }\\n\\n function minimumAuthorization() external pure returns (uint96) {\\n return 0;\\n }\\n}\\n\\ncontract BrokenApplicationMock is ApplicationMock {\\n constructor(TokenStaking _tokenStaking) ApplicationMock(_tokenStaking) {}\\n\\n function involuntaryAuthorizationDecrease(\\n address,\\n uint96,\\n uint96\\n ) public pure override {\\n revert(\\\"Broken application\\\");\\n }\\n}\\n\\ncontract ExpensiveApplicationMock is ApplicationMock {\\n uint256[] private dummy;\\n\\n constructor(TokenStaking _tokenStaking) ApplicationMock(_tokenStaking) {}\\n\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) public override {\\n super.involuntaryAuthorizationDecrease(\\n stakingProvider,\\n fromAmount,\\n toAmount\\n );\\n for (uint256 i = 0; i < 12; i++) {\\n dummy.push(i);\\n }\\n }\\n}\\n\\ncontract ManagedGrantMock {\\n address public grantee;\\n\\n //slither-disable-next-line missing-zero-check\\n function setGrantee(address _grantee) external {\\n grantee = _grantee;\\n }\\n}\\n\\ncontract ExtendedTokenStaking is TokenStaking {\\n constructor(\\n T _token,\\n IKeepTokenStaking _keepStakingContract,\\n INuCypherStakingEscrow _nucypherStakingContract,\\n VendingMachine _keepVendingMachine,\\n VendingMachine _nucypherVendingMachine,\\n KeepStake _keepStake\\n )\\n TokenStaking(\\n _token,\\n _keepStakingContract,\\n _nucypherStakingContract,\\n _keepVendingMachine,\\n _nucypherVendingMachine,\\n _keepStake\\n )\\n {}\\n\\n function cleanAuthorizedApplications(\\n address stakingProvider,\\n uint256 numberToDelete\\n ) external {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n cleanAuthorizedApplications(stakingProviderStruct, numberToDelete);\\n }\\n\\n function setAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external {\\n stakingProviders[stakingProvider]\\n .authorizations[application]\\n .authorized = amount;\\n }\\n\\n function setAuthorizedApplications(\\n address stakingProvider,\\n address[] memory _applications\\n ) external {\\n stakingProviders[stakingProvider]\\n .authorizedApplications = _applications;\\n }\\n\\n // to decrease size of test contract\\n function processSlashing(uint256 count) external override {}\\n\\n function getAuthorizedApplications(address stakingProvider)\\n external\\n view\\n returns (address[] memory)\\n {\\n return stakingProviders[stakingProvider].authorizedApplications;\\n }\\n}\\n\",\"keccak256\":\"0x55bd1a8dc0c354ff3be00489028bd31f95fbf8c75a2c28a41f1b2466a7f955be\",\"license\":\"GPL-3.0-or-later\"},\"contracts/token/T.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 \\\"../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\",\"keccak256\":\"0x6265416225fd15b1108fce13d570b53a862a5d256ba2e6329bccf658eccac430\",\"license\":\"GPL-3.0-or-later\"},\"contracts/utils/PercentUtils.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\\nlibrary PercentUtils {\\n // Return `b`% of `a`\\n // 200.percent(40) == 80\\n // Commutative, works both ways\\n function percent(uint256 a, uint256 b) internal pure returns (uint256) {\\n return (a * b) / 100;\\n }\\n\\n // Return `a` as percentage of `b`:\\n // 80.asPercentOf(200) == 40\\n //slither-disable-next-line dead-code\\n function asPercentOf(uint256 a, uint256 b) internal pure returns (uint256) {\\n return (a * 100) / b;\\n }\\n}\\n\",\"keccak256\":\"0xf5feadeff9d504b33058dfd6c2b99d31ecebc152b356272646a7afe6ed638d40\",\"license\":\"GPL-3.0-or-later\"},\"contracts/utils/SafeTUpgradeable.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 \\\"../token/T.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\n/// @notice A wrapper around OpenZeppelin's `SafeERC20Upgradeable` but specific\\n/// to the T token. Use this library in upgradeable contracts. If your\\n/// contract is non-upgradeable, then the traditional `SafeERC20` works.\\n/// The motivation is to prevent upgradeable contracts that use T from\\n/// depending on the `Address` library, which can be problematic since\\n/// it uses `delegatecall`, which is discouraged by OpenZeppelin for use\\n/// in upgradeable contracts.\\n/// @dev This implementation force-casts T to `IERC20Upgradeable` to make it\\n/// work with `SafeERC20Upgradeable`.\\nlibrary SafeTUpgradeable {\\n function safeTransfer(\\n T token,\\n address to,\\n uint256 value\\n ) internal {\\n SafeERC20Upgradeable.safeTransfer(\\n IERC20Upgradeable(address(token)),\\n to,\\n value\\n );\\n }\\n\\n function safeTransferFrom(\\n T token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n SafeERC20Upgradeable.safeTransferFrom(\\n IERC20Upgradeable(address(token)),\\n from,\\n to,\\n value\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf53907099650f9f973ff51c403730e7ae7170a5728fbde49f0f00b0a17775ce7\",\"license\":\"GPL-3.0-or-later\"},\"contracts/vending/VendingMachine.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 \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\nimport \\\"../token/T.sol\\\";\\n\\n/// @title T token vending machine\\n/// @notice Contract implements a special update protocol to enable KEEP/NU\\n/// token holders to wrap their tokens and obtain T tokens according\\n/// to a fixed ratio. This will go on indefinitely and enable NU and\\n/// KEEP token holders to join T network without needing to buy or\\n/// sell any assets. Logistically, anyone holding NU or KEEP can wrap\\n/// those assets in order to upgrade to T. They can also unwrap T in\\n/// order to downgrade back to the underlying asset. There is a separate\\n/// instance of this contract deployed for KEEP holders and a separate\\n/// instance of this contract deployed for NU holders.\\ncontract VendingMachine is IReceiveApproval {\\n using SafeERC20 for IERC20;\\n using SafeERC20 for T;\\n\\n /// @notice Number of decimal places of precision in conversion to/from\\n /// wrapped tokens (assuming typical ERC20 token with 18 decimals).\\n /// This implies that amounts of wrapped tokens below this precision\\n /// won't take part in the conversion. E.g., for a value of 3, then\\n /// for a conversion of 1.123456789 wrapped tokens, only 1.123 is\\n /// convertible (i.e., 3 decimal places), and 0.000456789 is left.\\n uint256 public constant WRAPPED_TOKEN_CONVERSION_PRECISION = 3;\\n\\n /// @notice Divisor for precision purposes, used to represent fractions.\\n uint256 public constant FLOATING_POINT_DIVISOR =\\n 10**(18 - WRAPPED_TOKEN_CONVERSION_PRECISION);\\n\\n /// @notice The token being wrapped to T (KEEP/NU).\\n IERC20 public immutable wrappedToken;\\n\\n /// @notice T token contract.\\n T public immutable tToken;\\n\\n /// @notice The ratio with which T token is converted based on the provided\\n /// token being wrapped (KEEP/NU), expressed in 1e18 precision.\\n ///\\n /// When wrapping:\\n /// x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR\\n ///\\n /// When unwrapping:\\n /// x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\\n uint256 public immutable ratio;\\n\\n /// @notice The total balance of wrapped tokens for the given holder\\n /// account. Only holders that have previously wrapped KEEP/NU to T\\n /// can unwrap, up to the amount previously wrapped.\\n mapping(address => uint256) public wrappedBalance;\\n\\n event Wrapped(\\n address indexed recipient,\\n uint256 wrappedTokenAmount,\\n uint256 tTokenAmount\\n );\\n event Unwrapped(\\n address indexed recipient,\\n uint256 tTokenAmount,\\n uint256 wrappedTokenAmount\\n );\\n\\n /// @notice Sets the reference to `wrappedToken` and `tToken`. Initializes\\n /// conversion `ratio` between wrapped token and T based on the\\n /// provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\\n /// @param _wrappedToken Address to ERC20 token that will be wrapped to T\\n /// @param _tToken Address of T token\\n /// @param _wrappedTokenAllocation The total supply of the token that will be\\n /// wrapped to T\\n /// @param _tTokenAllocation The allocation of T this instance of Vending\\n /// Machine will receive\\n /// @dev Multiplications in this contract can't overflow uint256 as we\\n /// restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to\\n /// 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\\n constructor(\\n IERC20 _wrappedToken,\\n T _tToken,\\n uint96 _wrappedTokenAllocation,\\n uint96 _tTokenAllocation\\n ) {\\n wrappedToken = _wrappedToken;\\n tToken = _tToken;\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n\\n /// @notice Wraps up to the the given `amount` of the token (KEEP/NU) and\\n /// releases T token proportionally to the amount being wrapped with\\n /// respect to the wrap ratio. The token holder needs to have at\\n /// least the given amount of the wrapped token (KEEP/NU) approved\\n /// to transfer to the Vending Machine before calling this function.\\n /// @param amount The amount of KEEP/NU to be wrapped\\n function wrap(uint256 amount) external {\\n _wrap(msg.sender, amount);\\n }\\n\\n /// @notice Wraps up to the given amount of the token (KEEP/NU) and releases\\n /// T token proportionally to the amount being wrapped with respect\\n /// to the wrap ratio. This is a shortcut to `wrap` function that\\n /// avoids a separate approval transaction. Only KEEP/NU token\\n /// is allowed as a caller, so please call this function via\\n /// token's `approveAndCall`.\\n /// @param from Caller's address, must be the same as `wrappedToken` field\\n /// @param amount The amount of KEEP/NU to be wrapped\\n /// @param token Token's address, must be the same as `wrappedToken` field\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(\\n token == address(wrappedToken),\\n \\\"Token is not the wrapped token\\\"\\n );\\n require(\\n msg.sender == address(wrappedToken),\\n \\\"Only wrapped token caller allowed\\\"\\n );\\n _wrap(from, amount);\\n }\\n\\n /// @notice Unwraps up to the given `amount` of T back to the legacy token\\n /// (KEEP/NU) according to the wrap ratio. It can only be called by\\n /// a token holder who previously wrapped their tokens in this\\n /// vending machine contract. The token holder can't unwrap more\\n /// tokens than they originally wrapped. The token holder needs to\\n /// have at least the given amount of T tokens approved to transfer\\n /// to the Vending Machine before calling this function.\\n /// @param amount The amount of T to unwrap back to the collateral (KEEP/NU)\\n function unwrap(uint256 amount) external {\\n _unwrap(msg.sender, amount);\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` wrapped\\n /// tokens (KEEP/NU), and the remainder that can't be upgraded.\\n function conversionToT(uint256 amount)\\n public\\n view\\n returns (uint256 tAmount, uint256 wrappedRemainder)\\n {\\n wrappedRemainder = amount % FLOATING_POINT_DIVISOR;\\n uint256 convertibleAmount = amount - wrappedRemainder;\\n tAmount = (convertibleAmount * ratio) / FLOATING_POINT_DIVISOR;\\n }\\n\\n /// @notice The amount of wrapped tokens (KEEP/NU) that's obtained from\\n /// `amount` T tokens, and the remainder that can't be downgraded.\\n function conversionFromT(uint256 amount)\\n public\\n view\\n returns (uint256 wrappedAmount, uint256 tRemainder)\\n {\\n tRemainder = amount % ratio;\\n uint256 convertibleAmount = amount - tRemainder;\\n wrappedAmount = (convertibleAmount * FLOATING_POINT_DIVISOR) / ratio;\\n }\\n\\n function _wrap(address tokenHolder, uint256 wrappedTokenAmount) internal {\\n (uint256 tTokenAmount, uint256 remainder) = conversionToT(\\n wrappedTokenAmount\\n );\\n wrappedTokenAmount -= remainder;\\n require(wrappedTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n emit Wrapped(tokenHolder, wrappedTokenAmount, tTokenAmount);\\n\\n wrappedBalance[tokenHolder] += wrappedTokenAmount;\\n wrappedToken.safeTransferFrom(\\n tokenHolder,\\n address(this),\\n wrappedTokenAmount\\n );\\n tToken.safeTransfer(tokenHolder, tTokenAmount);\\n }\\n\\n function _unwrap(address tokenHolder, uint256 tTokenAmount) internal {\\n (uint256 wrappedTokenAmount, uint256 remainder) = conversionFromT(\\n tTokenAmount\\n );\\n tTokenAmount -= remainder;\\n require(tTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n require(\\n wrappedBalance[tokenHolder] >= wrappedTokenAmount,\\n \\\"Can not unwrap more than previously wrapped\\\"\\n );\\n\\n emit Unwrapped(tokenHolder, tTokenAmount, wrappedTokenAmount);\\n wrappedBalance[tokenHolder] -= wrappedTokenAmount;\\n tToken.safeTransferFrom(tokenHolder, address(this), tTokenAmount);\\n wrappedToken.safeTransfer(tokenHolder, wrappedTokenAmount);\\n }\\n}\\n\",\"keccak256\":\"0xa4e7de5a9063db09b32ca97fa0fb5d8d1cc7b539387d1b44d74d15d3c2ed4134\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506104f7806100206000396000f3fe608060405234801561001057600080fd5b506004361061006d5760003560e01c8063178b6de6146100725780633223ff4b146100ae5780633d4fa8e5146100c15780634e745f1f146100ed5780637da5f6a6146101655780639168ae721461018557806399cc218c146101d2575b600080fd5b61009b6100803660046103b9565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61009b6100bc3660046103db565b6101e5565b6100eb6100cf36600461040e565b6001600160a01b03909116600090815260208190526040902055565b005b6101416100fb3660046103b9565b604080518082018252600080825260209182018190526001600160a01b039384168152808252829020825180840190935280548352600101549092169181019190915290565b60408051825181526020928301516001600160a01b031692810192909252016100a5565b61009b6101733660046103b9565b60016020526000908152604090205481565b6101b56101933660046103b9565b600060208190529081526040902080546001909101546001600160a01b031682565b604080519283526001600160a01b039091166020830152016100a5565b6100eb6101e0366004610438565b6102db565b6001600160a01b038083166000908152602081905260408120600181015491929091161580610223575060018101546001600160a01b038481169116145b61028d5760405162461bcd60e51b815260206004820152603060248201527f416e6f746865722070726f76696465722077617320616c72656164792073657460448201526f103337b9103a3434b99039ba30b5b2b960811b60648201526084015b60405180910390fd5b60018101546001600160a01b03166102bd576001810180546001600160a01b0319166001600160a01b0385161790555b5050506001600160a01b031660009081526020819052604090205490565b6000831161033d5760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f20736c617368206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610284565b6001600160a01b03841660009081526020819052604081208054859290610365908490610492565b90915550506001600160a01b038216600090815260016020526040812080548392906103929084906104a9565b909155505050505050565b80356001600160a01b03811681146103b457600080fd5b919050565b6000602082840312156103cb57600080fd5b6103d48261039d565b9392505050565b600080604083850312156103ee57600080fd5b6103f78361039d565b91506104056020840161039d565b90509250929050565b6000806040838503121561042157600080fd5b61042a8361039d565b946020939093013593505050565b6000806000806080858703121561044e57600080fd5b6104578561039d565b93506020850135925061046c6040860161039d565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b6000828210156104a4576104a461047c565b500390565b600082198211156104bc576104bc61047c565b50019056fea264697066735822122013f334f0e987972deba7121c77cc3fce35892cabbb50474966ec389786a8e67964736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061006d5760003560e01c8063178b6de6146100725780633223ff4b146100ae5780633d4fa8e5146100c15780634e745f1f146100ed5780637da5f6a6146101655780639168ae721461018557806399cc218c146101d2575b600080fd5b61009b6100803660046103b9565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61009b6100bc3660046103db565b6101e5565b6100eb6100cf36600461040e565b6001600160a01b03909116600090815260208190526040902055565b005b6101416100fb3660046103b9565b604080518082018252600080825260209182018190526001600160a01b039384168152808252829020825180840190935280548352600101549092169181019190915290565b60408051825181526020928301516001600160a01b031692810192909252016100a5565b61009b6101733660046103b9565b60016020526000908152604090205481565b6101b56101933660046103b9565b600060208190529081526040902080546001909101546001600160a01b031682565b604080519283526001600160a01b039091166020830152016100a5565b6100eb6101e0366004610438565b6102db565b6001600160a01b038083166000908152602081905260408120600181015491929091161580610223575060018101546001600160a01b038481169116145b61028d5760405162461bcd60e51b815260206004820152603060248201527f416e6f746865722070726f76696465722077617320616c72656164792073657460448201526f103337b9103a3434b99039ba30b5b2b960811b60648201526084015b60405180910390fd5b60018101546001600160a01b03166102bd576001810180546001600160a01b0319166001600160a01b0385161790555b5050506001600160a01b031660009081526020819052604090205490565b6000831161033d5760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f20736c617368206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610284565b6001600160a01b03841660009081526020819052604081208054859290610365908490610492565b90915550506001600160a01b038216600090815260016020526040812080548392906103929084906104a9565b909155505050505050565b80356001600160a01b03811681146103b457600080fd5b919050565b6000602082840312156103cb57600080fd5b6103d48261039d565b9392505050565b600080604083850312156103ee57600080fd5b6103f78361039d565b91506104056020840161039d565b90509250929050565b6000806040838503121561042157600080fd5b61042a8361039d565b946020939093013593505050565b6000806000806080858703121561044e57600080fd5b6104578561039d565b93506020850135925061046c6040860161039d565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b6000828210156104a4576104a461047c565b500390565b600082198211156104bc576104bc61047c565b50019056fea264697066735822122013f334f0e987972deba7121c77cc3fce35892cabbb50474966ec389786a8e67964736f6c63430008090033", "devdoc": { "kind": "dev", "methods": { @@ -219,15 +219,15 @@ "storageLayout": { "storage": [ { - "astId": 17639, + "astId": 17613, "contract": "contracts/test/TokenStakingTestSet.sol:NuCypherTokenStakingMock", "label": "stakers", "offset": 0, "slot": "0", - "type": "t_mapping(t_address,t_struct(StakerStruct)17634_storage)" + "type": "t_mapping(t_address,t_struct(StakerStruct)17608_storage)" }, { - "astId": 17643, + "astId": 17617, "contract": "contracts/test/TokenStakingTestSet.sol:NuCypherTokenStakingMock", "label": "investigators", "offset": 0, @@ -241,12 +241,12 @@ "label": "address", "numberOfBytes": "20" }, - "t_mapping(t_address,t_struct(StakerStruct)17634_storage)": { + "t_mapping(t_address,t_struct(StakerStruct)17608_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct NuCypherTokenStakingMock.StakerStruct)", "numberOfBytes": "32", - "value": "t_struct(StakerStruct)17634_storage" + "value": "t_struct(StakerStruct)17608_storage" }, "t_mapping(t_address,t_uint256)": { "encoding": "mapping", @@ -255,12 +255,12 @@ "numberOfBytes": "32", "value": "t_uint256" }, - "t_struct(StakerStruct)17634_storage": { + "t_struct(StakerStruct)17608_storage": { "encoding": "inplace", "label": "struct NuCypherTokenStakingMock.StakerStruct", "members": [ { - "astId": 17631, + "astId": 17605, "contract": "contracts/test/TokenStakingTestSet.sol:NuCypherTokenStakingMock", "label": "value", "offset": 0, @@ -268,7 +268,7 @@ "type": "t_uint256" }, { - "astId": 17633, + "astId": 17607, "contract": "contracts/test/TokenStakingTestSet.sol:NuCypherTokenStakingMock", "label": "stakingProvider", "offset": 0, diff --git a/src/threshold-ts/staking/dapp-development-goerli-artifacts/NuCypherStakingEscrow.json b/src/threshold-ts/staking/sepolia-artifacts/NuCypherStakingEscrow.json similarity index 50% rename from src/threshold-ts/staking/dapp-development-goerli-artifacts/NuCypherStakingEscrow.json rename to src/threshold-ts/staking/sepolia-artifacts/NuCypherStakingEscrow.json index 70898f28f..99a920252 100644 --- a/src/threshold-ts/staking/dapp-development-goerli-artifacts/NuCypherStakingEscrow.json +++ b/src/threshold-ts/staking/sepolia-artifacts/NuCypherStakingEscrow.json @@ -1,5 +1,5 @@ { - "address": "0x79De893356A479cCfF1a58be92e2247F425fE7a5", + "address": "0x2F85e597BFB6E41242E6604dD95EA2EC3e8ECd63", "abi": [ { "inputs": [ @@ -165,28 +165,28 @@ "type": "function" } ], - "transactionHash": "0x4f9b9d6a6adb27463ff0b1d930ebe9d573bf50ae93f709a73d514ffebf3011bc", + "transactionHash": "0x8191030fd62695c5ebfdd637165c6932ad8e4e6d3b6d392c9d5df2d79fd72ab9", "receipt": { "to": null, - "from": "0xfd42E065d5b128a65d752F11A1dA089f74DBf49A", - "contractAddress": "0x79De893356A479cCfF1a58be92e2247F425fE7a5", - "transactionIndex": 8, - "gasUsed": "327706", + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x2F85e597BFB6E41242E6604dD95EA2EC3e8ECd63", + "transactionIndex": 33, + "gasUsed": "327788", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x39c618af1271d4e6d0f921bad1465b7632cc0617ad241ce1dfc03ee34fd49fd5", - "transactionHash": "0x4f9b9d6a6adb27463ff0b1d930ebe9d573bf50ae93f709a73d514ffebf3011bc", + "blockHash": "0x0d24696c6f6e079032587d6b2089cf2361c07a27eaf4eec1a9375516d1f40573", + "transactionHash": "0x8191030fd62695c5ebfdd637165c6932ad8e4e6d3b6d392c9d5df2d79fd72ab9", "logs": [], - "blockNumber": 8259797, - "cumulativeGasUsed": "3203172", + "blockNumber": 4320491, + "cumulativeGasUsed": "8168826", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "fa4158cdf7ba30d8892d97237acdb9a6", - "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"getAllTokens\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"investigators\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"requestMerge\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setStaker\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"penalty\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"investigator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"slashStaker\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"stakerInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"internalType\":\"struct NuCypherTokenStakingMock.StakerStruct\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"stakers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"slashStaker(address,uint256,address,uint256)\":{\"params\":{\"investigator\":\"Investigator\",\"penalty\":\"Penalty\",\"reward\":\"Reward for the investigator\",\"staker\":\"Staker's address\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getAllTokens(address)\":{\"notice\":\"Get all tokens belonging to the staker\"},\"requestMerge(address,address)\":{\"notice\":\"Request merge between NuCypher staking contract and T staking contract. Returns amount of staked tokens\"},\"slashStaker(address,uint256,address,uint256)\":{\"notice\":\"Slash the staker's stake and reward the investigator\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/TokenStakingTestSet.sol\":\"NuCypherTokenStakingMock\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() initializer {}\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\\n // contract may have been reentered.\\n require(_initializing ? _isConstructor() : !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} modifier, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n function _isConstructor() private view returns (bool) {\\n return !AddressUpgradeable.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x372b0bc04e3b4c074559bbbfb1317afddb56de5504158ca25a7f9cd403980445\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev 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 /**\\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\",\"keccak256\":\"0x6777f3fccb5dab95a9088ef62c41bee0198fd92e50d7c94f0e3733788af4079e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3e26a49d2fa5ef8338b8a9467c91e54f417cb07e849b1cc0f4ebc4d2a147938e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x55cf2bd9fc76704ddcdc19834cd288b7de00fc0f298a40ea16a954ae8991db2d\",\"license\":\"MIT\"},\"@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 v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.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 /**\\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\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\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 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 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 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 /**\\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\",\"keccak256\":\"0x516a22876c1fab47f49b1bc22b4614491cd05338af8bd2e7b382da090a079990\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.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 SafeCast {\\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\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"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\"},\"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/staking/IApplication.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\\n/// @title Application interface for Threshold Network applications\\n/// @notice Generic interface for an application. Application is an external\\n/// smart contract or a set of smart contracts utilizing functionalities\\n/// offered by Threshold Network. Applications authorized for the given\\n/// staking provider are eligible to slash the stake delegated to that\\n/// staking provider.\\ninterface IApplication {\\n /// @dev Event emitted by `withdrawRewards` function.\\n event RewardsWithdrawn(address indexed stakingProvider, uint96 amount);\\n\\n /// @notice Withdraws application rewards for the given staking provider.\\n /// Rewards are withdrawn to the staking provider's beneficiary\\n /// address set in the staking contract.\\n /// @dev Emits `RewardsWithdrawn` event.\\n function withdrawRewards(address stakingProvider) external;\\n\\n /// @notice Used by T staking contract to inform the application that the\\n /// authorized amount for the given staking provider increased.\\n /// The application may do any necessary housekeeping. The\\n /// application must revert the transaction in case the\\n /// authorization is below the minimum required.\\n function authorizationIncreased(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Used by T staking contract to inform the application that the\\n /// authorization decrease for the given staking provider has been\\n /// requested. The application should mark the authorization as\\n /// pending decrease and respond to the staking contract with\\n /// `approveAuthorizationDecrease` at its discretion. It may\\n /// happen right away but it also may happen several months later.\\n /// If there is already a pending authorization decrease request\\n /// for the application, and the application does not agree for\\n /// overwriting it, the function should revert.\\n function authorizationDecreaseRequested(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Used by T staking contract to inform the application the\\n /// authorization has been decreased for the given staking provider\\n /// involuntarily, as a result of slashing. Lets the application to\\n /// do any housekeeping neccessary. Called with 250k gas limit and\\n /// does not revert the transaction if\\n /// `involuntaryAuthorizationDecrease` call failed.\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Returns the amount of application rewards available for\\n /// withdrawal for the given staking provider.\\n function availableRewards(address stakingProvider)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice The minimum authorization amount required for the staking\\n /// provider so that they can participate in the application.\\n function minimumAuthorization() external view returns (uint96);\\n}\\n\",\"keccak256\":\"0x43d707dccc548bf48ad316d9652450cb297203234d251132cdc6b97508eb44c5\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/ILegacyTokenStaking.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\\n/// @title IKeepTokenStaking\\n/// @notice Interface for Keep TokenStaking contract\\ninterface IKeepTokenStaking {\\n /// @notice Seize provided token amount from every member in the misbehaved\\n /// operators array. The tattletale is rewarded with 5% of the total seized\\n /// amount scaled by the reward adjustment parameter and the rest 95% is burned.\\n /// @param amountToSeize Token amount to seize from every misbehaved operator.\\n /// @param rewardMultiplier Reward adjustment in percentage. Min 1% and 100% max.\\n /// @param tattletale Address to receive the 5% reward.\\n /// @param misbehavedOperators Array of addresses to seize the tokens from.\\n function seize(\\n uint256 amountToSeize,\\n uint256 rewardMultiplier,\\n address tattletale,\\n address[] memory misbehavedOperators\\n ) external;\\n\\n /// @notice Gets stake delegation info for the given operator.\\n /// @param operator Operator address.\\n /// @return amount The amount of tokens the given operator delegated.\\n /// @return createdAt The time when the stake has been delegated.\\n /// @return undelegatedAt The time when undelegation has been requested.\\n /// If undelegation has not been requested, 0 is returned.\\n function getDelegationInfo(address operator)\\n external\\n view\\n returns (\\n uint256 amount,\\n uint256 createdAt,\\n uint256 undelegatedAt\\n );\\n\\n /// @notice Gets the stake owner for the specified operator address.\\n /// @return Stake owner address.\\n function ownerOf(address operator) external view returns (address);\\n\\n /// @notice Gets the beneficiary for the specified operator address.\\n /// @return Beneficiary address.\\n function beneficiaryOf(address operator)\\n external\\n view\\n returns (address payable);\\n\\n /// @notice Gets the authorizer for the specified operator address.\\n /// @return Authorizer address.\\n function authorizerOf(address operator) external view returns (address);\\n\\n /// @notice Gets the eligible stake balance of the specified address.\\n /// An eligible stake is a stake that passed the initialization period\\n /// and is not currently undelegating. Also, the operator had to approve\\n /// the specified operator contract.\\n ///\\n /// Operator with a minimum required amount of eligible stake can join the\\n /// network and participate in new work selection.\\n ///\\n /// @param operator address of stake operator.\\n /// @param operatorContract address of operator contract.\\n /// @return balance an uint256 representing the eligible stake balance.\\n function eligibleStake(address operator, address operatorContract)\\n external\\n view\\n returns (uint256 balance);\\n}\\n\\n/// @title INuCypherStakingEscrow\\n/// @notice Interface for NuCypher StakingEscrow contract\\ninterface INuCypherStakingEscrow {\\n /// @notice Slash the staker's stake and reward the investigator\\n /// @param staker Staker's address\\n /// @param penalty Penalty\\n /// @param investigator Investigator\\n /// @param reward Reward for the investigator\\n function slashStaker(\\n address staker,\\n uint256 penalty,\\n address investigator,\\n uint256 reward\\n ) external;\\n\\n /// @notice Request merge between NuCypher staking contract and T staking contract.\\n /// Returns amount of staked tokens\\n function requestMerge(address staker, address stakingProvider)\\n external\\n returns (uint256);\\n\\n /// @notice Get all tokens belonging to the staker\\n function getAllTokens(address staker) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x807d42d248e94c1f2269c7aa27031302a1225525e1405010424dd91adcc092ab\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/IStaking.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\\n/// @title Interface of Threshold Network staking contract\\n/// @notice The staking contract enables T owners to have their wallets offline\\n/// and their stake managed by staking providers on their behalf.\\n/// The staking contract does not define operator role. The operator\\n/// responsible for running off-chain client software is appointed by\\n/// the staking provider in the particular application utilizing the\\n/// staking contract. All off-chain client software should be able\\n/// to run without exposing operator's or staking provider\\u2019s private\\n/// key and should not require any owner\\u2019s keys at all. The stake\\n/// delegation optimizes the network throughput without compromising the\\n/// security of the owners\\u2019 stake.\\ninterface IStaking {\\n enum StakeType {\\n NU,\\n KEEP,\\n T\\n }\\n\\n //\\n //\\n // Delegating a stake\\n //\\n //\\n\\n /// @notice Creates a delegation with `msg.sender` owner with the given\\n /// staking provider, beneficiary, and authorizer. Transfers the\\n /// given amount of T to the staking contract.\\n /// @dev The owner of the delegation needs to have the amount approved to\\n /// transfer to the staking contract.\\n function stake(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer,\\n uint96 amount\\n ) external;\\n\\n /// @notice Copies delegation from the legacy KEEP staking contract to T\\n /// staking contract. No tokens are transferred. Caches the active\\n /// stake amount from KEEP staking contract. Can be called by\\n /// anyone.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function stakeKeep(address stakingProvider) external;\\n\\n /// @notice Copies delegation from the legacy NU staking contract to T\\n /// staking contract, additionally appointing staking provider,\\n /// beneficiary and authorizer roles. Caches the amount staked in NU\\n /// staking contract. Can be called only by the original delegation\\n /// owner.\\n function stakeNu(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer\\n ) external;\\n\\n /// @notice Refresh Keep stake owner. Can be called only by the old owner\\n /// or their staking provider.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function refreshKeepStakeOwner(address stakingProvider) external;\\n\\n /// @notice Allows the Governance to set the minimum required stake amount.\\n /// This amount is required to protect against griefing the staking\\n /// contract and individual applications are allowed to require\\n /// higher minimum stakes if necessary.\\n function setMinimumStakeAmount(uint96 amount) external;\\n\\n //\\n //\\n // Authorizing an application\\n //\\n //\\n\\n /// @notice Allows the Governance to approve the particular application\\n /// before individual stake authorizers are able to authorize it.\\n function approveApplication(address application) external;\\n\\n /// @notice Increases the authorization of the given staking provider for\\n /// the given application by the given amount. Can only be called by\\n /// the authorizer for that staking provider.\\n /// @dev Calls `authorizationIncreased(address stakingProvider, uint256 amount)`\\n /// on the given application to notify the application about\\n /// authorization change. See `IApplication`.\\n function increaseAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external;\\n\\n /// @notice Requests decrease of the authorization for the given staking\\n /// provider on the given application by the provided amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application if the application agrees for that. If the\\n /// application does not agree for overwriting, the function\\n /// reverts.\\n /// @dev Calls `authorizationDecreaseRequested(address stakingProvider, uint256 amount)`\\n /// on the given application. See `IApplication`.\\n function requestAuthorizationDecrease(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external;\\n\\n /// @notice Requests decrease of all authorizations for the given staking\\n /// provider on all applications by all authorized amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application.\\n /// @dev Calls `authorizationDecreaseRequested(address stakingProvider, uint256 amount)`\\n /// for each authorized application. See `IApplication`.\\n function requestAuthorizationDecrease(address stakingProvider) external;\\n\\n /// @notice Called by the application at its discretion to approve the\\n /// previously requested authorization decrease request. Can only be\\n /// called by the application that was previously requested to\\n /// decrease the authorization for that staking provider.\\n /// Returns resulting authorized amount for the application.\\n function approveAuthorizationDecrease(address stakingProvider)\\n external\\n returns (uint96);\\n\\n /// @notice Decreases the authorization for the given `stakingProvider` on\\n /// the given disabled `application`, for all authorized amount.\\n /// Can be called by anyone.\\n function forceDecreaseAuthorization(\\n address stakingProvider,\\n address application\\n ) external;\\n\\n /// @notice Pauses the given application\\u2019s eligibility to slash stakes.\\n /// Besides that stakers can't change authorization to the application.\\n /// Can be called only by the Panic Button of the particular\\n /// application. The paused application can not slash stakes until\\n /// it is approved again by the Governance using `approveApplication`\\n /// function. Should be used only in case of an emergency.\\n function pauseApplication(address application) external;\\n\\n /// @notice Disables the given application. The disabled application can't\\n /// slash stakers. Also stakers can't increase authorization to that\\n /// application but can decrease without waiting by calling\\n /// `requestAuthorizationDecrease` at any moment. Can be called only\\n /// by the governance. The disabled application can't be approved\\n /// again. Should be used only in case of an emergency.\\n function disableApplication(address application) external;\\n\\n /// @notice Sets the Panic Button role for the given application to the\\n /// provided address. Can only be called by the Governance. If the\\n /// Panic Button for the given application should be disabled, the\\n /// role address should be set to 0x0 address.\\n function setPanicButton(address application, address panicButton) external;\\n\\n /// @notice Sets the maximum number of applications one staking provider can\\n /// have authorized. Used to protect against DoSing slashing queue.\\n /// Can only be called by the Governance.\\n function setAuthorizationCeiling(uint256 ceiling) external;\\n\\n //\\n //\\n // Stake top-up\\n //\\n //\\n\\n /// @notice Increases the amount of the stake for the given staking provider.\\n /// @dev The sender of this transaction needs to have the amount approved to\\n /// transfer to the staking contract.\\n function topUp(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Propagates information about stake top-up from the legacy KEEP\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpKeep(address stakingProvider) external;\\n\\n /// @notice Propagates information about stake top-up from the legacy NU\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpNu(address stakingProvider) external;\\n\\n //\\n //\\n // Undelegating a stake (unstaking)\\n //\\n //\\n\\n /// @notice Reduces the liquid T stake amount by the provided amount and\\n /// withdraws T to the owner. Reverts if there is at least one\\n /// authorization higher than the sum of the legacy stake and\\n /// remaining liquid T stake or if the unstake amount is higher than\\n /// the liquid T stake amount. Can be called only by the delegation\\n /// owner or the staking provider.\\n function unstakeT(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Sets the legacy KEEP staking contract active stake amount cached\\n /// in T staking contract to 0. Reverts if the amount of liquid T\\n /// staked in T staking contract is lower than the highest\\n /// application authorization. This function allows to unstake from\\n /// KEEP staking contract and still being able to operate in T\\n /// network and earning rewards based on the liquid T staked. Can be\\n /// called only by the delegation owner or the staking provider.\\n function unstakeKeep(address stakingProvider) external;\\n\\n /// @notice Reduces cached legacy NU stake amount by the provided amount.\\n /// Reverts if there is at least one authorization higher than the\\n /// sum of remaining legacy NU stake and liquid T stake for that\\n /// staking provider or if the untaked amount is higher than the\\n /// cached legacy stake amount. If succeeded, the legacy NU stake\\n /// can be partially or fully undelegated on the legacy staking\\n /// contract. This function allows to unstake from NU staking\\n /// contract and still being able to operate in T network and\\n /// earning rewards based on the liquid T staked. Can be called only\\n /// by the delegation owner or the staking provider.\\n function unstakeNu(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Sets cached legacy stake amount to 0, sets the liquid T stake\\n /// amount to 0 and withdraws all liquid T from the stake to the\\n /// owner. Reverts if there is at least one non-zero authorization.\\n /// Can be called only by the delegation owner or the staking\\n /// provider.\\n function unstakeAll(address stakingProvider) external;\\n\\n //\\n //\\n // Keeping information in sync\\n //\\n //\\n\\n /// @notice Notifies about the discrepancy between legacy KEEP active stake\\n /// and the amount cached in T staking contract. Slashes the staking\\n /// provider in case the amount cached is higher than the actual\\n /// active stake amount in KEEP staking contract. Needs to update\\n /// authorizations of all affected applications and execute an\\n /// involuntary allocation decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyKeepStakeDiscrepancy(address stakingProvider) external;\\n\\n /// @notice Notifies about the discrepancy between legacy NU active stake\\n /// and the amount cached in T staking contract. Slashes the\\n /// staking provider in case the amount cached is higher than the\\n /// actual active stake amount in NU staking contract. Needs to\\n /// update authorizations of all affected applications and execute\\n /// an involuntary allocation decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyNuStakeDiscrepancy(address stakingProvider) external;\\n\\n /// @notice Sets the penalty amount for stake discrepancy and reward\\n /// multiplier for reporting it. The penalty is seized from the\\n /// delegated stake, and 5% of the penalty, scaled by the\\n /// multiplier, is given to the notifier. The rest of the tokens are\\n /// burned. Can only be called by the Governance. See `seize` function.\\n function setStakeDiscrepancyPenalty(\\n uint96 penalty,\\n uint256 rewardMultiplier\\n ) external;\\n\\n /// @notice Sets reward in T tokens for notification of misbehaviour\\n /// of one staking provider. Can only be called by the governance.\\n function setNotificationReward(uint96 reward) external;\\n\\n /// @notice Transfer some amount of T tokens as reward for notifications\\n /// of misbehaviour\\n function pushNotificationReward(uint96 reward) external;\\n\\n /// @notice Withdraw some amount of T tokens from notifiers treasury.\\n /// Can only be called by the governance.\\n function withdrawNotificationReward(address recipient, uint96 amount)\\n external;\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount that should be slashed from each one of them. Can only be\\n /// called by application authorized for all staking providers in\\n /// the array.\\n function slash(uint96 amount, address[] memory stakingProviders) external;\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each staking\\n /// provider from notifiers treasury. Can only be called by\\n /// application authorized for all staking providers in the array.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultipier,\\n address notifier,\\n address[] memory stakingProviders\\n ) external;\\n\\n /// @notice Takes the given number of queued slashing operations and\\n /// processes them. Receives 5% of the slashed amount.\\n /// Executes `involuntaryAllocationDecrease` function on each\\n /// affected application.\\n function processSlashing(uint256 count) external;\\n\\n //\\n //\\n // Auxiliary functions\\n //\\n //\\n\\n /// @notice Returns the authorized stake amount of the staking provider for\\n /// the application.\\n function authorizedStake(address stakingProvider, address application)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice Returns staked amount of T, Keep and Nu for the specified\\n /// staking provider.\\n /// @dev All values are in T denomination\\n function stakes(address stakingProvider)\\n external\\n view\\n returns (\\n uint96 tStake,\\n uint96 keepInTStake,\\n uint96 nuInTStake\\n );\\n\\n /// @notice Returns start staking timestamp.\\n /// @dev This value is set at most once.\\n function getStartStakingTimestamp(address stakingProvider)\\n external\\n view\\n returns (uint256);\\n\\n /// @notice Returns staked amount of NU for the specified staking provider.\\n function stakedNu(address stakingProvider) external view returns (uint256);\\n\\n /// @notice Gets the stake owner, the beneficiary and the authorizer\\n /// for the specified staking provider address.\\n /// @return owner Stake owner address.\\n /// @return beneficiary Beneficiary address.\\n /// @return authorizer Authorizer address.\\n function rolesOf(address stakingProvider)\\n external\\n view\\n returns (\\n address owner,\\n address payable beneficiary,\\n address authorizer\\n );\\n\\n /// @notice Returns length of application array\\n function getApplicationsLength() external view returns (uint256);\\n\\n /// @notice Returns length of slashing queue\\n function getSlashingQueueLength() external view returns (uint256);\\n\\n /// @notice Returns minimum possible stake for T, KEEP or NU in T\\n /// denomination.\\n /// @dev For example, suppose the given staking provider has 10 T, 20 T\\n /// worth of KEEP, and 30 T worth of NU all staked, and the maximum\\n /// application authorization is 40 T, then `getMinStaked` for\\n /// that staking provider returns:\\n /// * 0 T if KEEP stake type specified i.e.\\n /// min = 40 T max - (10 T + 30 T worth of NU) = 0 T\\n /// * 10 T if NU stake type specified i.e.\\n /// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T\\n /// * 0 T if T stake type specified i.e.\\n /// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T\\n /// In other words, the minimum stake amount for the specified\\n /// stake type is the minimum amount of stake of the given type\\n /// needed to satisfy the maximum application authorization given the\\n /// staked amounts of the other stake types for that staking provider.\\n function getMinStaked(address stakingProvider, StakeType stakeTypes)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice Returns available amount to authorize for the specified application\\n function getAvailableToAuthorize(\\n address stakingProvider,\\n address application\\n ) external view returns (uint96);\\n}\\n\",\"keccak256\":\"0x5fde659b8fe5fffb695e55d84df1b1efe89978470d2d7a42f287d92a7fcc8b79\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/KeepStake.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 \\\"./ILegacyTokenStaking.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title KEEP ManagedGrant contract interface\\ninterface IManagedGrant {\\n function grantee() external view returns (address);\\n}\\n\\n/// @title KEEP stake owner resolver\\n/// @notice T network staking contract supports existing KEEP stakes by allowing\\n/// KEEP stakers to use their stakes in T network and weights them based\\n/// on KEEP<>T token ratio. KEEP stake owner is cached in T staking\\n/// contract and used to restrict access to all functions only owner or\\n/// operator should call. To cache KEEP stake owner in T staking\\n/// contract, T staking contract first needs to resolve the owner.\\n///\\n/// Resolving liquid KEEP stake owner is easy. Resolving token grant\\n/// stake owner is complicated and not possible to do on-chain from\\n/// a contract external to KEEP TokenStaking contract. Keep TokenStaking\\n/// knows the grant ID but does not expose it externally.\\n///\\n/// KeepStake contract addresses this problem by exposing\\n/// operator-owner mappings snapshotted off-chain based on events and\\n/// information publicly available from KEEP TokenStaking contract and\\n/// KEEP TokenGrant contract. Additionally, it gives the Governance\\n/// ability to add new mappings in case they are ever needed; in\\n/// practice, this will be needed only if someone decides to stake their\\n/// KEEP token grant in KEEP network after 2021-11-11 when the snapshot\\n/// was taken.\\n///\\n/// Operator-owner pairs were snapshotted 2021-11-11 in the following\\n/// way:\\n/// 1. Fetch all TokenStaking events from KEEP staking contract.\\n/// 2. Filter out undelegated operators.\\n/// 3. Filter out canceled delegations.\\n/// 4. Fetch grant stake information from KEEP TokenGrant for that\\n/// operator to determine if we are dealing with grant delegation.\\n/// 5. Fetch grantee address from KEEP TokenGrant contract.\\n/// 6. Check if we are dealing with ManagedGrant by looking for all\\n/// created ManagedGrants and comparing their address against grantee\\n/// address fetched from TokenGrant contract.\\ncontract KeepStake is Ownable {\\n IKeepTokenStaking public immutable keepTokenStaking;\\n\\n mapping(address => address) public operatorToManagedGrant;\\n mapping(address => address) public operatorToGrantee;\\n\\n constructor(IKeepTokenStaking _keepTokenStaking) {\\n keepTokenStaking = _keepTokenStaking;\\n }\\n\\n /// @notice Allows the Governance to set new operator-managed grant pair.\\n /// This function should only be called for managed grants if\\n /// the snapshot does include this pair.\\n function setManagedGrant(address operator, address managedGrant)\\n external\\n onlyOwner\\n {\\n operatorToManagedGrant[operator] = managedGrant;\\n }\\n\\n /// @notice Allows the Governance to set new operator-grantee pair.\\n /// This function should only be called for non-managed grants if\\n /// the snapshot does include this pair.\\n function setGrantee(address operator, address grantee) external onlyOwner {\\n operatorToGrantee[operator] = grantee;\\n }\\n\\n /// @notice Resolves KEEP stake owner for the provided operator address.\\n /// Reverts if could not resolve the owner.\\n function resolveOwner(address operator) external view returns (address) {\\n address owner = operatorToManagedGrant[operator];\\n if (owner != address(0)) {\\n return IManagedGrant(owner).grantee();\\n }\\n\\n owner = operatorToGrantee[operator];\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = resolveSnapshottedManagedGrantees(operator);\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = resolveSnapshottedGrantees(operator);\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = keepTokenStaking.ownerOf(operator);\\n require(owner != address(0), \\\"Could not resolve the owner\\\");\\n\\n return owner;\\n }\\n\\n function resolveSnapshottedManagedGrantees(address operator)\\n internal\\n view\\n returns (address)\\n {\\n if (operator == 0x855A951162B1B93D70724484d5bdc9D00B56236B) {\\n return\\n IManagedGrant(0xFADbF758307A054C57B365Db1De90acA71feaFE5)\\n .grantee();\\n }\\n if (operator == 0xF1De9490Bf7298b5F350cE74332Ad7cf8d5cB181) {\\n return\\n IManagedGrant(0xAEd493Aaf3E76E83b29E151848b71eF4544f92f1)\\n .grantee();\\n }\\n if (operator == 0x39d2aCBCD80d80080541C6eed7e9feBb8127B2Ab) {\\n return\\n IManagedGrant(0xA2fa09D6f8C251422F5fde29a0BAd1C53dEfAe66)\\n .grantee();\\n }\\n if (operator == 0xd66cAE89FfBc6E50e6b019e45c1aEc93Dec54781) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0x2eBE08379f4fD866E871A9b9E1d5C695154C6A9F) {\\n return\\n IManagedGrant(0xd00c0d43b747C33726B3f0ff4BDA4b72dc53c6E9)\\n .grantee();\\n }\\n if (operator == 0xA97c34278162b556A527CFc01B53eb4DDeDFD223) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x6C76d49322C9f8761A1623CEd89A31490cdB649d) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x4a41c7a884d119eaaefE471D0B3a638226408382) {\\n return\\n IManagedGrant(0xcdf3d216d82a463Ce82971F2F5DA3d8f9C5f093A)\\n .grantee();\\n }\\n if (operator == 0x9c06Feb7Ebc8065ee11Cd5E8EEdaAFb2909A7087) {\\n return\\n IManagedGrant(0x45119cd98d145283762BA9eBCAea75F72D188733)\\n .grantee();\\n }\\n if (operator == 0x9bD818Ab6ACC974f2Cf2BD2EBA7a250126Accb9F) {\\n return\\n IManagedGrant(0x6E535043377067621954ee84065b0bd7357e7aBa)\\n .grantee();\\n }\\n if (operator == 0x1d803c89760F8B4057DB15BCb3B8929E0498D310) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x3101927DEeC27A2bfA6c4a6316e3A221f631dB91) {\\n return\\n IManagedGrant(0x178Bf1946feD0e2362fdF8bcD3f91F0701a012C6)\\n .grantee();\\n }\\n if (operator == 0x9d9b187E478bC62694A7bED216Fc365de87F280C) {\\n return\\n IManagedGrant(0xFBad17CFad6cb00D726c65501D69FdC13Ca5477c)\\n .grantee();\\n }\\n if (operator == 0xd977144724Bc77FaeFAe219F958AE3947205d0b5) {\\n return\\n IManagedGrant(0x087B442BFd4E42675cf2df5fa566F87d7A96Fb12)\\n .grantee();\\n }\\n if (operator == 0x045E511f53DeBF55c9C0B4522f14F602f7C7cA81) {\\n return\\n IManagedGrant(0xFcfe8C036C414a15cF871071c483687095caF7D6)\\n .grantee();\\n }\\n if (operator == 0x3Dd301b3c96A282d8092E1e6f6846f24172D45C1) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x5d84DEB482E770479154028788Df79aA7C563aA4) {\\n return\\n IManagedGrant(0x9D1a179c469a8BdD0b683A9f9250246cc47e8fBE)\\n .grantee();\\n }\\n if (operator == 0x1dF927B69A97E8140315536163C029d188e8573b) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x617daCE069Fbd41993491de211b4DfccdAcbd348) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x650A9eD18Df873cad98C88dcaC8170531cAD2399) {\\n return\\n IManagedGrant(0x1Df7324A3aD20526DFa02Cc803eD2D97Cac81F3b)\\n .grantee();\\n }\\n if (operator == 0x07C9a8f8264221906b7b8958951Ce4753D39628B) {\\n return\\n IManagedGrant(0x305D12b4d70529Cd618dA7399F5520701E510041)\\n .grantee();\\n }\\n if (operator == 0x63eB4c3DD0751F9BE7070A01156513C227fa1eF6) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0xc6349eEC31048787676b6297ba71721376A8DdcF) {\\n return\\n IManagedGrant(0xac1a985E75C6a0b475b9c807Ad0705a988Be2D99)\\n .grantee();\\n }\\n if (operator == 0x3B945f9C0C8737e44f8e887d4F04B5B3A491Ac4d) {\\n return\\n IManagedGrant(0x82e17477726E8D9D2C237745cA9989631582eE98)\\n .grantee();\\n }\\n if (operator == 0xF35343299a4f80Dd5D917bbe5ddd54eBB820eBd4) {\\n return\\n IManagedGrant(0xCC88c15506251B62ccCeebA193e100d6bBC9a30D)\\n .grantee();\\n }\\n if (operator == 0x3B9e5ae72d068448bB96786989c0d86FBC0551D1) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0xB2D53Be158Cb8451dFc818bD969877038c1BdeA1) {\\n return\\n IManagedGrant(0xaE55e3800f0A3feaFdcE535A8C0fab0fFdB90DEe)\\n .grantee();\\n }\\n if (operator == 0xF6dbF7AFe05b8Bb6f198eC7e69333c98D3C4608C) {\\n return\\n IManagedGrant(0xbb8D24a20c20625f86739824014C3cBAAAb26700)\\n .grantee();\\n }\\n if (operator == 0xB62Fc1ADfFb2ab832041528C8178358338d85f76) {\\n return\\n IManagedGrant(0x9ED98fD1C29018B9342CB8F57A3073B9695f0c02)\\n .grantee();\\n }\\n if (operator == 0x9bC8d30d971C9e74298112803036C05db07D73e3) {\\n return\\n IManagedGrant(0x66beda757939f8e505b5Eb883cd02C8d4a11Bca2)\\n .grantee();\\n }\\n\\n return address(0);\\n }\\n\\n function resolveSnapshottedGrantees(address operator)\\n internal\\n pure\\n returns (address)\\n {\\n if (operator == 0x1147ccFB4AEFc6e587a23b78724Ef20Ec6e474D4) {\\n return 0x3FB49dA4375Ef9019f17990D04c6d5daD482D80a;\\n }\\n if (operator == 0x4c21541f95a00C03C75F38C71DC220bd27cbbEd9) {\\n return 0xC897cfeE43a8d827F76D4226994D5CE5EBBe2571;\\n }\\n if (operator == 0x7E6332d18719a5463d3867a1a892359509589a3d) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0x8Bd660A764Ca14155F3411a4526a028b6316CB3E) {\\n return 0xf6f372DfAeCC1431186598c304e91B79Ce115766;\\n }\\n if (operator == 0x4F4f0D0dfd93513B3f4Cb116Fe9d0A005466F725) {\\n return 0x8b055ac1c4dd287E2a46D4a52d61FE76FB551bD0;\\n }\\n if (operator == 0x1DF0250027fEC876d8876d1ac7A392c9098F1a1e) {\\n return 0xE408fFa969707Ce5d7aA3e5F8d44674Fa4b26219;\\n }\\n if (operator == 0x860EF3f83B6adFEF757F98345c3B8DdcFCA9d152) {\\n return 0x08a3633AAb8f3E436DEA204288Ee26Fe094406b0;\\n }\\n if (operator == 0xe3a2d16dA142E6B190A5d9F7e0C07cc460B58A5F) {\\n return 0x875f8fFCDDeD63B5d8Cf54be4E4b82FE6c6E249C;\\n }\\n if (operator == 0xBDE07f1cA107Ef319b0Bb26eBF1d0a5b4c97ffc1) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0xE86181D6b672d78D33e83029fF3D0ef4A601B4C4) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0xb7c561e2069aCaE2c4480111B1606790BB4E13fE) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0x526c013f8382B050d32d86e7090Ac84De22EdA4D) {\\n return 0x61C6E5DDacded540CD08066C08cbc096d22D91f4;\\n }\\n\\n return address(0);\\n }\\n}\\n\",\"keccak256\":\"0xc75f6be595ec0e0c885d689786808a53b70c0a170a53dd344228359dc6aaf178\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/TokenStaking.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 \\\"./IApplication.sol\\\";\\nimport \\\"./ILegacyTokenStaking.sol\\\";\\nimport \\\"./IStaking.sol\\\";\\nimport \\\"./KeepStake.sol\\\";\\nimport \\\"../governance/Checkpoints.sol\\\";\\nimport \\\"../token/T.sol\\\";\\nimport \\\"../utils/PercentUtils.sol\\\";\\nimport \\\"../utils/SafeTUpgradeable.sol\\\";\\nimport \\\"../vending/VendingMachine.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\n\\n/// @notice TokenStaking is the main staking contract of the Threshold Network.\\n/// Apart from the basic usage of enabling T stakes, it also acts as a\\n/// sort of \\\"meta-staking\\\" contract, accepting existing legacy NU/KEEP\\n/// stakes. Additionally, it serves as application manager for the apps\\n/// that run on the Threshold Network. Note that legacy NU/KEEP staking\\n/// contracts see TokenStaking as an application (e.g., slashing is\\n/// requested by TokenStaking and performed by the legacy contracts).\\n/// @dev TokenStaking is upgradeable, using OpenZeppelin's Upgradeability\\n/// framework. As such, it is required to satisfy OZ's guidelines, like\\n/// restrictions on constructors, immutable variables, base contracts and\\n/// libraries. See https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable\\ncontract TokenStaking is Initializable, IStaking, Checkpoints {\\n using SafeTUpgradeable for T;\\n using PercentUtils for uint256;\\n using SafeCastUpgradeable for uint256;\\n\\n enum ApplicationStatus {\\n NOT_APPROVED,\\n APPROVED,\\n PAUSED,\\n DISABLED\\n }\\n\\n struct StakingProviderInfo {\\n uint96 nuInTStake;\\n address owner;\\n uint96 keepInTStake;\\n address payable beneficiary;\\n uint96 tStake;\\n address authorizer;\\n mapping(address => AppAuthorization) authorizations;\\n address[] authorizedApplications;\\n uint256 startStakingTimestamp;\\n }\\n\\n struct AppAuthorization {\\n uint96 authorized;\\n uint96 deauthorizing;\\n }\\n\\n struct ApplicationInfo {\\n ApplicationStatus status;\\n address panicButton;\\n }\\n\\n struct SlashingEvent {\\n address stakingProvider;\\n uint96 amount;\\n }\\n\\n uint256 internal constant SLASHING_REWARD_PERCENT = 5;\\n uint256 internal constant MIN_STAKE_TIME = 120;\\n uint256 internal constant GAS_LIMIT_AUTHORIZATION_DECREASE = 250000;\\n uint256 internal constant CONVERSION_DIVISOR = 10**(18 - 3);\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n T internal immutable token;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IKeepTokenStaking internal immutable keepStakingContract;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n KeepStake internal immutable keepStake;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n INuCypherStakingEscrow internal immutable nucypherStakingContract;\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable keepRatio;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable nucypherRatio;\\n\\n address public governance;\\n uint96 public minTStakeAmount;\\n uint256 public authorizationCeiling;\\n uint96 public stakeDiscrepancyPenalty;\\n uint256 public stakeDiscrepancyRewardMultiplier;\\n\\n uint256 public notifiersTreasury;\\n uint256 public notificationReward;\\n\\n mapping(address => StakingProviderInfo) internal stakingProviders;\\n mapping(address => ApplicationInfo) public applicationInfo;\\n address[] public applications;\\n\\n SlashingEvent[] public slashingQueue;\\n uint256 public slashingQueueIndex;\\n\\n event Staked(\\n StakeType indexed stakeType,\\n address indexed owner,\\n address indexed stakingProvider,\\n address beneficiary,\\n address authorizer,\\n uint96 amount\\n );\\n event MinimumStakeAmountSet(uint96 amount);\\n event ApplicationStatusChanged(\\n address indexed application,\\n ApplicationStatus indexed newStatus\\n );\\n event AuthorizationIncreased(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationDecreaseRequested(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationDecreaseApproved(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationInvoluntaryDecreased(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount,\\n bool indexed successfulCall\\n );\\n event PanicButtonSet(\\n address indexed application,\\n address indexed panicButton\\n );\\n event AuthorizationCeilingSet(uint256 ceiling);\\n event ToppedUp(address indexed stakingProvider, uint96 amount);\\n event Unstaked(address indexed stakingProvider, uint96 amount);\\n event TokensSeized(\\n address indexed stakingProvider,\\n uint96 amount,\\n bool indexed discrepancy\\n );\\n event StakeDiscrepancyPenaltySet(uint96 penalty, uint256 rewardMultiplier);\\n event NotificationRewardSet(uint96 reward);\\n event NotificationRewardPushed(uint96 reward);\\n event NotificationRewardWithdrawn(address recipient, uint96 amount);\\n event NotifierRewarded(address indexed notifier, uint256 amount);\\n event SlashingProcessed(\\n address indexed caller,\\n uint256 count,\\n uint256 tAmount\\n );\\n event OwnerRefreshed(\\n address indexed stakingProvider,\\n address indexed oldOwner,\\n address indexed newOwner\\n );\\n event GovernanceTransferred(address oldGovernance, address newGovernance);\\n\\n modifier onlyGovernance() {\\n require(governance == msg.sender, \\\"Caller is not the governance\\\");\\n _;\\n }\\n\\n modifier onlyPanicButtonOf(address application) {\\n require(\\n applicationInfo[application].panicButton == msg.sender,\\n \\\"Caller is not the panic button\\\"\\n );\\n _;\\n }\\n\\n modifier onlyAuthorizerOf(address stakingProvider) {\\n //slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].authorizer == msg.sender,\\n \\\"Not authorizer\\\"\\n );\\n _;\\n }\\n\\n modifier onlyOwnerOrStakingProvider(address stakingProvider) {\\n //slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].owner != address(0) &&\\n (stakingProvider == msg.sender ||\\n stakingProviders[stakingProvider].owner == msg.sender),\\n \\\"Not owner or provider\\\"\\n );\\n _;\\n }\\n\\n /// @param _token Address of T token contract\\n /// @param _keepStakingContract Address of Keep staking contract\\n /// @param _nucypherStakingContract Address of NuCypher staking contract\\n /// @param _keepVendingMachine Address of Keep vending machine\\n /// @param _nucypherVendingMachine Address of NuCypher vending machine\\n /// @param _keepStake Address of Keep contract with grant owners\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n T _token,\\n IKeepTokenStaking _keepStakingContract,\\n INuCypherStakingEscrow _nucypherStakingContract,\\n VendingMachine _keepVendingMachine,\\n VendingMachine _nucypherVendingMachine,\\n KeepStake _keepStake\\n ) {\\n // calls to check contracts are working\\n require(\\n _token.totalSupply() > 0 &&\\n _keepStakingContract.ownerOf(address(0)) == address(0) &&\\n _nucypherStakingContract.getAllTokens(address(0)) == 0 &&\\n AddressUpgradeable.isContract(address(_keepStake)),\\n \\\"Wrong input parameters\\\"\\n );\\n token = _token;\\n keepStakingContract = _keepStakingContract;\\n keepStake = _keepStake;\\n nucypherStakingContract = _nucypherStakingContract;\\n\\n keepRatio = _keepVendingMachine.ratio();\\n nucypherRatio = _nucypherVendingMachine.ratio();\\n }\\n\\n function initialize() external initializer {\\n _transferGovernance(msg.sender);\\n }\\n\\n //\\n //\\n // Delegating a stake\\n //\\n //\\n\\n /// @notice Creates a delegation with `msg.sender` owner with the given\\n /// staking provider, beneficiary, and authorizer. Transfers the\\n /// given amount of T to the staking contract.\\n /// @dev The owner of the delegation needs to have the amount approved to\\n /// transfer to the staking contract.\\n function stake(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer,\\n uint96 amount\\n ) external override {\\n require(\\n stakingProvider != address(0) &&\\n beneficiary != address(0) &&\\n authorizer != address(0),\\n \\\"Parameters must be specified\\\"\\n );\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n (, uint256 createdAt, ) = keepStakingContract.getDelegationInfo(\\n stakingProvider\\n );\\n require(\\n createdAt == 0 && stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n require(\\n amount > 0 && amount >= minTStakeAmount,\\n \\\"Amount is less than minimum\\\"\\n );\\n stakingProviderStruct.owner = msg.sender;\\n stakingProviderStruct.authorizer = authorizer;\\n stakingProviderStruct.beneficiary = beneficiary;\\n\\n stakingProviderStruct.tStake = amount;\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, amount);\\n\\n emit Staked(\\n StakeType.T,\\n msg.sender,\\n stakingProvider,\\n beneficiary,\\n authorizer,\\n amount\\n );\\n token.safeTransferFrom(msg.sender, address(this), amount);\\n }\\n\\n /// @notice Copies delegation from the legacy KEEP staking contract to T\\n /// staking contract. No tokens are transferred. Caches the active\\n /// stake amount from KEEP staking contract. Can be called by\\n /// anyone.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function stakeKeep(address stakingProvider) external override {\\n require(stakingProvider != address(0), \\\"Parameters must be specified\\\");\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n\\n require(\\n stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n\\n uint96 tAmount = getKeepAmountInT(stakingProvider);\\n require(tAmount != 0, \\\"Nothing to sync\\\");\\n\\n stakingProviderStruct.keepInTStake = tAmount;\\n stakingProviderStruct.owner = keepStake.resolveOwner(stakingProvider);\\n stakingProviderStruct.authorizer = keepStakingContract.authorizerOf(\\n stakingProvider\\n );\\n stakingProviderStruct.beneficiary = keepStakingContract.beneficiaryOf(\\n stakingProvider\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, tAmount);\\n\\n emit Staked(\\n StakeType.KEEP,\\n stakingProviderStruct.owner,\\n stakingProvider,\\n stakingProviderStruct.beneficiary,\\n stakingProviderStruct.authorizer,\\n tAmount\\n );\\n }\\n\\n /// @notice Copies delegation from the legacy NU staking contract to T\\n /// staking contract, additionally appointing beneficiary and\\n /// authorizer roles. Caches the amount staked in NU staking\\n /// contract. Can be called only by the original delegation owner.\\n function stakeNu(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer\\n ) external override {\\n require(\\n stakingProvider != address(0) &&\\n beneficiary != address(0) &&\\n authorizer != address(0),\\n \\\"Parameters must be specified\\\"\\n );\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n (, uint256 createdAt, ) = keepStakingContract.getDelegationInfo(\\n stakingProvider\\n );\\n require(\\n createdAt == 0 && stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n\\n uint96 tAmount = getNuAmountInT(msg.sender, stakingProvider);\\n require(tAmount > 0, \\\"Nothing to sync\\\");\\n\\n stakingProviderStruct.nuInTStake = tAmount;\\n stakingProviderStruct.owner = msg.sender;\\n stakingProviderStruct.authorizer = authorizer;\\n stakingProviderStruct.beneficiary = beneficiary;\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, tAmount);\\n\\n emit Staked(\\n StakeType.NU,\\n msg.sender,\\n stakingProvider,\\n beneficiary,\\n authorizer,\\n tAmount\\n );\\n }\\n\\n /// @notice Refresh Keep stake owner. Can be called only by the old owner\\n /// or their staking provider.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function refreshKeepStakeOwner(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n address newOwner = keepStake.resolveOwner(stakingProvider);\\n\\n emit OwnerRefreshed(\\n stakingProvider,\\n stakingProviderStruct.owner,\\n newOwner\\n );\\n stakingProviderStruct.owner = newOwner;\\n }\\n\\n /// @notice Allows the Governance to set the minimum required stake amount.\\n /// This amount is required to protect against griefing the staking\\n /// contract and individual applications are allowed to require\\n /// higher minimum stakes if necessary.\\n /// @dev Staking providers are not required to maintain a minimum T stake\\n /// all the time. 24 hours after the delegation, T stake can be reduced\\n /// below the minimum stake. The minimum stake in the staking contract\\n /// is just to protect against griefing stake operation. Please note\\n /// that each application may have its own minimum authorization though\\n /// and the authorization can not be higher than the stake.\\n function setMinimumStakeAmount(uint96 amount)\\n external\\n override\\n onlyGovernance\\n {\\n minTStakeAmount = amount;\\n emit MinimumStakeAmountSet(amount);\\n }\\n\\n //\\n //\\n // Authorizing an application\\n //\\n //\\n\\n /// @notice Allows the Governance to approve the particular application\\n /// before individual stake authorizers are able to authorize it.\\n function approveApplication(address application)\\n external\\n override\\n onlyGovernance\\n {\\n require(application != address(0), \\\"Parameters must be specified\\\");\\n ApplicationInfo storage info = applicationInfo[application];\\n require(\\n info.status == ApplicationStatus.NOT_APPROVED ||\\n info.status == ApplicationStatus.PAUSED,\\n \\\"Can't approve application\\\"\\n );\\n\\n if (info.status == ApplicationStatus.NOT_APPROVED) {\\n applications.push(application);\\n }\\n info.status = ApplicationStatus.APPROVED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.APPROVED);\\n }\\n\\n /// @notice Increases the authorization of the given staking provider for\\n /// the given application by the given amount. Can only be called by\\n /// the given staking provider\\u2019s authorizer.\\n /// @dev Calls `authorizationIncreased` callback on the given application to\\n /// notify the application about authorization change.\\n /// See `IApplication`.\\n function increaseAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external override onlyAuthorizerOf(stakingProvider) {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[application];\\n uint96 fromAmount = authorization.authorized;\\n if (fromAmount == 0) {\\n require(\\n authorizationCeiling == 0 ||\\n stakingProviderStruct.authorizedApplications.length <\\n authorizationCeiling,\\n \\\"Too many applications\\\"\\n );\\n stakingProviderStruct.authorizedApplications.push(application);\\n }\\n\\n uint96 availableTValue = getAvailableToAuthorize(\\n stakingProvider,\\n application\\n );\\n require(availableTValue >= amount, \\\"Not enough stake to authorize\\\");\\n authorization.authorized += amount;\\n emit AuthorizationIncreased(\\n stakingProvider,\\n application,\\n fromAmount,\\n authorization.authorized\\n );\\n IApplication(application).authorizationIncreased(\\n stakingProvider,\\n fromAmount,\\n authorization.authorized\\n );\\n }\\n\\n /// @notice Requests decrease of all authorizations for the given staking\\n /// provider on all applications by all authorized amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application.\\n /// @dev Calls `authorizationDecreaseRequested` callback\\n /// for each authorized application. See `IApplication`.\\n function requestAuthorizationDecrease(address stakingProvider) external {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 deauthorizing = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address application = stakingProviderStruct.authorizedApplications[\\n i\\n ];\\n uint96 authorized = stakingProviderStruct\\n .authorizations[application]\\n .authorized;\\n if (authorized > 0) {\\n requestAuthorizationDecrease(\\n stakingProvider,\\n application,\\n authorized\\n );\\n deauthorizing += authorized;\\n }\\n }\\n\\n require(deauthorizing > 0, \\\"Nothing was authorized\\\");\\n }\\n\\n /// @notice Called by the application at its discretion to approve the\\n /// previously requested authorization decrease request. Can only be\\n /// called by the application that was previously requested to\\n /// decrease the authorization for that staking provider.\\n /// Returns resulting authorized amount for the application.\\n function approveAuthorizationDecrease(address stakingProvider)\\n external\\n override\\n returns (uint96)\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[msg.sender];\\n require(authorization.deauthorizing > 0, \\\"No deauthorizing in process\\\");\\n\\n uint96 fromAmount = authorization.authorized;\\n authorization.authorized -= authorization.deauthorizing;\\n authorization.deauthorizing = 0;\\n emit AuthorizationDecreaseApproved(\\n stakingProvider,\\n msg.sender,\\n fromAmount,\\n authorization.authorized\\n );\\n\\n // remove application from an array\\n if (authorization.authorized == 0) {\\n cleanAuthorizedApplications(stakingProviderStruct, 1);\\n }\\n\\n return authorization.authorized;\\n }\\n\\n /// @notice Decreases the authorization for the given `stakingProvider` on\\n /// the given disabled `application`, for all authorized amount.\\n /// Can be called by anyone.\\n function forceDecreaseAuthorization(\\n address stakingProvider,\\n address application\\n ) external override {\\n require(\\n applicationInfo[application].status == ApplicationStatus.DISABLED,\\n \\\"Application is not disabled\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[application];\\n uint96 fromAmount = authorization.authorized;\\n require(fromAmount > 0, \\\"Application is not authorized\\\");\\n authorization.authorized = 0;\\n authorization.deauthorizing = 0;\\n\\n emit AuthorizationDecreaseApproved(\\n stakingProvider,\\n application,\\n fromAmount,\\n 0\\n );\\n cleanAuthorizedApplications(stakingProviderStruct, 1);\\n }\\n\\n /// @notice Pauses the given application\\u2019s eligibility to slash stakes.\\n /// Besides that stakers can't change authorization to the application.\\n /// Can be called only by the Panic Button of the particular\\n /// application. The paused application can not slash stakes until\\n /// it is approved again by the Governance using `approveApplication`\\n /// function. Should be used only in case of an emergency.\\n function pauseApplication(address application)\\n external\\n override\\n onlyPanicButtonOf(application)\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Can't pause application\\\"\\n );\\n applicationStruct.status = ApplicationStatus.PAUSED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.PAUSED);\\n }\\n\\n /// @notice Disables the given application. The disabled application can't\\n /// slash stakers. Also stakers can't increase authorization to that\\n /// application but can decrease without waiting by calling\\n /// `forceDecreaseAuthorization` at any moment. Can be called only\\n /// by the governance. The disabled application can't be approved\\n /// again. Should be used only in case of an emergency.\\n function disableApplication(address application)\\n external\\n override\\n onlyGovernance\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED ||\\n applicationStruct.status == ApplicationStatus.PAUSED,\\n \\\"Can't disable application\\\"\\n );\\n applicationStruct.status = ApplicationStatus.DISABLED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.DISABLED);\\n }\\n\\n /// @notice Sets the Panic Button role for the given application to the\\n /// provided address. Can only be called by the Governance. If the\\n /// Panic Button for the given application should be disabled, the\\n /// role address should be set to 0x0 address.\\n function setPanicButton(address application, address panicButton)\\n external\\n override\\n onlyGovernance\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n applicationStruct.panicButton = panicButton;\\n emit PanicButtonSet(application, panicButton);\\n }\\n\\n /// @notice Sets the maximum number of applications one staking provider can\\n /// have authorized. Used to protect against DoSing slashing queue.\\n /// Can only be called by the Governance.\\n function setAuthorizationCeiling(uint256 ceiling)\\n external\\n override\\n onlyGovernance\\n {\\n authorizationCeiling = ceiling;\\n emit AuthorizationCeilingSet(ceiling);\\n }\\n\\n //\\n //\\n // Stake top-up\\n //\\n //\\n\\n /// @notice Increases the amount of the stake for the given staking provider.\\n /// @dev The sender of this transaction needs to have the amount approved to\\n /// transfer to the staking contract.\\n function topUp(address stakingProvider, uint96 amount) external override {\\n require(\\n stakingProviders[stakingProvider].owner != address(0),\\n \\\"Nothing to top-up\\\"\\n );\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n stakingProviderStruct.tStake += amount;\\n emit ToppedUp(stakingProvider, amount);\\n increaseStakeCheckpoint(stakingProvider, amount);\\n token.safeTransferFrom(msg.sender, address(this), amount);\\n }\\n\\n /// @notice Propagates information about stake top-up from the legacy KEEP\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpKeep(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 tAmount = getKeepAmountInT(stakingProvider);\\n require(\\n tAmount > stakingProviderStruct.keepInTStake,\\n \\\"Nothing to top-up\\\"\\n );\\n\\n uint96 toppedUp = tAmount - stakingProviderStruct.keepInTStake;\\n emit ToppedUp(stakingProvider, toppedUp);\\n stakingProviderStruct.keepInTStake = tAmount;\\n increaseStakeCheckpoint(stakingProvider, toppedUp);\\n }\\n\\n /// @notice Propagates information about stake top-up from the legacy NU\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpNu(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 tAmount = getNuAmountInT(\\n stakingProviderStruct.owner,\\n stakingProvider\\n );\\n require(\\n tAmount > stakingProviderStruct.nuInTStake,\\n \\\"Nothing to top-up\\\"\\n );\\n\\n uint96 toppedUp = tAmount - stakingProviderStruct.nuInTStake;\\n emit ToppedUp(stakingProvider, toppedUp);\\n stakingProviderStruct.nuInTStake = tAmount;\\n increaseStakeCheckpoint(stakingProvider, toppedUp);\\n }\\n\\n //\\n //\\n // Undelegating a stake (unstaking)\\n //\\n //\\n\\n /// @notice Reduces the liquid T stake amount by the provided amount and\\n /// withdraws T to the owner. Reverts if there is at least one\\n /// authorization higher than the sum of the legacy stake and\\n /// remaining liquid T stake or if the unstake amount is higher than\\n /// the liquid T stake amount. Can be called only by the owner or\\n /// the staking provider. Can only be called when 24h passed since\\n /// the stake has been delegated.\\n function unstakeT(address stakingProvider, uint96 amount)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n amount > 0 &&\\n amount + getMinStaked(stakingProvider, StakeType.T) <=\\n stakingProviderStruct.tStake,\\n \\\"Too much to unstake\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n stakingProviderStruct.tStake -= amount;\\n decreaseStakeCheckpoint(stakingProvider, amount);\\n emit Unstaked(stakingProvider, amount);\\n token.safeTransfer(stakingProviderStruct.owner, amount);\\n }\\n\\n /// @notice Sets the legacy KEEP staking contract active stake amount cached\\n /// in T staking contract to 0. Reverts if the amount of liquid T\\n /// staked in T staking contract is lower than the highest\\n /// application authorization. This function allows to unstake from\\n /// KEEP staking contract and still being able to operate in T\\n /// network and earning rewards based on the liquid T staked. Can be\\n /// called only by the delegation owner or the staking provider.\\n /// Can only be called when 24h passed since the stake has been\\n /// delegated.\\n /// @dev This function (or `unstakeAll`) must be called before\\n /// `undelegate`/`undelegateAt` in Keep staking contract. Otherwise\\n /// provider can be slashed by `notifyKeepStakeDiscrepancy` method.\\n function unstakeKeep(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 keepInTStake = stakingProviderStruct.keepInTStake;\\n require(keepInTStake != 0, \\\"Nothing to unstake\\\");\\n require(\\n getMinStaked(stakingProvider, StakeType.KEEP) == 0,\\n \\\"Keep stake still authorized\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n emit Unstaked(stakingProvider, keepInTStake);\\n stakingProviderStruct.keepInTStake = 0;\\n decreaseStakeCheckpoint(stakingProvider, keepInTStake);\\n }\\n\\n /// @notice Reduces cached legacy NU stake amount by the provided amount.\\n /// Reverts if there is at least one authorization higher than the\\n /// sum of remaining legacy NU stake and liquid T stake for that\\n /// staking provider or if the untaked amount is higher than the\\n /// cached legacy stake amount. If succeeded, the legacy NU stake\\n /// can be partially or fully undelegated on the legacy staking\\n /// contract. This function allows to unstake from NU staking\\n /// contract and still being able to operate in T network and\\n /// earning rewards based on the liquid T staked. Can be called only\\n /// by the delegation owner or the staking provider. Can only be\\n /// called when 24h passed since the stake has been delegated.\\n /// @dev This function (or `unstakeAll`) must be called before `withdraw`\\n /// in NuCypher staking contract. Otherwise NU tokens can't be\\n /// unlocked.\\n /// @param stakingProvider Staking provider address\\n /// @param amount Amount of NU to unstake in T denomination\\n function unstakeNu(address stakingProvider, uint96 amount)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n // rounding amount to guarantee exact T<>NU conversion in both ways,\\n // so there's no remainder after unstaking\\n (, uint96 tRemainder) = convertFromT(amount, nucypherRatio);\\n amount -= tRemainder;\\n require(\\n amount > 0 &&\\n amount + getMinStaked(stakingProvider, StakeType.NU) <=\\n stakingProviderStruct.nuInTStake,\\n \\\"Too much to unstake\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n stakingProviderStruct.nuInTStake -= amount;\\n decreaseStakeCheckpoint(stakingProvider, amount);\\n emit Unstaked(stakingProvider, amount);\\n }\\n\\n /// @notice Sets cached legacy stake amount to 0, sets the liquid T stake\\n /// amount to 0 and withdraws all liquid T from the stake to the\\n /// owner. Reverts if there is at least one non-zero authorization.\\n /// Can be called only by the delegation owner or the staking\\n /// provider. Can only be called when 24h passed since the stake\\n /// has been delegated.\\n function unstakeAll(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n stakingProviderStruct.authorizedApplications.length == 0,\\n \\\"Stake still authorized\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n uint96 unstaked = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n emit Unstaked(stakingProvider, unstaked);\\n uint96 amount = stakingProviderStruct.tStake;\\n stakingProviderStruct.tStake = 0;\\n stakingProviderStruct.keepInTStake = 0;\\n stakingProviderStruct.nuInTStake = 0;\\n decreaseStakeCheckpoint(stakingProvider, unstaked);\\n\\n if (amount > 0) {\\n token.safeTransfer(stakingProviderStruct.owner, amount);\\n }\\n }\\n\\n //\\n //\\n // Keeping information in sync\\n //\\n //\\n\\n /// @notice Notifies about the discrepancy between legacy KEEP active stake\\n /// and the amount cached in T staking contract. Slashes the staking\\n /// provider in case the amount cached is higher than the actual\\n /// active stake amount in KEEP staking contract. Needs to update\\n /// authorizations of all affected applications and execute an\\n /// involuntary authorization decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyKeepStakeDiscrepancy(address stakingProvider)\\n external\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(stakingProviderStruct.keepInTStake > 0, \\\"Nothing to slash\\\");\\n\\n (uint256 keepStakeAmount, , uint256 undelegatedAt) = keepStakingContract\\n .getDelegationInfo(stakingProvider);\\n\\n (uint96 realKeepInTStake, ) = convertToT(keepStakeAmount, keepRatio);\\n uint96 oldKeepInTStake = stakingProviderStruct.keepInTStake;\\n\\n require(\\n oldKeepInTStake > realKeepInTStake || undelegatedAt != 0,\\n \\\"There is no discrepancy\\\"\\n );\\n stakingProviderStruct.keepInTStake = realKeepInTStake;\\n seizeKeep(\\n stakingProviderStruct,\\n stakingProvider,\\n stakeDiscrepancyPenalty,\\n stakeDiscrepancyRewardMultiplier\\n );\\n\\n uint96 slashedAmount = realKeepInTStake -\\n stakingProviderStruct.keepInTStake;\\n emit TokensSeized(stakingProvider, slashedAmount, true);\\n if (undelegatedAt != 0) {\\n stakingProviderStruct.keepInTStake = 0;\\n }\\n\\n decreaseStakeCheckpoint(\\n stakingProvider,\\n oldKeepInTStake - stakingProviderStruct.keepInTStake\\n );\\n\\n authorizationDecrease(\\n stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n }\\n\\n /// @notice Notifies about the discrepancy between legacy NU active stake\\n /// and the amount cached in T staking contract. Slashes the\\n /// staking provider in case the amount cached is higher than the\\n /// actual active stake amount in NU staking contract. Needs to\\n /// update authorizations of all affected applications and execute an\\n /// involuntary authorization decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n /// @dev Real discrepancy between T and Nu is impossible.\\n /// This method is a safeguard in case of bugs in NuCypher staking\\n /// contract\\n function notifyNuStakeDiscrepancy(address stakingProvider)\\n external\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(stakingProviderStruct.nuInTStake > 0, \\\"Nothing to slash\\\");\\n\\n uint256 nuStakeAmount = nucypherStakingContract.getAllTokens(\\n stakingProviderStruct.owner\\n );\\n (uint96 realNuInTStake, ) = convertToT(nuStakeAmount, nucypherRatio);\\n uint96 oldNuInTStake = stakingProviderStruct.nuInTStake;\\n require(oldNuInTStake > realNuInTStake, \\\"There is no discrepancy\\\");\\n\\n stakingProviderStruct.nuInTStake = realNuInTStake;\\n seizeNu(\\n stakingProviderStruct,\\n stakeDiscrepancyPenalty,\\n stakeDiscrepancyRewardMultiplier\\n );\\n\\n uint96 slashedAmount = realNuInTStake -\\n stakingProviderStruct.nuInTStake;\\n emit TokensSeized(stakingProvider, slashedAmount, true);\\n authorizationDecrease(\\n stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n decreaseStakeCheckpoint(\\n stakingProvider,\\n oldNuInTStake - stakingProviderStruct.nuInTStake\\n );\\n }\\n\\n /// @notice Sets the penalty amount for stake discrepancy and reward\\n /// multiplier for reporting it. The penalty is seized from the\\n /// delegated stake, and 5% of the penalty, scaled by the\\n /// multiplier, is given to the notifier. The rest of the tokens are\\n /// burned. Can only be called by the Governance. See `seize` function.\\n function setStakeDiscrepancyPenalty(\\n uint96 penalty,\\n uint256 rewardMultiplier\\n ) external override onlyGovernance {\\n stakeDiscrepancyPenalty = penalty;\\n stakeDiscrepancyRewardMultiplier = rewardMultiplier;\\n emit StakeDiscrepancyPenaltySet(penalty, rewardMultiplier);\\n }\\n\\n /// @notice Sets reward in T tokens for notification of misbehaviour\\n /// of one staking provider. Can only be called by the governance.\\n function setNotificationReward(uint96 reward)\\n external\\n override\\n onlyGovernance\\n {\\n notificationReward = reward;\\n emit NotificationRewardSet(reward);\\n }\\n\\n /// @notice Transfer some amount of T tokens as reward for notifications\\n /// of misbehaviour\\n function pushNotificationReward(uint96 reward) external override {\\n require(reward > 0, \\\"Parameters must be specified\\\");\\n notifiersTreasury += reward;\\n emit NotificationRewardPushed(reward);\\n token.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraw some amount of T tokens from notifiers treasury.\\n /// Can only be called by the governance.\\n function withdrawNotificationReward(address recipient, uint96 amount)\\n external\\n override\\n onlyGovernance\\n {\\n require(amount <= notifiersTreasury, \\\"Not enough tokens\\\");\\n notifiersTreasury -= amount;\\n emit NotificationRewardWithdrawn(recipient, amount);\\n token.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount that should be slashed from each one of them. Can only be\\n /// called by application authorized for all staking providers in\\n /// the array.\\n /// @dev This method doesn't emit events for providers that are added to\\n /// the queue. If necessary events can be added to the application\\n /// level.\\n function slash(uint96 amount, address[] memory _stakingProviders)\\n external\\n override\\n {\\n notify(amount, 0, address(0), _stakingProviders);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each provider from\\n /// notifiers treasury. Can only be called by application\\n /// authorized for all staking providers in the array.\\n /// @dev This method doesn't emit events for staking providers that are\\n /// added to the queue. If necessary events can be added to the\\n /// application level.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) external override {\\n notify(amount, rewardMultiplier, notifier, _stakingProviders);\\n }\\n\\n /// @notice Takes the given number of queued slashing operations and\\n /// processes them. Receives 5% of the slashed amount.\\n /// Executes `involuntaryAuthorizationDecrease` function on each\\n /// affected application.\\n function processSlashing(uint256 count) external virtual override {\\n require(\\n slashingQueueIndex < slashingQueue.length && count > 0,\\n \\\"Nothing to process\\\"\\n );\\n\\n uint256 maxIndex = slashingQueueIndex + count;\\n maxIndex = MathUpgradeable.min(maxIndex, slashingQueue.length);\\n count = maxIndex - slashingQueueIndex;\\n uint96 tAmountToBurn = 0;\\n\\n uint256 index = slashingQueueIndex;\\n for (; index < maxIndex; index++) {\\n SlashingEvent storage slashing = slashingQueue[index];\\n tAmountToBurn += processSlashing(slashing);\\n }\\n slashingQueueIndex = index;\\n\\n uint256 tProcessorReward = uint256(tAmountToBurn).percent(\\n SLASHING_REWARD_PERCENT\\n );\\n notifiersTreasury += tAmountToBurn - tProcessorReward.toUint96();\\n emit SlashingProcessed(msg.sender, count, tProcessorReward);\\n if (tProcessorReward > 0) {\\n token.safeTransfer(msg.sender, tProcessorReward);\\n }\\n }\\n\\n /// @notice Delegate voting power from the stake associated to the\\n /// `stakingProvider` to a `delegatee` address. Caller must be the\\n /// owner of this stake.\\n function delegateVoting(address stakingProvider, address delegatee)\\n external\\n {\\n delegate(stakingProvider, delegatee);\\n }\\n\\n /// @notice Transfers ownership of the contract to `newGuvnor`.\\n function transferGovernance(address newGuvnor)\\n external\\n virtual\\n onlyGovernance\\n {\\n _transferGovernance(newGuvnor);\\n }\\n\\n //\\n //\\n // Auxiliary functions\\n //\\n //\\n\\n /// @notice Returns the authorized stake amount of the staking provider for\\n /// the application.\\n function authorizedStake(address stakingProvider, address application)\\n external\\n view\\n override\\n returns (uint96)\\n {\\n return\\n stakingProviders[stakingProvider]\\n .authorizations[application]\\n .authorized;\\n }\\n\\n /// @notice Returns staked amount of T, Keep and Nu for the specified\\n /// staking provider.\\n /// @dev All values are in T denomination\\n function stakes(address stakingProvider)\\n external\\n view\\n override\\n returns (\\n uint96 tStake,\\n uint96 keepInTStake,\\n uint96 nuInTStake\\n )\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n tStake = stakingProviderStruct.tStake;\\n keepInTStake = stakingProviderStruct.keepInTStake;\\n nuInTStake = stakingProviderStruct.nuInTStake;\\n }\\n\\n /// @notice Returns start staking timestamp.\\n /// @dev This value is set at most once.\\n function getStartStakingTimestamp(address stakingProvider)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return stakingProviders[stakingProvider].startStakingTimestamp;\\n }\\n\\n /// @notice Returns staked amount of NU for the specified staking provider.\\n function stakedNu(address stakingProvider)\\n external\\n view\\n override\\n returns (uint256 nuAmount)\\n {\\n (nuAmount, ) = convertFromT(\\n stakingProviders[stakingProvider].nuInTStake,\\n nucypherRatio\\n );\\n }\\n\\n /// @notice Gets the stake owner, the beneficiary and the authorizer\\n /// for the specified staking provider address.\\n /// @return owner Stake owner address.\\n /// @return beneficiary Beneficiary address.\\n /// @return authorizer Authorizer address.\\n function rolesOf(address stakingProvider)\\n external\\n view\\n override\\n returns (\\n address owner,\\n address payable beneficiary,\\n address authorizer\\n )\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n owner = stakingProviderStruct.owner;\\n beneficiary = stakingProviderStruct.beneficiary;\\n authorizer = stakingProviderStruct.authorizer;\\n }\\n\\n /// @notice Returns length of application array\\n function getApplicationsLength() external view override returns (uint256) {\\n return applications.length;\\n }\\n\\n /// @notice Returns length of slashing queue\\n function getSlashingQueueLength() external view override returns (uint256) {\\n return slashingQueue.length;\\n }\\n\\n /// @notice Requests decrease of the authorization for the given staking\\n /// provider on the given application by the provided amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application if the application agrees for that. If the\\n /// application does not agree for overwriting, the function\\n /// reverts.\\n /// @dev Calls `authorizationDecreaseRequested` callback on the given\\n /// application. See `IApplication`.\\n function requestAuthorizationDecrease(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) public override onlyAuthorizerOf(stakingProvider) {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n\\n AppAuthorization storage authorization = stakingProviders[\\n stakingProvider\\n ].authorizations[application];\\n require(\\n authorization.authorized >= amount,\\n \\\"Amount exceeds authorized\\\"\\n );\\n\\n authorization.deauthorizing = amount;\\n uint96 deauthorizingTo = authorization.authorized - amount;\\n emit AuthorizationDecreaseRequested(\\n stakingProvider,\\n application,\\n authorization.authorized,\\n deauthorizingTo\\n );\\n IApplication(application).authorizationDecreaseRequested(\\n stakingProvider,\\n authorization.authorized,\\n deauthorizingTo\\n );\\n }\\n\\n /// @notice Returns minimum possible stake for T, KEEP or NU in T denomination\\n /// @dev For example, suppose the given staking provider has 10 T, 20 T worth\\n /// of KEEP, and 30 T worth of NU all staked, and the maximum\\n /// application authorization is 40 T, then `getMinStaked` for\\n /// that staking provider returns:\\n /// * 0 T if KEEP stake type specified i.e.\\n /// min = 40 T max - (10 T + 30 T worth of NU) = 0 T\\n /// * 10 T if NU stake type specified i.e.\\n /// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T\\n /// * 0 T if T stake type specified i.e.\\n /// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T\\n /// In other words, the minimum stake amount for the specified\\n /// stake type is the minimum amount of stake of the given type\\n /// needed to satisfy the maximum application authorization given\\n /// the staked amounts of the other stake types for that staking\\n /// provider.\\n function getMinStaked(address stakingProvider, StakeType stakeTypes)\\n public\\n view\\n override\\n returns (uint96)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint256 maxAuthorization = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address application = stakingProviderStruct.authorizedApplications[\\n i\\n ];\\n maxAuthorization = MathUpgradeable.max(\\n maxAuthorization,\\n stakingProviderStruct.authorizations[application].authorized\\n );\\n }\\n\\n if (maxAuthorization == 0) {\\n return 0;\\n }\\n if (stakeTypes != StakeType.T) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.tStake\\n );\\n }\\n if (stakeTypes != StakeType.NU) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.nuInTStake\\n );\\n }\\n if (stakeTypes != StakeType.KEEP) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.keepInTStake\\n );\\n }\\n return maxAuthorization.toUint96();\\n }\\n\\n /// @notice Returns available amount to authorize for the specified\\n /// application.\\n function getAvailableToAuthorize(\\n address stakingProvider,\\n address application\\n ) public view override returns (uint96 availableTValue) {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n availableTValue =\\n stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n availableTValue -= stakingProviderStruct\\n .authorizations[application]\\n .authorized;\\n }\\n\\n /// @notice Delegate voting power from the stake associated to the\\n /// `stakingProvider` to a `delegatee` address. Caller must be the owner\\n /// of this stake.\\n /// @dev Original abstract function defined in Checkpoints contract had two\\n /// parameters, `delegator` and `delegatee`. Here we override it and\\n /// comply with the same signature but the semantics of the first\\n /// parameter changes to the `stakingProvider` address.\\n function delegate(address stakingProvider, address delegatee)\\n internal\\n virtual\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n stakingProviderStruct.owner == msg.sender,\\n \\\"Caller is not owner\\\"\\n );\\n uint96 stakingProviderBalance = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n address oldDelegatee = delegates(stakingProvider);\\n _delegates[stakingProvider] = delegatee;\\n emit DelegateChanged(stakingProvider, oldDelegatee, delegatee);\\n moveVotingPower(oldDelegatee, delegatee, stakingProviderBalance);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each staking\\n /// provider from notifiers treasury. Can only be called by\\n /// application authorized for all staking providers in the array.\\n function notify(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) internal {\\n require(\\n amount > 0 && _stakingProviders.length > 0,\\n \\\"Parameters must be specified\\\"\\n );\\n\\n ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n uint256 queueLength = slashingQueue.length;\\n for (uint256 i = 0; i < _stakingProviders.length; i++) {\\n address stakingProvider = _stakingProviders[i];\\n uint256 amountToSlash = MathUpgradeable.min(\\n stakingProviders[stakingProvider]\\n .authorizations[msg.sender]\\n .authorized,\\n amount\\n );\\n if (\\n //slither-disable-next-line incorrect-equality\\n amountToSlash == 0\\n ) {\\n continue;\\n }\\n slashingQueue.push(\\n SlashingEvent(stakingProvider, amountToSlash.toUint96())\\n );\\n }\\n\\n if (notifier != address(0)) {\\n uint256 reward = ((slashingQueue.length - queueLength) *\\n notificationReward).percent(rewardMultiplier);\\n reward = MathUpgradeable.min(reward, notifiersTreasury);\\n emit NotifierRewarded(notifier, reward);\\n if (reward != 0) {\\n notifiersTreasury -= reward;\\n token.safeTransfer(notifier, reward);\\n }\\n }\\n }\\n\\n /// @notice Processes one specified slashing event.\\n /// Executes `involuntaryAuthorizationDecrease` function on each\\n /// affected application.\\n //slither-disable-next-line dead-code\\n function processSlashing(SlashingEvent storage slashing)\\n internal\\n returns (uint96 tAmountToBurn)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n slashing.stakingProvider\\n ];\\n uint96 tAmountToSlash = slashing.amount;\\n uint96 oldStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n // slash T\\n if (stakingProviderStruct.tStake > 0) {\\n if (tAmountToSlash <= stakingProviderStruct.tStake) {\\n tAmountToBurn = tAmountToSlash;\\n } else {\\n tAmountToBurn = stakingProviderStruct.tStake;\\n }\\n stakingProviderStruct.tStake -= tAmountToBurn;\\n tAmountToSlash -= tAmountToBurn;\\n }\\n\\n // slash KEEP\\n if (tAmountToSlash > 0 && stakingProviderStruct.keepInTStake > 0) {\\n (uint256 keepStakeAmount, , ) = keepStakingContract\\n .getDelegationInfo(slashing.stakingProvider);\\n (uint96 tAmount, ) = convertToT(keepStakeAmount, keepRatio);\\n stakingProviderStruct.keepInTStake = tAmount;\\n\\n tAmountToSlash = seizeKeep(\\n stakingProviderStruct,\\n slashing.stakingProvider,\\n tAmountToSlash,\\n 100\\n );\\n }\\n\\n // slash NU\\n if (tAmountToSlash > 0 && stakingProviderStruct.nuInTStake > 0) {\\n // synchronization skipped due to impossibility of real discrepancy\\n tAmountToSlash = seizeNu(\\n stakingProviderStruct,\\n tAmountToSlash,\\n 100\\n );\\n }\\n\\n uint96 slashedAmount = slashing.amount - tAmountToSlash;\\n emit TokensSeized(slashing.stakingProvider, slashedAmount, false);\\n authorizationDecrease(\\n slashing.stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n uint96 newStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n decreaseStakeCheckpoint(slashing.stakingProvider, oldStake - newStake);\\n }\\n\\n /// @notice Synchronize authorizations (if needed) after slashing stake\\n function authorizationDecrease(\\n address stakingProvider,\\n StakingProviderInfo storage stakingProviderStruct,\\n uint96 slashedAmount\\n ) internal {\\n uint96 totalStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.nuInTStake +\\n stakingProviderStruct.keepInTStake;\\n uint256 applicationsToDelete = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address authorizedApplication = stakingProviderStruct\\n .authorizedApplications[i];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[authorizedApplication];\\n uint96 fromAmount = authorization.authorized;\\n\\n authorization.authorized -= MathUpgradeable\\n .min(fromAmount, slashedAmount)\\n .toUint96();\\n\\n if (authorization.authorized > totalStake) {\\n authorization.authorized = totalStake;\\n }\\n\\n bool successful = true;\\n //slither-disable-next-line calls-loop\\n try\\n IApplication(authorizedApplication)\\n .involuntaryAuthorizationDecrease{\\n gas: GAS_LIMIT_AUTHORIZATION_DECREASE\\n }(stakingProvider, fromAmount, authorization.authorized)\\n {} catch {\\n successful = false;\\n }\\n if (authorization.deauthorizing > authorization.authorized) {\\n authorization.deauthorizing = authorization.authorized;\\n }\\n emit AuthorizationInvoluntaryDecreased(\\n stakingProvider,\\n authorizedApplication,\\n fromAmount,\\n authorization.authorized,\\n successful\\n );\\n if (authorization.authorized == 0) {\\n applicationsToDelete++;\\n }\\n }\\n if (applicationsToDelete > 0) {\\n cleanAuthorizedApplications(\\n stakingProviderStruct,\\n applicationsToDelete\\n );\\n }\\n }\\n\\n /// @notice Convert amount from T to Keep and call `seize` in Keep staking contract.\\n /// Returns remainder of slashing amount in T\\n /// @dev Note this internal function doesn't update stake checkpoints\\n function seizeKeep(\\n StakingProviderInfo storage stakingProviderStruct,\\n address stakingProvider,\\n uint96 tAmountToSlash,\\n uint256 rewardMultiplier\\n ) internal returns (uint96) {\\n if (stakingProviderStruct.keepInTStake == 0) {\\n return tAmountToSlash;\\n }\\n\\n uint96 tPenalty;\\n if (tAmountToSlash <= stakingProviderStruct.keepInTStake) {\\n tPenalty = tAmountToSlash;\\n } else {\\n tPenalty = stakingProviderStruct.keepInTStake;\\n }\\n\\n (uint256 keepPenalty, uint96 tRemainder) = convertFromT(\\n tPenalty,\\n keepRatio\\n );\\n if (keepPenalty == 0) {\\n return tAmountToSlash;\\n }\\n tPenalty -= tRemainder;\\n stakingProviderStruct.keepInTStake -= tPenalty;\\n tAmountToSlash -= tPenalty;\\n\\n address[] memory stakingProviderWrapper = new address[](1);\\n stakingProviderWrapper[0] = stakingProvider;\\n keepStakingContract.seize(\\n keepPenalty,\\n rewardMultiplier,\\n msg.sender,\\n stakingProviderWrapper\\n );\\n return tAmountToSlash;\\n }\\n\\n /// @notice Convert amount from T to NU and call `slashStaker` in NuCypher staking contract.\\n /// Returns remainder of slashing amount in T\\n /// @dev Note this internal function doesn't update the stake checkpoints\\n function seizeNu(\\n StakingProviderInfo storage stakingProviderStruct,\\n uint96 tAmountToSlash,\\n uint256 rewardMultiplier\\n ) internal returns (uint96) {\\n if (stakingProviderStruct.nuInTStake == 0) {\\n return tAmountToSlash;\\n }\\n\\n uint96 tPenalty;\\n if (tAmountToSlash <= stakingProviderStruct.nuInTStake) {\\n tPenalty = tAmountToSlash;\\n } else {\\n tPenalty = stakingProviderStruct.nuInTStake;\\n }\\n\\n (uint256 nuPenalty, uint96 tRemainder) = convertFromT(\\n tPenalty,\\n nucypherRatio\\n );\\n if (nuPenalty == 0) {\\n return tAmountToSlash;\\n }\\n tPenalty -= tRemainder;\\n stakingProviderStruct.nuInTStake -= tPenalty;\\n tAmountToSlash -= tPenalty;\\n\\n uint256 nuReward = nuPenalty.percent(SLASHING_REWARD_PERCENT).percent(\\n rewardMultiplier\\n );\\n nucypherStakingContract.slashStaker(\\n stakingProviderStruct.owner,\\n nuPenalty,\\n msg.sender,\\n nuReward\\n );\\n return tAmountToSlash;\\n }\\n\\n /// @notice Removes application with zero authorization from authorized\\n /// applications array\\n function cleanAuthorizedApplications(\\n StakingProviderInfo storage stakingProviderStruct,\\n uint256 numberToDelete\\n ) internal {\\n uint256 length = stakingProviderStruct.authorizedApplications.length;\\n if (numberToDelete == length) {\\n delete stakingProviderStruct.authorizedApplications;\\n return;\\n }\\n\\n uint256 deleted = 0;\\n uint256 index = 0;\\n uint256 newLength = length - numberToDelete;\\n while (index < newLength && deleted < numberToDelete) {\\n address application = stakingProviderStruct.authorizedApplications[\\n index\\n ];\\n if (\\n stakingProviderStruct.authorizations[application].authorized ==\\n 0\\n ) {\\n stakingProviderStruct.authorizedApplications[\\n index\\n ] = stakingProviderStruct.authorizedApplications[\\n length - deleted - 1\\n ];\\n deleted++;\\n } else {\\n index++;\\n }\\n }\\n\\n for (index = newLength; index < length; index++) {\\n stakingProviderStruct.authorizedApplications.pop();\\n }\\n }\\n\\n /// @notice Creates new checkpoints due to a change of stake amount\\n /// @param _delegator Address of the staking provider acting as delegator\\n /// @param _amount Amount of T to increment\\n /// @param increase True if the change is an increase, false if a decrease\\n function newStakeCheckpoint(\\n address _delegator,\\n uint96 _amount,\\n bool increase\\n ) internal {\\n if (_amount == 0) {\\n return;\\n }\\n writeCheckpoint(\\n _totalSupplyCheckpoints,\\n increase ? add : subtract,\\n _amount\\n );\\n address delegatee = delegates(_delegator);\\n if (delegatee != address(0)) {\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[delegatee],\\n increase ? add : subtract,\\n _amount\\n );\\n emit DelegateVotesChanged(delegatee, oldWeight, newWeight);\\n }\\n }\\n\\n /// @notice Creates new checkpoints due to an increment of a stakers' stake\\n /// @param _delegator Address of the staking provider acting as delegator\\n /// @param _amount Amount of T to increment\\n function increaseStakeCheckpoint(address _delegator, uint96 _amount)\\n internal\\n {\\n newStakeCheckpoint(_delegator, _amount, true);\\n }\\n\\n /// @notice Creates new checkpoints due to a decrease of a stakers' stake\\n /// @param _delegator Address of the stake owner acting as delegator\\n /// @param _amount Amount of T to decrease\\n function decreaseStakeCheckpoint(address _delegator, uint96 _amount)\\n internal\\n {\\n newStakeCheckpoint(_delegator, _amount, false);\\n }\\n\\n /// @notice Returns amount of Nu stake in the NuCypher staking contract for\\n /// the specified staking provider.\\n /// Resulting value in T denomination\\n function getNuAmountInT(address owner, address stakingProvider)\\n internal\\n returns (uint96)\\n {\\n uint256 nuStakeAmount = nucypherStakingContract.requestMerge(\\n owner,\\n stakingProvider\\n );\\n (uint96 tAmount, ) = convertToT(nuStakeAmount, nucypherRatio);\\n return tAmount;\\n }\\n\\n function _transferGovernance(address newGuvnor) internal virtual {\\n address oldGuvnor = governance;\\n governance = newGuvnor;\\n emit GovernanceTransferred(oldGuvnor, newGuvnor);\\n }\\n\\n /// @notice Returns amount of Keep stake in the Keep staking contract for\\n /// the specified staking provider.\\n /// Resulting value in T denomination\\n function getKeepAmountInT(address stakingProvider)\\n internal\\n view\\n returns (uint96)\\n {\\n uint256 keepStakeAmount = keepStakingContract.eligibleStake(\\n stakingProvider,\\n address(this)\\n );\\n (uint96 tAmount, ) = convertToT(keepStakeAmount, keepRatio);\\n return tAmount;\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` legacy\\n /// tokens for the given `ratio`, and the remainder that can't be\\n /// converted.\\n function convertToT(uint256 amount, uint256 ratio)\\n internal\\n pure\\n returns (uint96 tAmount, uint256 remainder)\\n {\\n remainder = amount % CONVERSION_DIVISOR;\\n uint256 convertibleAmount = amount - remainder;\\n tAmount = ((convertibleAmount * ratio) / CONVERSION_DIVISOR).toUint96();\\n }\\n\\n /// @notice Returns the amount of legacy tokens that's obtained from\\n /// `tAmount` T tokens for the given `ratio`, and the T remainder\\n /// that can't be converted.\\n function convertFromT(uint96 tAmount, uint256 ratio)\\n internal\\n pure\\n returns (uint256 amount, uint96 tRemainder)\\n {\\n //slither-disable-next-line weak-prng\\n tRemainder = (tAmount % ratio).toUint96();\\n uint256 convertibleAmount = tAmount - tRemainder;\\n amount = (convertibleAmount * CONVERSION_DIVISOR) / ratio;\\n }\\n}\\n\",\"keccak256\":\"0x1e8bd3195d5de9e9fb941c0aafee00c2892055c616a5931367fed6f5aa0b946f\",\"license\":\"GPL-3.0-or-later\"},\"contracts/test/TokenStakingTestSet.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"../staking/ILegacyTokenStaking.sol\\\";\\nimport \\\"../staking/IApplication.sol\\\";\\nimport \\\"../staking/TokenStaking.sol\\\";\\n\\ncontract KeepTokenStakingMock is IKeepTokenStaking {\\n using PercentUtils for uint256;\\n\\n struct OperatorStruct {\\n address owner;\\n address payable beneficiary;\\n address authorizer;\\n uint256 createdAt;\\n uint256 undelegatedAt;\\n uint256 amount;\\n mapping(address => bool) eligibility;\\n }\\n\\n mapping(address => OperatorStruct) internal operators;\\n mapping(address => uint256) public tattletales;\\n\\n function setOperator(\\n address operator,\\n address owner,\\n address payable beneficiary,\\n address authorizer,\\n uint256 createdAt,\\n uint256 undelegatedAt,\\n uint256 amount\\n ) external {\\n OperatorStruct storage operatorStrut = operators[operator];\\n operatorStrut.owner = owner;\\n operatorStrut.beneficiary = beneficiary;\\n operatorStrut.authorizer = authorizer;\\n operatorStrut.createdAt = createdAt;\\n operatorStrut.undelegatedAt = undelegatedAt;\\n operatorStrut.amount = amount;\\n }\\n\\n function setEligibility(\\n address operator,\\n address application,\\n bool isEligible\\n ) external {\\n operators[operator].eligibility[application] = isEligible;\\n }\\n\\n function setAmount(address operator, uint256 amount) external {\\n operators[operator].amount = amount;\\n }\\n\\n function setUndelegatedAt(address operator, uint256 undelegatedAt)\\n external\\n {\\n operators[operator].undelegatedAt = undelegatedAt;\\n }\\n\\n function seize(\\n uint256 amountToSeize,\\n uint256 rewardMultiplier,\\n address tattletale,\\n address[] memory misbehavedOperators\\n ) external override {\\n require(amountToSeize > 0, \\\"Amount to slash must be greater than zero\\\");\\n // assumed only one will be slashed (per call)\\n require(\\n misbehavedOperators.length == 1,\\n \\\"Only one operator per call in tests\\\"\\n );\\n address operator = misbehavedOperators[0];\\n operators[operator].amount -= amountToSeize;\\n tattletales[tattletale] += amountToSeize.percent(5).percent(\\n rewardMultiplier\\n );\\n }\\n\\n function getDelegationInfo(address operator)\\n external\\n view\\n override\\n returns (\\n uint256 amount,\\n uint256 createdAt,\\n uint256 undelegatedAt\\n )\\n {\\n amount = operators[operator].amount;\\n createdAt = operators[operator].createdAt;\\n undelegatedAt = operators[operator].undelegatedAt;\\n }\\n\\n function ownerOf(address operator)\\n external\\n view\\n override\\n returns (address)\\n {\\n return operators[operator].owner;\\n }\\n\\n function beneficiaryOf(address operator)\\n external\\n view\\n override\\n returns (address payable)\\n {\\n return operators[operator].beneficiary;\\n }\\n\\n function authorizerOf(address operator)\\n external\\n view\\n override\\n returns (address)\\n {\\n return operators[operator].authorizer;\\n }\\n\\n function eligibleStake(address operator, address operatorContract)\\n external\\n view\\n override\\n returns (uint256 balance)\\n {\\n OperatorStruct storage operatorStrut = operators[operator];\\n if (operatorStrut.eligibility[operatorContract]) {\\n return operatorStrut.amount;\\n }\\n return 0;\\n }\\n}\\n\\ncontract NuCypherTokenStakingMock is INuCypherStakingEscrow {\\n struct StakerStruct {\\n uint256 value;\\n address stakingProvider;\\n }\\n\\n mapping(address => StakerStruct) public stakers;\\n mapping(address => uint256) public investigators;\\n\\n function setStaker(address staker, uint256 value) external {\\n stakers[staker].value = value;\\n }\\n\\n function slashStaker(\\n address staker,\\n uint256 penalty,\\n address investigator,\\n uint256 reward\\n ) external override {\\n require(penalty > 0, \\\"Amount to slash must be greater than zero\\\");\\n stakers[staker].value -= penalty;\\n investigators[investigator] += reward;\\n }\\n\\n function requestMerge(address staker, address stakingProvider)\\n external\\n override\\n returns (uint256)\\n {\\n StakerStruct storage stakerStruct = stakers[staker];\\n require(\\n stakerStruct.stakingProvider == address(0) ||\\n stakerStruct.stakingProvider == stakingProvider,\\n \\\"Another provider was already set for this staker\\\"\\n );\\n if (stakerStruct.stakingProvider == address(0)) {\\n stakerStruct.stakingProvider = stakingProvider;\\n }\\n return stakers[staker].value;\\n }\\n\\n function getAllTokens(address staker)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return stakers[staker].value;\\n }\\n\\n function stakerInfo(address staker)\\n public\\n view\\n returns (StakerStruct memory)\\n {\\n return stakers[staker];\\n }\\n}\\n\\ncontract VendingMachineMock {\\n uint256 public constant FLOATING_POINT_DIVISOR = 10**15;\\n\\n uint256 public immutable ratio;\\n\\n constructor(uint96 _wrappedTokenAllocation, uint96 _tTokenAllocation) {\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n}\\n\\ncontract ApplicationMock is IApplication {\\n struct StakingProviderStruct {\\n uint96 authorized;\\n uint96 deauthorizingTo;\\n }\\n\\n TokenStaking internal immutable tokenStaking;\\n mapping(address => StakingProviderStruct) public stakingProviders;\\n\\n constructor(TokenStaking _tokenStaking) {\\n tokenStaking = _tokenStaking;\\n }\\n\\n function withdrawRewards(address) external {\\n // does nothing\\n }\\n\\n function authorizationIncreased(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) external override {\\n stakingProviders[stakingProvider].authorized = toAmount;\\n }\\n\\n function authorizationDecreaseRequested(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) external override {\\n stakingProviders[stakingProvider].deauthorizingTo = toAmount;\\n }\\n\\n function approveAuthorizationDecrease(address stakingProvider) external {\\n StakingProviderStruct storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n stakingProviderStruct.authorized = tokenStaking\\n .approveAuthorizationDecrease(stakingProvider);\\n }\\n\\n function slash(uint96 amount, address[] memory _stakingProviders) external {\\n tokenStaking.slash(amount, _stakingProviders);\\n }\\n\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) external {\\n tokenStaking.seize(\\n amount,\\n rewardMultiplier,\\n notifier,\\n _stakingProviders\\n );\\n }\\n\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) public virtual override {\\n StakingProviderStruct storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n toAmount != stakingProviderStruct.authorized,\\n \\\"Nothing to decrease\\\"\\n );\\n uint96 decrease = stakingProviderStruct.authorized - toAmount;\\n if (stakingProviderStruct.deauthorizingTo > decrease) {\\n stakingProviderStruct.deauthorizingTo -= decrease;\\n } else {\\n stakingProviderStruct.deauthorizingTo = 0;\\n }\\n stakingProviderStruct.authorized = toAmount;\\n }\\n\\n function availableRewards(address) external pure returns (uint96) {\\n return 0;\\n }\\n\\n function minimumAuthorization() external pure returns (uint96) {\\n return 0;\\n }\\n}\\n\\ncontract BrokenApplicationMock is ApplicationMock {\\n constructor(TokenStaking _tokenStaking) ApplicationMock(_tokenStaking) {}\\n\\n function involuntaryAuthorizationDecrease(\\n address,\\n uint96,\\n uint96\\n ) public pure override {\\n revert(\\\"Broken application\\\");\\n }\\n}\\n\\ncontract ExpensiveApplicationMock is ApplicationMock {\\n uint256[] private dummy;\\n\\n constructor(TokenStaking _tokenStaking) ApplicationMock(_tokenStaking) {}\\n\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) public override {\\n super.involuntaryAuthorizationDecrease(\\n stakingProvider,\\n fromAmount,\\n toAmount\\n );\\n for (uint256 i = 0; i < 12; i++) {\\n dummy.push(i);\\n }\\n }\\n}\\n\\ncontract ManagedGrantMock {\\n address public grantee;\\n\\n //slither-disable-next-line missing-zero-check\\n function setGrantee(address _grantee) external {\\n grantee = _grantee;\\n }\\n}\\n\\ncontract ExtendedTokenStaking is TokenStaking {\\n constructor(\\n T _token,\\n IKeepTokenStaking _keepStakingContract,\\n INuCypherStakingEscrow _nucypherStakingContract,\\n VendingMachine _keepVendingMachine,\\n VendingMachine _nucypherVendingMachine,\\n KeepStake _keepStake\\n )\\n TokenStaking(\\n _token,\\n _keepStakingContract,\\n _nucypherStakingContract,\\n _keepVendingMachine,\\n _nucypherVendingMachine,\\n _keepStake\\n )\\n {}\\n\\n function cleanAuthorizedApplications(\\n address stakingProvider,\\n uint256 numberToDelete\\n ) external {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n cleanAuthorizedApplications(stakingProviderStruct, numberToDelete);\\n }\\n\\n function setAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external {\\n stakingProviders[stakingProvider]\\n .authorizations[application]\\n .authorized = amount;\\n }\\n\\n function setAuthorizedApplications(\\n address stakingProvider,\\n address[] memory _applications\\n ) external {\\n stakingProviders[stakingProvider]\\n .authorizedApplications = _applications;\\n }\\n\\n // to decrease size of test contract\\n function processSlashing(uint256 count) external override {}\\n\\n function getAuthorizedApplications(address stakingProvider)\\n external\\n view\\n returns (address[] memory)\\n {\\n return stakingProviders[stakingProvider].authorizedApplications;\\n }\\n}\\n\",\"keccak256\":\"0x55bd1a8dc0c354ff3be00489028bd31f95fbf8c75a2c28a41f1b2466a7f955be\",\"license\":\"GPL-3.0-or-later\"},\"contracts/token/T.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 \\\"../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\",\"keccak256\":\"0x6265416225fd15b1108fce13d570b53a862a5d256ba2e6329bccf658eccac430\",\"license\":\"GPL-3.0-or-later\"},\"contracts/utils/PercentUtils.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\\nlibrary PercentUtils {\\n // Return `b`% of `a`\\n // 200.percent(40) == 80\\n // Commutative, works both ways\\n function percent(uint256 a, uint256 b) internal pure returns (uint256) {\\n return (a * b) / 100;\\n }\\n\\n // Return `a` as percentage of `b`:\\n // 80.asPercentOf(200) == 40\\n //slither-disable-next-line dead-code\\n function asPercentOf(uint256 a, uint256 b) internal pure returns (uint256) {\\n return (a * 100) / b;\\n }\\n}\\n\",\"keccak256\":\"0xf5feadeff9d504b33058dfd6c2b99d31ecebc152b356272646a7afe6ed638d40\",\"license\":\"GPL-3.0-or-later\"},\"contracts/utils/SafeTUpgradeable.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 \\\"../token/T.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\n/// @notice A wrapper around OpenZeppelin's `SafeERC20Upgradeable` but specific\\n/// to the T token. Use this library in upgradeable contracts. If your\\n/// contract is non-upgradeable, then the traditional `SafeERC20` works.\\n/// The motivation is to prevent upgradeable contracts that use T from\\n/// depending on the `Address` library, which can be problematic since\\n/// it uses `delegatecall`, which is discouraged by OpenZeppelin for use\\n/// in upgradeable contracts.\\n/// @dev This implementation force-casts T to `IERC20Upgradeable` to make it\\n/// work with `SafeERC20Upgradeable`.\\nlibrary SafeTUpgradeable {\\n function safeTransfer(\\n T token,\\n address to,\\n uint256 value\\n ) internal {\\n SafeERC20Upgradeable.safeTransfer(\\n IERC20Upgradeable(address(token)),\\n to,\\n value\\n );\\n }\\n\\n function safeTransferFrom(\\n T token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n SafeERC20Upgradeable.safeTransferFrom(\\n IERC20Upgradeable(address(token)),\\n from,\\n to,\\n value\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf53907099650f9f973ff51c403730e7ae7170a5728fbde49f0f00b0a17775ce7\",\"license\":\"GPL-3.0-or-later\"},\"contracts/vending/VendingMachine.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 \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\nimport \\\"../token/T.sol\\\";\\n\\n/// @title T token vending machine\\n/// @notice Contract implements a special update protocol to enable KEEP/NU\\n/// token holders to wrap their tokens and obtain T tokens according\\n/// to a fixed ratio. This will go on indefinitely and enable NU and\\n/// KEEP token holders to join T network without needing to buy or\\n/// sell any assets. Logistically, anyone holding NU or KEEP can wrap\\n/// those assets in order to upgrade to T. They can also unwrap T in\\n/// order to downgrade back to the underlying asset. There is a separate\\n/// instance of this contract deployed for KEEP holders and a separate\\n/// instance of this contract deployed for NU holders.\\ncontract VendingMachine is IReceiveApproval {\\n using SafeERC20 for IERC20;\\n using SafeERC20 for T;\\n\\n /// @notice Number of decimal places of precision in conversion to/from\\n /// wrapped tokens (assuming typical ERC20 token with 18 decimals).\\n /// This implies that amounts of wrapped tokens below this precision\\n /// won't take part in the conversion. E.g., for a value of 3, then\\n /// for a conversion of 1.123456789 wrapped tokens, only 1.123 is\\n /// convertible (i.e., 3 decimal places), and 0.000456789 is left.\\n uint256 public constant WRAPPED_TOKEN_CONVERSION_PRECISION = 3;\\n\\n /// @notice Divisor for precision purposes, used to represent fractions.\\n uint256 public constant FLOATING_POINT_DIVISOR =\\n 10**(18 - WRAPPED_TOKEN_CONVERSION_PRECISION);\\n\\n /// @notice The token being wrapped to T (KEEP/NU).\\n IERC20 public immutable wrappedToken;\\n\\n /// @notice T token contract.\\n T public immutable tToken;\\n\\n /// @notice The ratio with which T token is converted based on the provided\\n /// token being wrapped (KEEP/NU), expressed in 1e18 precision.\\n ///\\n /// When wrapping:\\n /// x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR\\n ///\\n /// When unwrapping:\\n /// x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\\n uint256 public immutable ratio;\\n\\n /// @notice The total balance of wrapped tokens for the given holder\\n /// account. Only holders that have previously wrapped KEEP/NU to T\\n /// can unwrap, up to the amount previously wrapped.\\n mapping(address => uint256) public wrappedBalance;\\n\\n event Wrapped(\\n address indexed recipient,\\n uint256 wrappedTokenAmount,\\n uint256 tTokenAmount\\n );\\n event Unwrapped(\\n address indexed recipient,\\n uint256 tTokenAmount,\\n uint256 wrappedTokenAmount\\n );\\n\\n /// @notice Sets the reference to `wrappedToken` and `tToken`. Initializes\\n /// conversion `ratio` between wrapped token and T based on the\\n /// provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\\n /// @param _wrappedToken Address to ERC20 token that will be wrapped to T\\n /// @param _tToken Address of T token\\n /// @param _wrappedTokenAllocation The total supply of the token that will be\\n /// wrapped to T\\n /// @param _tTokenAllocation The allocation of T this instance of Vending\\n /// Machine will receive\\n /// @dev Multiplications in this contract can't overflow uint256 as we\\n /// restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to\\n /// 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\\n constructor(\\n IERC20 _wrappedToken,\\n T _tToken,\\n uint96 _wrappedTokenAllocation,\\n uint96 _tTokenAllocation\\n ) {\\n wrappedToken = _wrappedToken;\\n tToken = _tToken;\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n\\n /// @notice Wraps up to the the given `amount` of the token (KEEP/NU) and\\n /// releases T token proportionally to the amount being wrapped with\\n /// respect to the wrap ratio. The token holder needs to have at\\n /// least the given amount of the wrapped token (KEEP/NU) approved\\n /// to transfer to the Vending Machine before calling this function.\\n /// @param amount The amount of KEEP/NU to be wrapped\\n function wrap(uint256 amount) external {\\n _wrap(msg.sender, amount);\\n }\\n\\n /// @notice Wraps up to the given amount of the token (KEEP/NU) and releases\\n /// T token proportionally to the amount being wrapped with respect\\n /// to the wrap ratio. This is a shortcut to `wrap` function that\\n /// avoids a separate approval transaction. Only KEEP/NU token\\n /// is allowed as a caller, so please call this function via\\n /// token's `approveAndCall`.\\n /// @param from Caller's address, must be the same as `wrappedToken` field\\n /// @param amount The amount of KEEP/NU to be wrapped\\n /// @param token Token's address, must be the same as `wrappedToken` field\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(\\n token == address(wrappedToken),\\n \\\"Token is not the wrapped token\\\"\\n );\\n require(\\n msg.sender == address(wrappedToken),\\n \\\"Only wrapped token caller allowed\\\"\\n );\\n _wrap(from, amount);\\n }\\n\\n /// @notice Unwraps up to the given `amount` of T back to the legacy token\\n /// (KEEP/NU) according to the wrap ratio. It can only be called by\\n /// a token holder who previously wrapped their tokens in this\\n /// vending machine contract. The token holder can't unwrap more\\n /// tokens than they originally wrapped. The token holder needs to\\n /// have at least the given amount of T tokens approved to transfer\\n /// to the Vending Machine before calling this function.\\n /// @param amount The amount of T to unwrap back to the collateral (KEEP/NU)\\n function unwrap(uint256 amount) external {\\n _unwrap(msg.sender, amount);\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` wrapped\\n /// tokens (KEEP/NU), and the remainder that can't be upgraded.\\n function conversionToT(uint256 amount)\\n public\\n view\\n returns (uint256 tAmount, uint256 wrappedRemainder)\\n {\\n wrappedRemainder = amount % FLOATING_POINT_DIVISOR;\\n uint256 convertibleAmount = amount - wrappedRemainder;\\n tAmount = (convertibleAmount * ratio) / FLOATING_POINT_DIVISOR;\\n }\\n\\n /// @notice The amount of wrapped tokens (KEEP/NU) that's obtained from\\n /// `amount` T tokens, and the remainder that can't be downgraded.\\n function conversionFromT(uint256 amount)\\n public\\n view\\n returns (uint256 wrappedAmount, uint256 tRemainder)\\n {\\n tRemainder = amount % ratio;\\n uint256 convertibleAmount = amount - tRemainder;\\n wrappedAmount = (convertibleAmount * FLOATING_POINT_DIVISOR) / ratio;\\n }\\n\\n function _wrap(address tokenHolder, uint256 wrappedTokenAmount) internal {\\n (uint256 tTokenAmount, uint256 remainder) = conversionToT(\\n wrappedTokenAmount\\n );\\n wrappedTokenAmount -= remainder;\\n require(wrappedTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n emit Wrapped(tokenHolder, wrappedTokenAmount, tTokenAmount);\\n\\n wrappedBalance[tokenHolder] += wrappedTokenAmount;\\n wrappedToken.safeTransferFrom(\\n tokenHolder,\\n address(this),\\n wrappedTokenAmount\\n );\\n tToken.safeTransfer(tokenHolder, tTokenAmount);\\n }\\n\\n function _unwrap(address tokenHolder, uint256 tTokenAmount) internal {\\n (uint256 wrappedTokenAmount, uint256 remainder) = conversionFromT(\\n tTokenAmount\\n );\\n tTokenAmount -= remainder;\\n require(tTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n require(\\n wrappedBalance[tokenHolder] >= wrappedTokenAmount,\\n \\\"Can not unwrap more than previously wrapped\\\"\\n );\\n\\n emit Unwrapped(tokenHolder, tTokenAmount, wrappedTokenAmount);\\n wrappedBalance[tokenHolder] -= wrappedTokenAmount;\\n tToken.safeTransferFrom(tokenHolder, address(this), tTokenAmount);\\n wrappedToken.safeTransfer(tokenHolder, wrappedTokenAmount);\\n }\\n}\\n\",\"keccak256\":\"0xa4e7de5a9063db09b32ca97fa0fb5d8d1cc7b539387d1b44d74d15d3c2ed4134\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b506104f7806100206000396000f3fe608060405234801561001057600080fd5b506004361061006d5760003560e01c8063178b6de6146100725780633223ff4b146100ae5780633d4fa8e5146100c15780634e745f1f146100ed5780637da5f6a6146101655780639168ae721461018557806399cc218c146101d2575b600080fd5b61009b6100803660046103b9565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61009b6100bc3660046103db565b6101e5565b6100eb6100cf36600461040e565b6001600160a01b03909116600090815260208190526040902055565b005b6101416100fb3660046103b9565b604080518082018252600080825260209182018190526001600160a01b039384168152808252829020825180840190935280548352600101549092169181019190915290565b60408051825181526020928301516001600160a01b031692810192909252016100a5565b61009b6101733660046103b9565b60016020526000908152604090205481565b6101b56101933660046103b9565b600060208190529081526040902080546001909101546001600160a01b031682565b604080519283526001600160a01b039091166020830152016100a5565b6100eb6101e0366004610438565b6102db565b6001600160a01b038083166000908152602081905260408120600181015491929091161580610223575060018101546001600160a01b038481169116145b61028d5760405162461bcd60e51b815260206004820152603060248201527f416e6f746865722070726f76696465722077617320616c72656164792073657460448201526f103337b9103a3434b99039ba30b5b2b960811b60648201526084015b60405180910390fd5b60018101546001600160a01b03166102bd576001810180546001600160a01b0319166001600160a01b0385161790555b5050506001600160a01b031660009081526020819052604090205490565b6000831161033d5760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f20736c617368206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610284565b6001600160a01b03841660009081526020819052604081208054859290610365908490610492565b90915550506001600160a01b038216600090815260016020526040812080548392906103929084906104a9565b909155505050505050565b80356001600160a01b03811681146103b457600080fd5b919050565b6000602082840312156103cb57600080fd5b6103d48261039d565b9392505050565b600080604083850312156103ee57600080fd5b6103f78361039d565b91506104056020840161039d565b90509250929050565b6000806040838503121561042157600080fd5b61042a8361039d565b946020939093013593505050565b6000806000806080858703121561044e57600080fd5b6104578561039d565b93506020850135925061046c6040860161039d565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b6000828210156104a4576104a461047c565b500390565b600082198211156104bc576104bc61047c565b50019056fea2646970667358221220693cead7106fe4e2d7e4a088f822c5ec5acea00860a89e5f30d7e6f1ae0042fe64736f6c63430008090033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061006d5760003560e01c8063178b6de6146100725780633223ff4b146100ae5780633d4fa8e5146100c15780634e745f1f146100ed5780637da5f6a6146101655780639168ae721461018557806399cc218c146101d2575b600080fd5b61009b6100803660046103b9565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61009b6100bc3660046103db565b6101e5565b6100eb6100cf36600461040e565b6001600160a01b03909116600090815260208190526040902055565b005b6101416100fb3660046103b9565b604080518082018252600080825260209182018190526001600160a01b039384168152808252829020825180840190935280548352600101549092169181019190915290565b60408051825181526020928301516001600160a01b031692810192909252016100a5565b61009b6101733660046103b9565b60016020526000908152604090205481565b6101b56101933660046103b9565b600060208190529081526040902080546001909101546001600160a01b031682565b604080519283526001600160a01b039091166020830152016100a5565b6100eb6101e0366004610438565b6102db565b6001600160a01b038083166000908152602081905260408120600181015491929091161580610223575060018101546001600160a01b038481169116145b61028d5760405162461bcd60e51b815260206004820152603060248201527f416e6f746865722070726f76696465722077617320616c72656164792073657460448201526f103337b9103a3434b99039ba30b5b2b960811b60648201526084015b60405180910390fd5b60018101546001600160a01b03166102bd576001810180546001600160a01b0319166001600160a01b0385161790555b5050506001600160a01b031660009081526020819052604090205490565b6000831161033d5760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f20736c617368206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610284565b6001600160a01b03841660009081526020819052604081208054859290610365908490610492565b90915550506001600160a01b038216600090815260016020526040812080548392906103929084906104a9565b909155505050505050565b80356001600160a01b03811681146103b457600080fd5b919050565b6000602082840312156103cb57600080fd5b6103d48261039d565b9392505050565b600080604083850312156103ee57600080fd5b6103f78361039d565b91506104056020840161039d565b90509250929050565b6000806040838503121561042157600080fd5b61042a8361039d565b946020939093013593505050565b6000806000806080858703121561044e57600080fd5b6104578561039d565b93506020850135925061046c6040860161039d565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b6000828210156104a4576104a461047c565b500390565b600082198211156104bc576104bc61047c565b50019056fea2646970667358221220693cead7106fe4e2d7e4a088f822c5ec5acea00860a89e5f30d7e6f1ae0042fe64736f6c63430008090033", + "solcInputHash": "3e22d437f05c26959c9fff55c53befb8", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"getAllTokens\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"investigators\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"requestMerge\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"setStaker\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"penalty\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"investigator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"slashStaker\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"stakerInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"internalType\":\"struct NuCypherTokenStakingMock.StakerStruct\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"stakers\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"slashStaker(address,uint256,address,uint256)\":{\"params\":{\"investigator\":\"Investigator\",\"penalty\":\"Penalty\",\"reward\":\"Reward for the investigator\",\"staker\":\"Staker's address\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getAllTokens(address)\":{\"notice\":\"Get all tokens belonging to the staker\"},\"requestMerge(address,address)\":{\"notice\":\"Request merge between NuCypher staking contract and T staking contract. Returns amount of staked tokens\"},\"slashStaker(address,uint256,address,uint256)\":{\"notice\":\"Slash the staker's stake and reward the investigator\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/TokenStakingTestSet.sol\":\"NuCypherTokenStakingMock\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() initializer {}\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\\n // contract may have been reentered.\\n require(_initializing ? _isConstructor() : !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} modifier, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n function _isConstructor() private view returns (bool) {\\n return !AddressUpgradeable.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x372b0bc04e3b4c074559bbbfb1317afddb56de5504158ca25a7f9cd403980445\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev 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 /**\\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\",\"keccak256\":\"0x6777f3fccb5dab95a9088ef62c41bee0198fd92e50d7c94f0e3733788af4079e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3e26a49d2fa5ef8338b8a9467c91e54f417cb07e849b1cc0f4ebc4d2a147938e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x55cf2bd9fc76704ddcdc19834cd288b7de00fc0f298a40ea16a954ae8991db2d\",\"license\":\"MIT\"},\"@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 v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.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 /**\\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\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\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 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 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 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 /**\\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\",\"keccak256\":\"0x516a22876c1fab47f49b1bc22b4614491cd05338af8bd2e7b382da090a079990\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.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 SafeCast {\\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\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"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\"},\"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/staking/IApplication.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\\n/// @title Application interface for Threshold Network applications\\n/// @notice Generic interface for an application. Application is an external\\n/// smart contract or a set of smart contracts utilizing functionalities\\n/// offered by Threshold Network. Applications authorized for the given\\n/// staking provider are eligible to slash the stake delegated to that\\n/// staking provider.\\ninterface IApplication {\\n /// @dev Event emitted by `withdrawRewards` function.\\n event RewardsWithdrawn(address indexed stakingProvider, uint96 amount);\\n\\n /// @notice Withdraws application rewards for the given staking provider.\\n /// Rewards are withdrawn to the staking provider's beneficiary\\n /// address set in the staking contract.\\n /// @dev Emits `RewardsWithdrawn` event.\\n function withdrawRewards(address stakingProvider) external;\\n\\n /// @notice Used by T staking contract to inform the application that the\\n /// authorized amount for the given staking provider increased.\\n /// The application may do any necessary housekeeping. The\\n /// application must revert the transaction in case the\\n /// authorization is below the minimum required.\\n function authorizationIncreased(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Used by T staking contract to inform the application that the\\n /// authorization decrease for the given staking provider has been\\n /// requested. The application should mark the authorization as\\n /// pending decrease and respond to the staking contract with\\n /// `approveAuthorizationDecrease` at its discretion. It may\\n /// happen right away but it also may happen several months later.\\n /// If there is already a pending authorization decrease request\\n /// for the application, and the application does not agree for\\n /// overwriting it, the function should revert.\\n function authorizationDecreaseRequested(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Used by T staking contract to inform the application the\\n /// authorization has been decreased for the given staking provider\\n /// involuntarily, as a result of slashing. Lets the application to\\n /// do any housekeeping neccessary. Called with 250k gas limit and\\n /// does not revert the transaction if\\n /// `involuntaryAuthorizationDecrease` call failed.\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) external;\\n\\n /// @notice Returns the amount of application rewards available for\\n /// withdrawal for the given staking provider.\\n function availableRewards(address stakingProvider)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice The minimum authorization amount required for the staking\\n /// provider so that they can participate in the application.\\n function minimumAuthorization() external view returns (uint96);\\n}\\n\",\"keccak256\":\"0x43d707dccc548bf48ad316d9652450cb297203234d251132cdc6b97508eb44c5\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/ILegacyTokenStaking.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\\n/// @title IKeepTokenStaking\\n/// @notice Interface for Keep TokenStaking contract\\ninterface IKeepTokenStaking {\\n /// @notice Seize provided token amount from every member in the misbehaved\\n /// operators array. The tattletale is rewarded with 5% of the total seized\\n /// amount scaled by the reward adjustment parameter and the rest 95% is burned.\\n /// @param amountToSeize Token amount to seize from every misbehaved operator.\\n /// @param rewardMultiplier Reward adjustment in percentage. Min 1% and 100% max.\\n /// @param tattletale Address to receive the 5% reward.\\n /// @param misbehavedOperators Array of addresses to seize the tokens from.\\n function seize(\\n uint256 amountToSeize,\\n uint256 rewardMultiplier,\\n address tattletale,\\n address[] memory misbehavedOperators\\n ) external;\\n\\n /// @notice Gets stake delegation info for the given operator.\\n /// @param operator Operator address.\\n /// @return amount The amount of tokens the given operator delegated.\\n /// @return createdAt The time when the stake has been delegated.\\n /// @return undelegatedAt The time when undelegation has been requested.\\n /// If undelegation has not been requested, 0 is returned.\\n function getDelegationInfo(address operator)\\n external\\n view\\n returns (\\n uint256 amount,\\n uint256 createdAt,\\n uint256 undelegatedAt\\n );\\n\\n /// @notice Gets the stake owner for the specified operator address.\\n /// @return Stake owner address.\\n function ownerOf(address operator) external view returns (address);\\n\\n /// @notice Gets the beneficiary for the specified operator address.\\n /// @return Beneficiary address.\\n function beneficiaryOf(address operator)\\n external\\n view\\n returns (address payable);\\n\\n /// @notice Gets the authorizer for the specified operator address.\\n /// @return Authorizer address.\\n function authorizerOf(address operator) external view returns (address);\\n\\n /// @notice Gets the eligible stake balance of the specified address.\\n /// An eligible stake is a stake that passed the initialization period\\n /// and is not currently undelegating. Also, the operator had to approve\\n /// the specified operator contract.\\n ///\\n /// Operator with a minimum required amount of eligible stake can join the\\n /// network and participate in new work selection.\\n ///\\n /// @param operator address of stake operator.\\n /// @param operatorContract address of operator contract.\\n /// @return balance an uint256 representing the eligible stake balance.\\n function eligibleStake(address operator, address operatorContract)\\n external\\n view\\n returns (uint256 balance);\\n}\\n\\n/// @title INuCypherStakingEscrow\\n/// @notice Interface for NuCypher StakingEscrow contract\\ninterface INuCypherStakingEscrow {\\n /// @notice Slash the staker's stake and reward the investigator\\n /// @param staker Staker's address\\n /// @param penalty Penalty\\n /// @param investigator Investigator\\n /// @param reward Reward for the investigator\\n function slashStaker(\\n address staker,\\n uint256 penalty,\\n address investigator,\\n uint256 reward\\n ) external;\\n\\n /// @notice Request merge between NuCypher staking contract and T staking contract.\\n /// Returns amount of staked tokens\\n function requestMerge(address staker, address stakingProvider)\\n external\\n returns (uint256);\\n\\n /// @notice Get all tokens belonging to the staker\\n function getAllTokens(address staker) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x807d42d248e94c1f2269c7aa27031302a1225525e1405010424dd91adcc092ab\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/IStaking.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\\n/// @title Interface of Threshold Network staking contract\\n/// @notice The staking contract enables T owners to have their wallets offline\\n/// and their stake managed by staking providers on their behalf.\\n/// The staking contract does not define operator role. The operator\\n/// responsible for running off-chain client software is appointed by\\n/// the staking provider in the particular application utilizing the\\n/// staking contract. All off-chain client software should be able\\n/// to run without exposing operator's or staking provider\\u2019s private\\n/// key and should not require any owner\\u2019s keys at all. The stake\\n/// delegation optimizes the network throughput without compromising the\\n/// security of the owners\\u2019 stake.\\ninterface IStaking {\\n enum StakeType {\\n NU,\\n KEEP,\\n T\\n }\\n\\n //\\n //\\n // Delegating a stake\\n //\\n //\\n\\n /// @notice Creates a delegation with `msg.sender` owner with the given\\n /// staking provider, beneficiary, and authorizer. Transfers the\\n /// given amount of T to the staking contract.\\n /// @dev The owner of the delegation needs to have the amount approved to\\n /// transfer to the staking contract.\\n function stake(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer,\\n uint96 amount\\n ) external;\\n\\n /// @notice Copies delegation from the legacy KEEP staking contract to T\\n /// staking contract. No tokens are transferred. Caches the active\\n /// stake amount from KEEP staking contract. Can be called by\\n /// anyone.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function stakeKeep(address stakingProvider) external;\\n\\n /// @notice Copies delegation from the legacy NU staking contract to T\\n /// staking contract, additionally appointing staking provider,\\n /// beneficiary and authorizer roles. Caches the amount staked in NU\\n /// staking contract. Can be called only by the original delegation\\n /// owner.\\n function stakeNu(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer\\n ) external;\\n\\n /// @notice Allows the Governance to set the minimum required stake amount.\\n /// This amount is required to protect against griefing the staking\\n /// contract and individual applications are allowed to require\\n /// higher minimum stakes if necessary.\\n function setMinimumStakeAmount(uint96 amount) external;\\n\\n //\\n //\\n // Authorizing an application\\n //\\n //\\n\\n /// @notice Allows the Governance to approve the particular application\\n /// before individual stake authorizers are able to authorize it.\\n function approveApplication(address application) external;\\n\\n /// @notice Increases the authorization of the given staking provider for\\n /// the given application by the given amount. Can only be called by\\n /// the authorizer for that staking provider.\\n /// @dev Calls `authorizationIncreased(address stakingProvider, uint256 amount)`\\n /// on the given application to notify the application about\\n /// authorization change. See `IApplication`.\\n function increaseAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external;\\n\\n /// @notice Requests decrease of the authorization for the given staking\\n /// provider on the given application by the provided amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application if the application agrees for that. If the\\n /// application does not agree for overwriting, the function\\n /// reverts.\\n /// @dev Calls `authorizationDecreaseRequested(address stakingProvider, uint256 amount)`\\n /// on the given application. See `IApplication`.\\n function requestAuthorizationDecrease(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external;\\n\\n /// @notice Requests decrease of all authorizations for the given staking\\n /// provider on all applications by all authorized amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application.\\n /// @dev Calls `authorizationDecreaseRequested(address stakingProvider, uint256 amount)`\\n /// for each authorized application. See `IApplication`.\\n function requestAuthorizationDecrease(address stakingProvider) external;\\n\\n /// @notice Called by the application at its discretion to approve the\\n /// previously requested authorization decrease request. Can only be\\n /// called by the application that was previously requested to\\n /// decrease the authorization for that staking provider.\\n /// Returns resulting authorized amount for the application.\\n function approveAuthorizationDecrease(address stakingProvider)\\n external\\n returns (uint96);\\n\\n /// @notice Decreases the authorization for the given `stakingProvider` on\\n /// the given disabled `application`, for all authorized amount.\\n /// Can be called by anyone.\\n function forceDecreaseAuthorization(\\n address stakingProvider,\\n address application\\n ) external;\\n\\n /// @notice Pauses the given application\\u2019s eligibility to slash stakes.\\n /// Besides that stakers can't change authorization to the application.\\n /// Can be called only by the Panic Button of the particular\\n /// application. The paused application can not slash stakes until\\n /// it is approved again by the Governance using `approveApplication`\\n /// function. Should be used only in case of an emergency.\\n function pauseApplication(address application) external;\\n\\n /// @notice Disables the given application. The disabled application can't\\n /// slash stakers. Also stakers can't increase authorization to that\\n /// application but can decrease without waiting by calling\\n /// `requestAuthorizationDecrease` at any moment. Can be called only\\n /// by the governance. The disabled application can't be approved\\n /// again. Should be used only in case of an emergency.\\n function disableApplication(address application) external;\\n\\n /// @notice Sets the Panic Button role for the given application to the\\n /// provided address. Can only be called by the Governance. If the\\n /// Panic Button for the given application should be disabled, the\\n /// role address should be set to 0x0 address.\\n function setPanicButton(address application, address panicButton) external;\\n\\n /// @notice Sets the maximum number of applications one staking provider can\\n /// have authorized. Used to protect against DoSing slashing queue.\\n /// Can only be called by the Governance.\\n function setAuthorizationCeiling(uint256 ceiling) external;\\n\\n //\\n //\\n // Stake top-up\\n //\\n //\\n\\n /// @notice Increases the amount of the stake for the given staking provider.\\n /// @dev The sender of this transaction needs to have the amount approved to\\n /// transfer to the staking contract.\\n function topUp(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Propagates information about stake top-up from the legacy KEEP\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpKeep(address stakingProvider) external;\\n\\n /// @notice Propagates information about stake top-up from the legacy NU\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpNu(address stakingProvider) external;\\n\\n //\\n //\\n // Undelegating a stake (unstaking)\\n //\\n //\\n\\n /// @notice Reduces the liquid T stake amount by the provided amount and\\n /// withdraws T to the owner. Reverts if there is at least one\\n /// authorization higher than the sum of the legacy stake and\\n /// remaining liquid T stake or if the unstake amount is higher than\\n /// the liquid T stake amount. Can be called only by the delegation\\n /// owner or the staking provider.\\n function unstakeT(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Sets the legacy KEEP staking contract active stake amount cached\\n /// in T staking contract to 0. Reverts if the amount of liquid T\\n /// staked in T staking contract is lower than the highest\\n /// application authorization. This function allows to unstake from\\n /// KEEP staking contract and still being able to operate in T\\n /// network and earning rewards based on the liquid T staked. Can be\\n /// called only by the delegation owner or the staking provider.\\n function unstakeKeep(address stakingProvider) external;\\n\\n /// @notice Reduces cached legacy NU stake amount by the provided amount.\\n /// Reverts if there is at least one authorization higher than the\\n /// sum of remaining legacy NU stake and liquid T stake for that\\n /// staking provider or if the untaked amount is higher than the\\n /// cached legacy stake amount. If succeeded, the legacy NU stake\\n /// can be partially or fully undelegated on the legacy staking\\n /// contract. This function allows to unstake from NU staking\\n /// contract and still being able to operate in T network and\\n /// earning rewards based on the liquid T staked. Can be called only\\n /// by the delegation owner or the staking provider.\\n function unstakeNu(address stakingProvider, uint96 amount) external;\\n\\n /// @notice Sets cached legacy stake amount to 0, sets the liquid T stake\\n /// amount to 0 and withdraws all liquid T from the stake to the\\n /// owner. Reverts if there is at least one non-zero authorization.\\n /// Can be called only by the delegation owner or the staking\\n /// provider.\\n function unstakeAll(address stakingProvider) external;\\n\\n //\\n //\\n // Keeping information in sync\\n //\\n //\\n\\n /// @notice Notifies about the discrepancy between legacy KEEP active stake\\n /// and the amount cached in T staking contract. Slashes the staking\\n /// provider in case the amount cached is higher than the actual\\n /// active stake amount in KEEP staking contract. Needs to update\\n /// authorizations of all affected applications and execute an\\n /// involuntary allocation decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyKeepStakeDiscrepancy(address stakingProvider) external;\\n\\n /// @notice Notifies about the discrepancy between legacy NU active stake\\n /// and the amount cached in T staking contract. Slashes the\\n /// staking provider in case the amount cached is higher than the\\n /// actual active stake amount in NU staking contract. Needs to\\n /// update authorizations of all affected applications and execute\\n /// an involuntary allocation decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyNuStakeDiscrepancy(address stakingProvider) external;\\n\\n /// @notice Sets the penalty amount for stake discrepancy and reward\\n /// multiplier for reporting it. The penalty is seized from the\\n /// delegated stake, and 5% of the penalty, scaled by the\\n /// multiplier, is given to the notifier. The rest of the tokens are\\n /// burned. Can only be called by the Governance. See `seize` function.\\n function setStakeDiscrepancyPenalty(\\n uint96 penalty,\\n uint256 rewardMultiplier\\n ) external;\\n\\n /// @notice Sets reward in T tokens for notification of misbehaviour\\n /// of one staking provider. Can only be called by the governance.\\n function setNotificationReward(uint96 reward) external;\\n\\n /// @notice Transfer some amount of T tokens as reward for notifications\\n /// of misbehaviour\\n function pushNotificationReward(uint96 reward) external;\\n\\n /// @notice Withdraw some amount of T tokens from notifiers treasury.\\n /// Can only be called by the governance.\\n function withdrawNotificationReward(address recipient, uint96 amount)\\n external;\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount that should be slashed from each one of them. Can only be\\n /// called by application authorized for all staking providers in\\n /// the array.\\n function slash(uint96 amount, address[] memory stakingProviders) external;\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each staking\\n /// provider from notifiers treasury. Can only be called by\\n /// application authorized for all staking providers in the array.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultipier,\\n address notifier,\\n address[] memory stakingProviders\\n ) external;\\n\\n /// @notice Takes the given number of queued slashing operations and\\n /// processes them. Receives 5% of the slashed amount.\\n /// Executes `involuntaryAllocationDecrease` function on each\\n /// affected application.\\n function processSlashing(uint256 count) external;\\n\\n //\\n //\\n // Auxiliary functions\\n //\\n //\\n\\n /// @notice Returns the authorized stake amount of the staking provider for\\n /// the application.\\n function authorizedStake(address stakingProvider, address application)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice Returns staked amount of T, Keep and Nu for the specified\\n /// staking provider.\\n /// @dev All values are in T denomination\\n function stakes(address stakingProvider)\\n external\\n view\\n returns (\\n uint96 tStake,\\n uint96 keepInTStake,\\n uint96 nuInTStake\\n );\\n\\n /// @notice Returns start staking timestamp.\\n /// @dev This value is set at most once.\\n function getStartStakingTimestamp(address stakingProvider)\\n external\\n view\\n returns (uint256);\\n\\n /// @notice Returns staked amount of NU for the specified staking provider.\\n function stakedNu(address stakingProvider) external view returns (uint256);\\n\\n /// @notice Gets the stake owner, the beneficiary and the authorizer\\n /// for the specified staking provider address.\\n /// @return owner Stake owner address.\\n /// @return beneficiary Beneficiary address.\\n /// @return authorizer Authorizer address.\\n function rolesOf(address stakingProvider)\\n external\\n view\\n returns (\\n address owner,\\n address payable beneficiary,\\n address authorizer\\n );\\n\\n /// @notice Returns length of application array\\n function getApplicationsLength() external view returns (uint256);\\n\\n /// @notice Returns length of slashing queue\\n function getSlashingQueueLength() external view returns (uint256);\\n\\n /// @notice Returns minimum possible stake for T, KEEP or NU in T\\n /// denomination.\\n /// @dev For example, suppose the given staking provider has 10 T, 20 T\\n /// worth of KEEP, and 30 T worth of NU all staked, and the maximum\\n /// application authorization is 40 T, then `getMinStaked` for\\n /// that staking provider returns:\\n /// * 0 T if KEEP stake type specified i.e.\\n /// min = 40 T max - (10 T + 30 T worth of NU) = 0 T\\n /// * 10 T if NU stake type specified i.e.\\n /// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T\\n /// * 0 T if T stake type specified i.e.\\n /// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T\\n /// In other words, the minimum stake amount for the specified\\n /// stake type is the minimum amount of stake of the given type\\n /// needed to satisfy the maximum application authorization given the\\n /// staked amounts of the other stake types for that staking provider.\\n function getMinStaked(address stakingProvider, StakeType stakeTypes)\\n external\\n view\\n returns (uint96);\\n\\n /// @notice Returns available amount to authorize for the specified application\\n function getAvailableToAuthorize(\\n address stakingProvider,\\n address application\\n ) external view returns (uint96);\\n}\\n\",\"keccak256\":\"0x45c15ff4a9a47024ce413da249a6a77cc2f20a81909e7536d4c5198c92f3f148\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/KeepStake.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 \\\"./ILegacyTokenStaking.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title KEEP ManagedGrant contract interface\\ninterface IManagedGrant {\\n function grantee() external view returns (address);\\n}\\n\\n/// @title KEEP stake owner resolver\\n/// @notice T network staking contract supports existing KEEP stakes by allowing\\n/// KEEP stakers to use their stakes in T network and weights them based\\n/// on KEEP<>T token ratio. KEEP stake owner is cached in T staking\\n/// contract and used to restrict access to all functions only owner or\\n/// operator should call. To cache KEEP stake owner in T staking\\n/// contract, T staking contract first needs to resolve the owner.\\n///\\n/// Resolving liquid KEEP stake owner is easy. Resolving token grant\\n/// stake owner is complicated and not possible to do on-chain from\\n/// a contract external to KEEP TokenStaking contract. Keep TokenStaking\\n/// knows the grant ID but does not expose it externally.\\n///\\n/// KeepStake contract addresses this problem by exposing\\n/// operator-owner mappings snapshotted off-chain based on events and\\n/// information publicly available from KEEP TokenStaking contract and\\n/// KEEP TokenGrant contract. Additionally, it gives the Governance\\n/// ability to add new mappings in case they are ever needed; in\\n/// practice, this will be needed only if someone decides to stake their\\n/// KEEP token grant in KEEP network after 2021-11-11 when the snapshot\\n/// was taken.\\n///\\n/// Operator-owner pairs were snapshotted 2021-11-11 in the following\\n/// way:\\n/// 1. Fetch all TokenStaking events from KEEP staking contract.\\n/// 2. Filter out undelegated operators.\\n/// 3. Filter out canceled delegations.\\n/// 4. Fetch grant stake information from KEEP TokenGrant for that\\n/// operator to determine if we are dealing with grant delegation.\\n/// 5. Fetch grantee address from KEEP TokenGrant contract.\\n/// 6. Check if we are dealing with ManagedGrant by looking for all\\n/// created ManagedGrants and comparing their address against grantee\\n/// address fetched from TokenGrant contract.\\ncontract KeepStake is Ownable {\\n IKeepTokenStaking public immutable keepTokenStaking;\\n\\n mapping(address => address) public operatorToManagedGrant;\\n mapping(address => address) public operatorToGrantee;\\n\\n constructor(IKeepTokenStaking _keepTokenStaking) {\\n keepTokenStaking = _keepTokenStaking;\\n }\\n\\n /// @notice Allows the Governance to set new operator-managed grant pair.\\n /// This function should only be called for managed grants if\\n /// the snapshot does include this pair.\\n function setManagedGrant(address operator, address managedGrant)\\n external\\n onlyOwner\\n {\\n operatorToManagedGrant[operator] = managedGrant;\\n }\\n\\n /// @notice Allows the Governance to set new operator-grantee pair.\\n /// This function should only be called for non-managed grants if\\n /// the snapshot does include this pair.\\n function setGrantee(address operator, address grantee) external onlyOwner {\\n operatorToGrantee[operator] = grantee;\\n }\\n\\n /// @notice Resolves KEEP stake owner for the provided operator address.\\n /// Reverts if could not resolve the owner.\\n function resolveOwner(address operator) external view returns (address) {\\n address owner = operatorToManagedGrant[operator];\\n if (owner != address(0)) {\\n return IManagedGrant(owner).grantee();\\n }\\n\\n owner = operatorToGrantee[operator];\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = resolveSnapshottedManagedGrantees(operator);\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = resolveSnapshottedGrantees(operator);\\n if (owner != address(0)) {\\n return owner;\\n }\\n\\n owner = keepTokenStaking.ownerOf(operator);\\n require(owner != address(0), \\\"Could not resolve the owner\\\");\\n\\n return owner;\\n }\\n\\n function resolveSnapshottedManagedGrantees(address operator)\\n internal\\n view\\n returns (address)\\n {\\n if (operator == 0x855A951162B1B93D70724484d5bdc9D00B56236B) {\\n return\\n IManagedGrant(0xFADbF758307A054C57B365Db1De90acA71feaFE5)\\n .grantee();\\n }\\n if (operator == 0xF1De9490Bf7298b5F350cE74332Ad7cf8d5cB181) {\\n return\\n IManagedGrant(0xAEd493Aaf3E76E83b29E151848b71eF4544f92f1)\\n .grantee();\\n }\\n if (operator == 0x39d2aCBCD80d80080541C6eed7e9feBb8127B2Ab) {\\n return\\n IManagedGrant(0xA2fa09D6f8C251422F5fde29a0BAd1C53dEfAe66)\\n .grantee();\\n }\\n if (operator == 0xd66cAE89FfBc6E50e6b019e45c1aEc93Dec54781) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0x2eBE08379f4fD866E871A9b9E1d5C695154C6A9F) {\\n return\\n IManagedGrant(0xd00c0d43b747C33726B3f0ff4BDA4b72dc53c6E9)\\n .grantee();\\n }\\n if (operator == 0xA97c34278162b556A527CFc01B53eb4DDeDFD223) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x6C76d49322C9f8761A1623CEd89A31490cdB649d) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x4a41c7a884d119eaaefE471D0B3a638226408382) {\\n return\\n IManagedGrant(0xcdf3d216d82a463Ce82971F2F5DA3d8f9C5f093A)\\n .grantee();\\n }\\n if (operator == 0x9c06Feb7Ebc8065ee11Cd5E8EEdaAFb2909A7087) {\\n return\\n IManagedGrant(0x45119cd98d145283762BA9eBCAea75F72D188733)\\n .grantee();\\n }\\n if (operator == 0x9bD818Ab6ACC974f2Cf2BD2EBA7a250126Accb9F) {\\n return\\n IManagedGrant(0x6E535043377067621954ee84065b0bd7357e7aBa)\\n .grantee();\\n }\\n if (operator == 0x1d803c89760F8B4057DB15BCb3B8929E0498D310) {\\n return\\n IManagedGrant(0xB3E967355c456B1Bd43cB0188A321592D410D096)\\n .grantee();\\n }\\n if (operator == 0x3101927DEeC27A2bfA6c4a6316e3A221f631dB91) {\\n return\\n IManagedGrant(0x178Bf1946feD0e2362fdF8bcD3f91F0701a012C6)\\n .grantee();\\n }\\n if (operator == 0x9d9b187E478bC62694A7bED216Fc365de87F280C) {\\n return\\n IManagedGrant(0xFBad17CFad6cb00D726c65501D69FdC13Ca5477c)\\n .grantee();\\n }\\n if (operator == 0xd977144724Bc77FaeFAe219F958AE3947205d0b5) {\\n return\\n IManagedGrant(0x087B442BFd4E42675cf2df5fa566F87d7A96Fb12)\\n .grantee();\\n }\\n if (operator == 0x045E511f53DeBF55c9C0B4522f14F602f7C7cA81) {\\n return\\n IManagedGrant(0xFcfe8C036C414a15cF871071c483687095caF7D6)\\n .grantee();\\n }\\n if (operator == 0x3Dd301b3c96A282d8092E1e6f6846f24172D45C1) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x5d84DEB482E770479154028788Df79aA7C563aA4) {\\n return\\n IManagedGrant(0x9D1a179c469a8BdD0b683A9f9250246cc47e8fBE)\\n .grantee();\\n }\\n if (operator == 0x1dF927B69A97E8140315536163C029d188e8573b) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x617daCE069Fbd41993491de211b4DfccdAcbd348) {\\n return\\n IManagedGrant(0xb5Bdd2D9B3541fc8f581Af37430D26527e59aeF8)\\n .grantee();\\n }\\n if (operator == 0x650A9eD18Df873cad98C88dcaC8170531cAD2399) {\\n return\\n IManagedGrant(0x1Df7324A3aD20526DFa02Cc803eD2D97Cac81F3b)\\n .grantee();\\n }\\n if (operator == 0x07C9a8f8264221906b7b8958951Ce4753D39628B) {\\n return\\n IManagedGrant(0x305D12b4d70529Cd618dA7399F5520701E510041)\\n .grantee();\\n }\\n if (operator == 0x63eB4c3DD0751F9BE7070A01156513C227fa1eF6) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0xc6349eEC31048787676b6297ba71721376A8DdcF) {\\n return\\n IManagedGrant(0xac1a985E75C6a0b475b9c807Ad0705a988Be2D99)\\n .grantee();\\n }\\n if (operator == 0x3B945f9C0C8737e44f8e887d4F04B5B3A491Ac4d) {\\n return\\n IManagedGrant(0x82e17477726E8D9D2C237745cA9989631582eE98)\\n .grantee();\\n }\\n if (operator == 0xF35343299a4f80Dd5D917bbe5ddd54eBB820eBd4) {\\n return\\n IManagedGrant(0xCC88c15506251B62ccCeebA193e100d6bBC9a30D)\\n .grantee();\\n }\\n if (operator == 0x3B9e5ae72d068448bB96786989c0d86FBC0551D1) {\\n return\\n IManagedGrant(0x306309f9d105F34132db0bFB3Ce3f5B0245Cd386)\\n .grantee();\\n }\\n if (operator == 0xB2D53Be158Cb8451dFc818bD969877038c1BdeA1) {\\n return\\n IManagedGrant(0xaE55e3800f0A3feaFdcE535A8C0fab0fFdB90DEe)\\n .grantee();\\n }\\n if (operator == 0xF6dbF7AFe05b8Bb6f198eC7e69333c98D3C4608C) {\\n return\\n IManagedGrant(0xbb8D24a20c20625f86739824014C3cBAAAb26700)\\n .grantee();\\n }\\n if (operator == 0xB62Fc1ADfFb2ab832041528C8178358338d85f76) {\\n return\\n IManagedGrant(0x9ED98fD1C29018B9342CB8F57A3073B9695f0c02)\\n .grantee();\\n }\\n if (operator == 0x9bC8d30d971C9e74298112803036C05db07D73e3) {\\n return\\n IManagedGrant(0x66beda757939f8e505b5Eb883cd02C8d4a11Bca2)\\n .grantee();\\n }\\n\\n return address(0);\\n }\\n\\n function resolveSnapshottedGrantees(address operator)\\n internal\\n pure\\n returns (address)\\n {\\n if (operator == 0x1147ccFB4AEFc6e587a23b78724Ef20Ec6e474D4) {\\n return 0x3FB49dA4375Ef9019f17990D04c6d5daD482D80a;\\n }\\n if (operator == 0x4c21541f95a00C03C75F38C71DC220bd27cbbEd9) {\\n return 0xC897cfeE43a8d827F76D4226994D5CE5EBBe2571;\\n }\\n if (operator == 0x7E6332d18719a5463d3867a1a892359509589a3d) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0x8Bd660A764Ca14155F3411a4526a028b6316CB3E) {\\n return 0xf6f372DfAeCC1431186598c304e91B79Ce115766;\\n }\\n if (operator == 0x4F4f0D0dfd93513B3f4Cb116Fe9d0A005466F725) {\\n return 0x8b055ac1c4dd287E2a46D4a52d61FE76FB551bD0;\\n }\\n if (operator == 0x1DF0250027fEC876d8876d1ac7A392c9098F1a1e) {\\n return 0xE408fFa969707Ce5d7aA3e5F8d44674Fa4b26219;\\n }\\n if (operator == 0x860EF3f83B6adFEF757F98345c3B8DdcFCA9d152) {\\n return 0x08a3633AAb8f3E436DEA204288Ee26Fe094406b0;\\n }\\n if (operator == 0xe3a2d16dA142E6B190A5d9F7e0C07cc460B58A5F) {\\n return 0x875f8fFCDDeD63B5d8Cf54be4E4b82FE6c6E249C;\\n }\\n if (operator == 0xBDE07f1cA107Ef319b0Bb26eBF1d0a5b4c97ffc1) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0xE86181D6b672d78D33e83029fF3D0ef4A601B4C4) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0xb7c561e2069aCaE2c4480111B1606790BB4E13fE) {\\n return 0x1578eD833D986c1188D1a998aA5FEcD418beF5da;\\n }\\n if (operator == 0x526c013f8382B050d32d86e7090Ac84De22EdA4D) {\\n return 0x61C6E5DDacded540CD08066C08cbc096d22D91f4;\\n }\\n\\n return address(0);\\n }\\n}\\n\",\"keccak256\":\"0xc75f6be595ec0e0c885d689786808a53b70c0a170a53dd344228359dc6aaf178\",\"license\":\"GPL-3.0-or-later\"},\"contracts/staking/TokenStaking.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 \\\"./IApplication.sol\\\";\\nimport \\\"./ILegacyTokenStaking.sol\\\";\\nimport \\\"./IStaking.sol\\\";\\nimport \\\"./KeepStake.sol\\\";\\nimport \\\"../governance/Checkpoints.sol\\\";\\nimport \\\"../token/T.sol\\\";\\nimport \\\"../utils/PercentUtils.sol\\\";\\nimport \\\"../utils/SafeTUpgradeable.sol\\\";\\nimport \\\"../vending/VendingMachine.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\n\\n/// @notice TokenStaking is the main staking contract of the Threshold Network.\\n/// Apart from the basic usage of enabling T stakes, it also acts as a\\n/// sort of \\\"meta-staking\\\" contract, accepting existing legacy NU/KEEP\\n/// stakes. Additionally, it serves as application manager for the apps\\n/// that run on the Threshold Network. Note that legacy NU/KEEP staking\\n/// contracts see TokenStaking as an application (e.g., slashing is\\n/// requested by TokenStaking and performed by the legacy contracts).\\n/// @dev TokenStaking is upgradeable, using OpenZeppelin's Upgradeability\\n/// framework. As such, it is required to satisfy OZ's guidelines, like\\n/// restrictions on constructors, immutable variables, base contracts and\\n/// libraries. See https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable\\ncontract TokenStaking is Initializable, IStaking, Checkpoints {\\n using SafeTUpgradeable for T;\\n using PercentUtils for uint256;\\n using SafeCastUpgradeable for uint256;\\n\\n enum ApplicationStatus {\\n NOT_APPROVED,\\n APPROVED,\\n PAUSED,\\n DISABLED\\n }\\n\\n struct StakingProviderInfo {\\n uint96 nuInTStake;\\n address owner;\\n uint96 keepInTStake;\\n address payable beneficiary;\\n uint96 tStake;\\n address authorizer;\\n mapping(address => AppAuthorization) authorizations;\\n address[] authorizedApplications;\\n uint256 startStakingTimestamp;\\n }\\n\\n struct AppAuthorization {\\n uint96 authorized;\\n uint96 deauthorizing;\\n }\\n\\n struct ApplicationInfo {\\n ApplicationStatus status;\\n address panicButton;\\n }\\n\\n struct SlashingEvent {\\n address stakingProvider;\\n uint96 amount;\\n }\\n\\n uint256 internal constant SLASHING_REWARD_PERCENT = 5;\\n uint256 internal constant MIN_STAKE_TIME = 24 hours;\\n uint256 internal constant GAS_LIMIT_AUTHORIZATION_DECREASE = 250000;\\n uint256 internal constant CONVERSION_DIVISOR = 10**(18 - 3);\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n T internal immutable token;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IKeepTokenStaking internal immutable keepStakingContract;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n KeepStake internal immutable keepStake;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n INuCypherStakingEscrow internal immutable nucypherStakingContract;\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable keepRatio;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable nucypherRatio;\\n\\n address public governance;\\n uint96 public minTStakeAmount;\\n uint256 public authorizationCeiling;\\n uint96 public stakeDiscrepancyPenalty;\\n uint256 public stakeDiscrepancyRewardMultiplier;\\n\\n uint256 public notifiersTreasury;\\n uint256 public notificationReward;\\n\\n mapping(address => StakingProviderInfo) internal stakingProviders;\\n mapping(address => ApplicationInfo) public applicationInfo;\\n address[] public applications;\\n\\n SlashingEvent[] public slashingQueue;\\n uint256 public slashingQueueIndex;\\n\\n event Staked(\\n StakeType indexed stakeType,\\n address indexed owner,\\n address indexed stakingProvider,\\n address beneficiary,\\n address authorizer,\\n uint96 amount\\n );\\n event MinimumStakeAmountSet(uint96 amount);\\n event ApplicationStatusChanged(\\n address indexed application,\\n ApplicationStatus indexed newStatus\\n );\\n event AuthorizationIncreased(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationDecreaseRequested(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationDecreaseApproved(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount\\n );\\n event AuthorizationInvoluntaryDecreased(\\n address indexed stakingProvider,\\n address indexed application,\\n uint96 fromAmount,\\n uint96 toAmount,\\n bool indexed successfulCall\\n );\\n event PanicButtonSet(\\n address indexed application,\\n address indexed panicButton\\n );\\n event AuthorizationCeilingSet(uint256 ceiling);\\n event ToppedUp(address indexed stakingProvider, uint96 amount);\\n event Unstaked(address indexed stakingProvider, uint96 amount);\\n event TokensSeized(\\n address indexed stakingProvider,\\n uint96 amount,\\n bool indexed discrepancy\\n );\\n event StakeDiscrepancyPenaltySet(uint96 penalty, uint256 rewardMultiplier);\\n event NotificationRewardSet(uint96 reward);\\n event NotificationRewardPushed(uint96 reward);\\n event NotificationRewardWithdrawn(address recipient, uint96 amount);\\n event NotifierRewarded(address indexed notifier, uint256 amount);\\n event SlashingProcessed(\\n address indexed caller,\\n uint256 count,\\n uint256 tAmount\\n );\\n event OwnerRefreshed(\\n address indexed stakingProvider,\\n address indexed oldOwner,\\n address indexed newOwner\\n );\\n event GovernanceTransferred(address oldGovernance, address newGovernance);\\n\\n modifier onlyGovernance() {\\n require(governance == msg.sender, \\\"Caller is not the governance\\\");\\n _;\\n }\\n\\n modifier onlyPanicButtonOf(address application) {\\n require(\\n applicationInfo[application].panicButton == msg.sender,\\n \\\"Caller is not the panic button\\\"\\n );\\n _;\\n }\\n\\n modifier onlyAuthorizerOf(address stakingProvider) {\\n //slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].authorizer == msg.sender,\\n \\\"Not authorizer\\\"\\n );\\n _;\\n }\\n\\n modifier onlyOwnerOrStakingProvider(address stakingProvider) {\\n //slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].owner != address(0) &&\\n (stakingProvider == msg.sender ||\\n stakingProviders[stakingProvider].owner == msg.sender),\\n \\\"Not owner or provider\\\"\\n );\\n _;\\n }\\n\\n modifier onlyOwnerOf(address stakingProvider) {\\n // slither-disable-next-line incorrect-equality\\n require(\\n stakingProviders[stakingProvider].owner == msg.sender,\\n \\\"Caller is not owner\\\"\\n );\\n _;\\n }\\n\\n /// @param _token Address of T token contract\\n /// @param _keepStakingContract Address of Keep staking contract\\n /// @param _nucypherStakingContract Address of NuCypher staking contract\\n /// @param _keepVendingMachine Address of Keep vending machine\\n /// @param _nucypherVendingMachine Address of NuCypher vending machine\\n /// @param _keepStake Address of Keep contract with grant owners\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(\\n T _token,\\n IKeepTokenStaking _keepStakingContract,\\n INuCypherStakingEscrow _nucypherStakingContract,\\n VendingMachine _keepVendingMachine,\\n VendingMachine _nucypherVendingMachine,\\n KeepStake _keepStake\\n ) {\\n // calls to check contracts are working\\n require(\\n _token.totalSupply() > 0 &&\\n _keepStakingContract.ownerOf(address(0)) == address(0) &&\\n _nucypherStakingContract.getAllTokens(address(0)) == 0 &&\\n AddressUpgradeable.isContract(address(_keepStake)),\\n \\\"Wrong input parameters\\\"\\n );\\n token = _token;\\n keepStakingContract = _keepStakingContract;\\n keepStake = _keepStake;\\n nucypherStakingContract = _nucypherStakingContract;\\n\\n keepRatio = _keepVendingMachine.ratio();\\n nucypherRatio = _nucypherVendingMachine.ratio();\\n }\\n\\n function initialize() external initializer {\\n _transferGovernance(msg.sender);\\n }\\n\\n //\\n //\\n // Delegating a stake\\n //\\n //\\n\\n /// @notice Creates a delegation with `msg.sender` owner with the given\\n /// staking provider, beneficiary, and authorizer. Transfers the\\n /// given amount of T to the staking contract.\\n /// @dev The owner of the delegation needs to have the amount approved to\\n /// transfer to the staking contract.\\n function stake(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer,\\n uint96 amount\\n ) external override {\\n require(\\n stakingProvider != address(0) &&\\n beneficiary != address(0) &&\\n authorizer != address(0),\\n \\\"Parameters must be specified\\\"\\n );\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n (, uint256 createdAt, ) = keepStakingContract.getDelegationInfo(\\n stakingProvider\\n );\\n require(\\n createdAt == 0 && stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n require(\\n amount > 0 && amount >= minTStakeAmount,\\n \\\"Amount is less than minimum\\\"\\n );\\n stakingProviderStruct.owner = msg.sender;\\n stakingProviderStruct.authorizer = authorizer;\\n stakingProviderStruct.beneficiary = beneficiary;\\n\\n stakingProviderStruct.tStake = amount;\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, amount);\\n\\n emit Staked(\\n StakeType.T,\\n msg.sender,\\n stakingProvider,\\n beneficiary,\\n authorizer,\\n amount\\n );\\n token.safeTransferFrom(msg.sender, address(this), amount);\\n }\\n\\n /// @notice Copies delegation from the legacy KEEP staking contract to T\\n /// staking contract. No tokens are transferred. Caches the active\\n /// stake amount from KEEP staking contract. Can be called by\\n /// anyone.\\n /// @dev The staking provider in T staking contract is the legacy KEEP\\n /// staking contract operator.\\n function stakeKeep(address stakingProvider) external override {\\n require(stakingProvider != address(0), \\\"Parameters must be specified\\\");\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n\\n require(\\n stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n\\n uint96 tAmount = getKeepAmountInT(stakingProvider);\\n require(tAmount != 0, \\\"Nothing to sync\\\");\\n\\n stakingProviderStruct.keepInTStake = tAmount;\\n stakingProviderStruct.owner = keepStake.resolveOwner(stakingProvider);\\n stakingProviderStruct.authorizer = keepStakingContract.authorizerOf(\\n stakingProvider\\n );\\n stakingProviderStruct.beneficiary = keepStakingContract.beneficiaryOf(\\n stakingProvider\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, tAmount);\\n\\n emit Staked(\\n StakeType.KEEP,\\n stakingProviderStruct.owner,\\n stakingProvider,\\n stakingProviderStruct.beneficiary,\\n stakingProviderStruct.authorizer,\\n tAmount\\n );\\n }\\n\\n /// @notice Copies delegation from the legacy NU staking contract to T\\n /// staking contract, additionally appointing beneficiary and\\n /// authorizer roles. Caches the amount staked in NU staking\\n /// contract. Can be called only by the original delegation owner.\\n function stakeNu(\\n address stakingProvider,\\n address payable beneficiary,\\n address authorizer\\n ) external override {\\n require(\\n stakingProvider != address(0) &&\\n beneficiary != address(0) &&\\n authorizer != address(0),\\n \\\"Parameters must be specified\\\"\\n );\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n (, uint256 createdAt, ) = keepStakingContract.getDelegationInfo(\\n stakingProvider\\n );\\n require(\\n createdAt == 0 && stakingProviderStruct.owner == address(0),\\n \\\"Provider is already in use\\\"\\n );\\n\\n uint96 tAmount = getNuAmountInT(msg.sender, stakingProvider);\\n require(tAmount > 0, \\\"Nothing to sync\\\");\\n\\n stakingProviderStruct.nuInTStake = tAmount;\\n stakingProviderStruct.owner = msg.sender;\\n stakingProviderStruct.authorizer = authorizer;\\n stakingProviderStruct.beneficiary = beneficiary;\\n /* solhint-disable-next-line not-rely-on-time */\\n stakingProviderStruct.startStakingTimestamp = block.timestamp;\\n\\n increaseStakeCheckpoint(stakingProvider, tAmount);\\n\\n emit Staked(\\n StakeType.NU,\\n msg.sender,\\n stakingProvider,\\n beneficiary,\\n authorizer,\\n tAmount\\n );\\n }\\n\\n /// @notice Allows the Governance to set the minimum required stake amount.\\n /// This amount is required to protect against griefing the staking\\n /// contract and individual applications are allowed to require\\n /// higher minimum stakes if necessary.\\n /// @dev Staking providers are not required to maintain a minimum T stake\\n /// all the time. 24 hours after the delegation, T stake can be reduced\\n /// below the minimum stake. The minimum stake in the staking contract\\n /// is just to protect against griefing stake operation. Please note\\n /// that each application may have its own minimum authorization though\\n /// and the authorization can not be higher than the stake.\\n function setMinimumStakeAmount(uint96 amount)\\n external\\n override\\n onlyGovernance\\n {\\n minTStakeAmount = amount;\\n emit MinimumStakeAmountSet(amount);\\n }\\n\\n //\\n //\\n // Authorizing an application\\n //\\n //\\n\\n /// @notice Allows the Governance to approve the particular application\\n /// before individual stake authorizers are able to authorize it.\\n function approveApplication(address application)\\n external\\n override\\n onlyGovernance\\n {\\n require(application != address(0), \\\"Parameters must be specified\\\");\\n ApplicationInfo storage info = applicationInfo[application];\\n require(\\n info.status == ApplicationStatus.NOT_APPROVED ||\\n info.status == ApplicationStatus.PAUSED,\\n \\\"Can't approve application\\\"\\n );\\n\\n if (info.status == ApplicationStatus.NOT_APPROVED) {\\n applications.push(application);\\n }\\n info.status = ApplicationStatus.APPROVED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.APPROVED);\\n }\\n\\n /// @notice Increases the authorization of the given staking provider for\\n /// the given application by the given amount. Can only be called by\\n /// the given staking provider\\u2019s authorizer.\\n /// @dev Calls `authorizationIncreased` callback on the given application to\\n /// notify the application about authorization change.\\n /// See `IApplication`.\\n function increaseAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external override onlyAuthorizerOf(stakingProvider) {\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[application];\\n uint96 fromAmount = authorization.authorized;\\n if (fromAmount == 0) {\\n require(\\n authorizationCeiling == 0 ||\\n stakingProviderStruct.authorizedApplications.length <\\n authorizationCeiling,\\n \\\"Too many applications\\\"\\n );\\n stakingProviderStruct.authorizedApplications.push(application);\\n }\\n\\n uint96 availableTValue = getAvailableToAuthorize(\\n stakingProvider,\\n application\\n );\\n require(availableTValue >= amount, \\\"Not enough stake to authorize\\\");\\n authorization.authorized += amount;\\n emit AuthorizationIncreased(\\n stakingProvider,\\n application,\\n fromAmount,\\n authorization.authorized\\n );\\n IApplication(application).authorizationIncreased(\\n stakingProvider,\\n fromAmount,\\n authorization.authorized\\n );\\n }\\n\\n /// @notice Requests decrease of all authorizations for the given staking\\n /// provider on all applications by all authorized amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application.\\n /// @dev Calls `authorizationDecreaseRequested` callback\\n /// for each authorized application. See `IApplication`.\\n function requestAuthorizationDecrease(address stakingProvider) external {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 deauthorizing = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address application = stakingProviderStruct.authorizedApplications[\\n i\\n ];\\n uint96 authorized = stakingProviderStruct\\n .authorizations[application]\\n .authorized;\\n if (authorized > 0) {\\n requestAuthorizationDecrease(\\n stakingProvider,\\n application,\\n authorized\\n );\\n deauthorizing += authorized;\\n }\\n }\\n\\n require(deauthorizing > 0, \\\"Nothing was authorized\\\");\\n }\\n\\n /// @notice Called by the application at its discretion to approve the\\n /// previously requested authorization decrease request. Can only be\\n /// called by the application that was previously requested to\\n /// decrease the authorization for that staking provider.\\n /// Returns resulting authorized amount for the application.\\n function approveAuthorizationDecrease(address stakingProvider)\\n external\\n override\\n returns (uint96)\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[msg.sender];\\n require(authorization.deauthorizing > 0, \\\"No deauthorizing in process\\\");\\n\\n uint96 fromAmount = authorization.authorized;\\n authorization.authorized -= authorization.deauthorizing;\\n authorization.deauthorizing = 0;\\n emit AuthorizationDecreaseApproved(\\n stakingProvider,\\n msg.sender,\\n fromAmount,\\n authorization.authorized\\n );\\n\\n // remove application from an array\\n if (authorization.authorized == 0) {\\n cleanAuthorizedApplications(stakingProviderStruct, 1);\\n }\\n\\n return authorization.authorized;\\n }\\n\\n /// @notice Decreases the authorization for the given `stakingProvider` on\\n /// the given disabled `application`, for all authorized amount.\\n /// Can be called by anyone.\\n function forceDecreaseAuthorization(\\n address stakingProvider,\\n address application\\n ) external override {\\n require(\\n applicationInfo[application].status == ApplicationStatus.DISABLED,\\n \\\"Application is not disabled\\\"\\n );\\n\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[application];\\n uint96 fromAmount = authorization.authorized;\\n require(fromAmount > 0, \\\"Application is not authorized\\\");\\n authorization.authorized = 0;\\n authorization.deauthorizing = 0;\\n\\n emit AuthorizationDecreaseApproved(\\n stakingProvider,\\n application,\\n fromAmount,\\n 0\\n );\\n cleanAuthorizedApplications(stakingProviderStruct, 1);\\n }\\n\\n /// @notice Pauses the given application\\u2019s eligibility to slash stakes.\\n /// Besides that stakers can't change authorization to the application.\\n /// Can be called only by the Panic Button of the particular\\n /// application. The paused application can not slash stakes until\\n /// it is approved again by the Governance using `approveApplication`\\n /// function. Should be used only in case of an emergency.\\n function pauseApplication(address application)\\n external\\n override\\n onlyPanicButtonOf(application)\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Can't pause application\\\"\\n );\\n applicationStruct.status = ApplicationStatus.PAUSED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.PAUSED);\\n }\\n\\n /// @notice Disables the given application. The disabled application can't\\n /// slash stakers. Also stakers can't increase authorization to that\\n /// application but can decrease without waiting by calling\\n /// `forceDecreaseAuthorization` at any moment. Can be called only\\n /// by the governance. The disabled application can't be approved\\n /// again. Should be used only in case of an emergency.\\n function disableApplication(address application)\\n external\\n override\\n onlyGovernance\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED ||\\n applicationStruct.status == ApplicationStatus.PAUSED,\\n \\\"Can't disable application\\\"\\n );\\n applicationStruct.status = ApplicationStatus.DISABLED;\\n emit ApplicationStatusChanged(application, ApplicationStatus.DISABLED);\\n }\\n\\n /// @notice Sets the Panic Button role for the given application to the\\n /// provided address. Can only be called by the Governance. If the\\n /// Panic Button for the given application should be disabled, the\\n /// role address should be set to 0x0 address.\\n function setPanicButton(address application, address panicButton)\\n external\\n override\\n onlyGovernance\\n {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n applicationStruct.panicButton = panicButton;\\n emit PanicButtonSet(application, panicButton);\\n }\\n\\n /// @notice Sets the maximum number of applications one staking provider can\\n /// have authorized. Used to protect against DoSing slashing queue.\\n /// Can only be called by the Governance.\\n function setAuthorizationCeiling(uint256 ceiling)\\n external\\n override\\n onlyGovernance\\n {\\n authorizationCeiling = ceiling;\\n emit AuthorizationCeilingSet(ceiling);\\n }\\n\\n //\\n //\\n // Stake top-up\\n //\\n //\\n\\n /// @notice Increases the amount of the stake for the given staking provider.\\n /// @dev The sender of this transaction needs to have the amount approved to\\n /// transfer to the staking contract.\\n function topUp(address stakingProvider, uint96 amount) external override {\\n require(\\n stakingProviders[stakingProvider].owner != address(0),\\n \\\"Nothing to top-up\\\"\\n );\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n stakingProviderStruct.tStake += amount;\\n emit ToppedUp(stakingProvider, amount);\\n increaseStakeCheckpoint(stakingProvider, amount);\\n token.safeTransferFrom(msg.sender, address(this), amount);\\n }\\n\\n /// @notice Propagates information about stake top-up from the legacy KEEP\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpKeep(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 tAmount = getKeepAmountInT(stakingProvider);\\n require(\\n tAmount > stakingProviderStruct.keepInTStake,\\n \\\"Nothing to top-up\\\"\\n );\\n\\n uint96 toppedUp = tAmount - stakingProviderStruct.keepInTStake;\\n emit ToppedUp(stakingProvider, toppedUp);\\n stakingProviderStruct.keepInTStake = tAmount;\\n increaseStakeCheckpoint(stakingProvider, toppedUp);\\n }\\n\\n /// @notice Propagates information about stake top-up from the legacy NU\\n /// staking contract to T staking contract. Can be called only by\\n /// the owner or the staking provider.\\n function topUpNu(address stakingProvider)\\n external\\n override\\n onlyOwnerOf(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 tAmount = getNuAmountInT(\\n stakingProviderStruct.owner,\\n stakingProvider\\n );\\n require(\\n tAmount > stakingProviderStruct.nuInTStake,\\n \\\"Nothing to top-up\\\"\\n );\\n\\n uint96 toppedUp = tAmount - stakingProviderStruct.nuInTStake;\\n emit ToppedUp(stakingProvider, toppedUp);\\n stakingProviderStruct.nuInTStake = tAmount;\\n increaseStakeCheckpoint(stakingProvider, toppedUp);\\n }\\n\\n //\\n //\\n // Undelegating a stake (unstaking)\\n //\\n //\\n\\n /// @notice Reduces the liquid T stake amount by the provided amount and\\n /// withdraws T to the owner. Reverts if there is at least one\\n /// authorization higher than the sum of the legacy stake and\\n /// remaining liquid T stake or if the unstake amount is higher than\\n /// the liquid T stake amount. Can be called only by the owner or\\n /// the staking provider. Can only be called when 24h passed since\\n /// the stake has been delegated.\\n function unstakeT(address stakingProvider, uint96 amount)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n amount > 0 &&\\n amount + getMinStaked(stakingProvider, StakeType.T) <=\\n stakingProviderStruct.tStake,\\n \\\"Too much to unstake\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n stakingProviderStruct.tStake -= amount;\\n decreaseStakeCheckpoint(stakingProvider, amount);\\n emit Unstaked(stakingProvider, amount);\\n token.safeTransfer(stakingProviderStruct.owner, amount);\\n }\\n\\n /// @notice Sets the legacy KEEP staking contract active stake amount cached\\n /// in T staking contract to 0. Reverts if the amount of liquid T\\n /// staked in T staking contract is lower than the highest\\n /// application authorization. This function allows to unstake from\\n /// KEEP staking contract and still being able to operate in T\\n /// network and earning rewards based on the liquid T staked. Can be\\n /// called only by the delegation owner or the staking provider.\\n /// Can only be called when 24h passed since the stake has been\\n /// delegated.\\n /// @dev This function (or `unstakeAll`) must be called before\\n /// `undelegate`/`undelegateAt` in Keep staking contract. Otherwise\\n /// provider can be slashed by `notifyKeepStakeDiscrepancy` method.\\n function unstakeKeep(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 keepInTStake = stakingProviderStruct.keepInTStake;\\n require(keepInTStake != 0, \\\"Nothing to unstake\\\");\\n require(\\n getMinStaked(stakingProvider, StakeType.KEEP) == 0,\\n \\\"Keep stake still authorized\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n emit Unstaked(stakingProvider, keepInTStake);\\n stakingProviderStruct.keepInTStake = 0;\\n decreaseStakeCheckpoint(stakingProvider, keepInTStake);\\n }\\n\\n /// @notice Reduces cached legacy NU stake amount by the provided amount.\\n /// Reverts if there is at least one authorization higher than the\\n /// sum of remaining legacy NU stake and liquid T stake for that\\n /// staking provider or if the untaked amount is higher than the\\n /// cached legacy stake amount. If succeeded, the legacy NU stake\\n /// can be partially or fully undelegated on the legacy staking\\n /// contract. This function allows to unstake from NU staking\\n /// contract and still being able to operate in T network and\\n /// earning rewards based on the liquid T staked. Can be called only\\n /// by the delegation owner or the staking provider. Can only be\\n /// called when 24h passed since the stake has been delegated.\\n /// @dev This function (or `unstakeAll`) must be called before `withdraw`\\n /// in NuCypher staking contract. Otherwise NU tokens can't be\\n /// unlocked.\\n /// @param stakingProvider Staking provider address\\n /// @param amount Amount of NU to unstake in T denomination\\n function unstakeNu(address stakingProvider, uint96 amount)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n // rounding amount to guarantee exact T<>NU conversion in both ways,\\n // so there's no remainder after unstaking\\n (, uint96 tRemainder) = convertFromT(amount, nucypherRatio);\\n amount -= tRemainder;\\n require(\\n amount > 0 &&\\n amount + getMinStaked(stakingProvider, StakeType.NU) <=\\n stakingProviderStruct.nuInTStake,\\n \\\"Too much to unstake\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n stakingProviderStruct.nuInTStake -= amount;\\n decreaseStakeCheckpoint(stakingProvider, amount);\\n emit Unstaked(stakingProvider, amount);\\n }\\n\\n /// @notice Sets cached legacy stake amount to 0, sets the liquid T stake\\n /// amount to 0 and withdraws all liquid T from the stake to the\\n /// owner. Reverts if there is at least one non-zero authorization.\\n /// Can be called only by the delegation owner or the staking\\n /// provider. Can only be called when 24h passed since the stake\\n /// has been delegated.\\n function unstakeAll(address stakingProvider)\\n external\\n override\\n onlyOwnerOrStakingProvider(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n stakingProviderStruct.authorizedApplications.length == 0,\\n \\\"Stake still authorized\\\"\\n );\\n require(\\n stakingProviderStruct.startStakingTimestamp + MIN_STAKE_TIME <=\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp,\\n \\\"Can't unstake earlier than 24h\\\"\\n );\\n\\n uint96 unstaked = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n emit Unstaked(stakingProvider, unstaked);\\n uint96 amount = stakingProviderStruct.tStake;\\n stakingProviderStruct.tStake = 0;\\n stakingProviderStruct.keepInTStake = 0;\\n stakingProviderStruct.nuInTStake = 0;\\n decreaseStakeCheckpoint(stakingProvider, unstaked);\\n\\n if (amount > 0) {\\n token.safeTransfer(stakingProviderStruct.owner, amount);\\n }\\n }\\n\\n //\\n //\\n // Keeping information in sync\\n //\\n //\\n\\n /// @notice Notifies about the discrepancy between legacy KEEP active stake\\n /// and the amount cached in T staking contract. Slashes the staking\\n /// provider in case the amount cached is higher than the actual\\n /// active stake amount in KEEP staking contract. Needs to update\\n /// authorizations of all affected applications and execute an\\n /// involuntary authorization decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n function notifyKeepStakeDiscrepancy(address stakingProvider)\\n external\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(stakingProviderStruct.keepInTStake > 0, \\\"Nothing to slash\\\");\\n\\n (uint256 keepStakeAmount, , uint256 undelegatedAt) = keepStakingContract\\n .getDelegationInfo(stakingProvider);\\n\\n (uint96 realKeepInTStake, ) = convertToT(keepStakeAmount, keepRatio);\\n uint96 oldKeepInTStake = stakingProviderStruct.keepInTStake;\\n\\n require(\\n oldKeepInTStake > realKeepInTStake || undelegatedAt != 0,\\n \\\"There is no discrepancy\\\"\\n );\\n stakingProviderStruct.keepInTStake = realKeepInTStake;\\n seizeKeep(\\n stakingProviderStruct,\\n stakingProvider,\\n stakeDiscrepancyPenalty,\\n stakeDiscrepancyRewardMultiplier\\n );\\n\\n uint96 slashedAmount = realKeepInTStake -\\n stakingProviderStruct.keepInTStake;\\n emit TokensSeized(stakingProvider, slashedAmount, true);\\n if (undelegatedAt != 0) {\\n stakingProviderStruct.keepInTStake = 0;\\n }\\n\\n decreaseStakeCheckpoint(\\n stakingProvider,\\n oldKeepInTStake - stakingProviderStruct.keepInTStake\\n );\\n\\n authorizationDecrease(\\n stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n }\\n\\n /// @notice Notifies about the discrepancy between legacy NU active stake\\n /// and the amount cached in T staking contract. Slashes the\\n /// staking provider in case the amount cached is higher than the\\n /// actual active stake amount in NU staking contract. Needs to\\n /// update authorizations of all affected applications and execute an\\n /// involuntary authorization decrease on all affected applications.\\n /// Can be called by anyone, notifier receives a reward.\\n /// @dev Real discrepancy between T and Nu is impossible.\\n /// This method is a safeguard in case of bugs in NuCypher staking\\n /// contract\\n function notifyNuStakeDiscrepancy(address stakingProvider)\\n external\\n override\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(stakingProviderStruct.nuInTStake > 0, \\\"Nothing to slash\\\");\\n\\n uint256 nuStakeAmount = nucypherStakingContract.getAllTokens(\\n stakingProviderStruct.owner\\n );\\n (uint96 realNuInTStake, ) = convertToT(nuStakeAmount, nucypherRatio);\\n uint96 oldNuInTStake = stakingProviderStruct.nuInTStake;\\n require(oldNuInTStake > realNuInTStake, \\\"There is no discrepancy\\\");\\n\\n stakingProviderStruct.nuInTStake = realNuInTStake;\\n seizeNu(\\n stakingProviderStruct,\\n stakeDiscrepancyPenalty,\\n stakeDiscrepancyRewardMultiplier\\n );\\n\\n uint96 slashedAmount = realNuInTStake -\\n stakingProviderStruct.nuInTStake;\\n emit TokensSeized(stakingProvider, slashedAmount, true);\\n authorizationDecrease(\\n stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n decreaseStakeCheckpoint(\\n stakingProvider,\\n oldNuInTStake - stakingProviderStruct.nuInTStake\\n );\\n }\\n\\n /// @notice Sets the penalty amount for stake discrepancy and reward\\n /// multiplier for reporting it. The penalty is seized from the\\n /// delegated stake, and 5% of the penalty, scaled by the\\n /// multiplier, is given to the notifier. The rest of the tokens are\\n /// burned. Can only be called by the Governance. See `seize` function.\\n function setStakeDiscrepancyPenalty(\\n uint96 penalty,\\n uint256 rewardMultiplier\\n ) external override onlyGovernance {\\n stakeDiscrepancyPenalty = penalty;\\n stakeDiscrepancyRewardMultiplier = rewardMultiplier;\\n emit StakeDiscrepancyPenaltySet(penalty, rewardMultiplier);\\n }\\n\\n /// @notice Sets reward in T tokens for notification of misbehaviour\\n /// of one staking provider. Can only be called by the governance.\\n function setNotificationReward(uint96 reward)\\n external\\n override\\n onlyGovernance\\n {\\n notificationReward = reward;\\n emit NotificationRewardSet(reward);\\n }\\n\\n /// @notice Transfer some amount of T tokens as reward for notifications\\n /// of misbehaviour\\n function pushNotificationReward(uint96 reward) external override {\\n require(reward > 0, \\\"Parameters must be specified\\\");\\n notifiersTreasury += reward;\\n emit NotificationRewardPushed(reward);\\n token.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraw some amount of T tokens from notifiers treasury.\\n /// Can only be called by the governance.\\n function withdrawNotificationReward(address recipient, uint96 amount)\\n external\\n override\\n onlyGovernance\\n {\\n require(amount <= notifiersTreasury, \\\"Not enough tokens\\\");\\n notifiersTreasury -= amount;\\n emit NotificationRewardWithdrawn(recipient, amount);\\n token.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount that should be slashed from each one of them. Can only be\\n /// called by application authorized for all staking providers in\\n /// the array.\\n /// @dev This method doesn't emit events for providers that are added to\\n /// the queue. If necessary events can be added to the application\\n /// level.\\n function slash(uint96 amount, address[] memory _stakingProviders)\\n external\\n override\\n {\\n notify(amount, 0, address(0), _stakingProviders);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each provider from\\n /// notifiers treasury. Can only be called by application\\n /// authorized for all staking providers in the array.\\n /// @dev This method doesn't emit events for staking providers that are\\n /// added to the queue. If necessary events can be added to the\\n /// application level.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) external override {\\n notify(amount, rewardMultiplier, notifier, _stakingProviders);\\n }\\n\\n /// @notice Takes the given number of queued slashing operations and\\n /// processes them. Receives 5% of the slashed amount.\\n /// Executes `involuntaryAuthorizationDecrease` function on each\\n /// affected application.\\n function processSlashing(uint256 count) external virtual override {\\n require(\\n slashingQueueIndex < slashingQueue.length && count > 0,\\n \\\"Nothing to process\\\"\\n );\\n\\n uint256 maxIndex = slashingQueueIndex + count;\\n maxIndex = MathUpgradeable.min(maxIndex, slashingQueue.length);\\n count = maxIndex - slashingQueueIndex;\\n uint96 tAmountToBurn = 0;\\n\\n uint256 index = slashingQueueIndex;\\n for (; index < maxIndex; index++) {\\n SlashingEvent storage slashing = slashingQueue[index];\\n tAmountToBurn += processSlashing(slashing);\\n }\\n slashingQueueIndex = index;\\n\\n uint256 tProcessorReward = uint256(tAmountToBurn).percent(\\n SLASHING_REWARD_PERCENT\\n );\\n notifiersTreasury += tAmountToBurn - tProcessorReward.toUint96();\\n emit SlashingProcessed(msg.sender, count, tProcessorReward);\\n if (tProcessorReward > 0) {\\n token.safeTransfer(msg.sender, tProcessorReward);\\n }\\n }\\n\\n /// @notice Delegate voting power from the stake associated to the\\n /// `stakingProvider` to a `delegatee` address. Caller must be the\\n /// owner of this stake.\\n function delegateVoting(address stakingProvider, address delegatee)\\n external\\n {\\n delegate(stakingProvider, delegatee);\\n }\\n\\n /// @notice Transfers ownership of the contract to `newGuvnor`.\\n function transferGovernance(address newGuvnor)\\n external\\n virtual\\n onlyGovernance\\n {\\n _transferGovernance(newGuvnor);\\n }\\n\\n //\\n //\\n // Auxiliary functions\\n //\\n //\\n\\n /// @notice Returns the authorized stake amount of the staking provider for\\n /// the application.\\n function authorizedStake(address stakingProvider, address application)\\n external\\n view\\n override\\n returns (uint96)\\n {\\n return\\n stakingProviders[stakingProvider]\\n .authorizations[application]\\n .authorized;\\n }\\n\\n /// @notice Returns staked amount of T, Keep and Nu for the specified\\n /// staking provider.\\n /// @dev All values are in T denomination\\n function stakes(address stakingProvider)\\n external\\n view\\n override\\n returns (\\n uint96 tStake,\\n uint96 keepInTStake,\\n uint96 nuInTStake\\n )\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n tStake = stakingProviderStruct.tStake;\\n keepInTStake = stakingProviderStruct.keepInTStake;\\n nuInTStake = stakingProviderStruct.nuInTStake;\\n }\\n\\n /// @notice Returns start staking timestamp.\\n /// @dev This value is set at most once.\\n function getStartStakingTimestamp(address stakingProvider)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return stakingProviders[stakingProvider].startStakingTimestamp;\\n }\\n\\n /// @notice Returns staked amount of NU for the specified staking provider.\\n function stakedNu(address stakingProvider)\\n external\\n view\\n override\\n returns (uint256 nuAmount)\\n {\\n (nuAmount, ) = convertFromT(\\n stakingProviders[stakingProvider].nuInTStake,\\n nucypherRatio\\n );\\n }\\n\\n /// @notice Gets the stake owner, the beneficiary and the authorizer\\n /// for the specified staking provider address.\\n /// @return owner Stake owner address.\\n /// @return beneficiary Beneficiary address.\\n /// @return authorizer Authorizer address.\\n function rolesOf(address stakingProvider)\\n external\\n view\\n override\\n returns (\\n address owner,\\n address payable beneficiary,\\n address authorizer\\n )\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n owner = stakingProviderStruct.owner;\\n beneficiary = stakingProviderStruct.beneficiary;\\n authorizer = stakingProviderStruct.authorizer;\\n }\\n\\n /// @notice Returns length of application array\\n function getApplicationsLength() external view override returns (uint256) {\\n return applications.length;\\n }\\n\\n /// @notice Returns length of slashing queue\\n function getSlashingQueueLength() external view override returns (uint256) {\\n return slashingQueue.length;\\n }\\n\\n /// @notice Requests decrease of the authorization for the given staking\\n /// provider on the given application by the provided amount.\\n /// It may not change the authorized amount immediatelly. When\\n /// it happens depends on the application. Can only be called by the\\n /// given staking provider\\u2019s authorizer. Overwrites pending\\n /// authorization decrease for the given staking provider and\\n /// application if the application agrees for that. If the\\n /// application does not agree for overwriting, the function\\n /// reverts.\\n /// @dev Calls `authorizationDecreaseRequested` callback on the given\\n /// application. See `IApplication`.\\n function requestAuthorizationDecrease(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) public override onlyAuthorizerOf(stakingProvider) {\\n ApplicationInfo storage applicationStruct = applicationInfo[\\n application\\n ];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n require(amount > 0, \\\"Parameters must be specified\\\");\\n\\n AppAuthorization storage authorization = stakingProviders[\\n stakingProvider\\n ].authorizations[application];\\n require(\\n authorization.authorized >= amount,\\n \\\"Amount exceeds authorized\\\"\\n );\\n\\n authorization.deauthorizing = amount;\\n uint96 deauthorizingTo = authorization.authorized - amount;\\n emit AuthorizationDecreaseRequested(\\n stakingProvider,\\n application,\\n authorization.authorized,\\n deauthorizingTo\\n );\\n IApplication(application).authorizationDecreaseRequested(\\n stakingProvider,\\n authorization.authorized,\\n deauthorizingTo\\n );\\n }\\n\\n /// @notice Returns minimum possible stake for T, KEEP or NU in T denomination\\n /// @dev For example, suppose the given staking provider has 10 T, 20 T worth\\n /// of KEEP, and 30 T worth of NU all staked, and the maximum\\n /// application authorization is 40 T, then `getMinStaked` for\\n /// that staking provider returns:\\n /// * 0 T if KEEP stake type specified i.e.\\n /// min = 40 T max - (10 T + 30 T worth of NU) = 0 T\\n /// * 10 T if NU stake type specified i.e.\\n /// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T\\n /// * 0 T if T stake type specified i.e.\\n /// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T\\n /// In other words, the minimum stake amount for the specified\\n /// stake type is the minimum amount of stake of the given type\\n /// needed to satisfy the maximum application authorization given\\n /// the staked amounts of the other stake types for that staking\\n /// provider.\\n function getMinStaked(address stakingProvider, StakeType stakeTypes)\\n public\\n view\\n override\\n returns (uint96)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint256 maxAuthorization = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address application = stakingProviderStruct.authorizedApplications[\\n i\\n ];\\n maxAuthorization = MathUpgradeable.max(\\n maxAuthorization,\\n stakingProviderStruct.authorizations[application].authorized\\n );\\n }\\n\\n if (maxAuthorization == 0) {\\n return 0;\\n }\\n if (stakeTypes != StakeType.T) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.tStake\\n );\\n }\\n if (stakeTypes != StakeType.NU) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.nuInTStake\\n );\\n }\\n if (stakeTypes != StakeType.KEEP) {\\n maxAuthorization -= MathUpgradeable.min(\\n maxAuthorization,\\n stakingProviderStruct.keepInTStake\\n );\\n }\\n return maxAuthorization.toUint96();\\n }\\n\\n /// @notice Returns available amount to authorize for the specified\\n /// application.\\n function getAvailableToAuthorize(\\n address stakingProvider,\\n address application\\n ) public view override returns (uint96 availableTValue) {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n availableTValue =\\n stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n availableTValue -= stakingProviderStruct\\n .authorizations[application]\\n .authorized;\\n }\\n\\n /// @notice Delegate voting power from the stake associated to the\\n /// `stakingProvider` to a `delegatee` address. Caller must be the owner\\n /// of this stake.\\n /// @dev Original abstract function defined in Checkpoints contract had two\\n /// parameters, `delegator` and `delegatee`. Here we override it and\\n /// comply with the same signature but the semantics of the first\\n /// parameter changes to the `stakingProvider` address.\\n function delegate(address stakingProvider, address delegatee)\\n internal\\n virtual\\n override\\n onlyOwnerOf(stakingProvider)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n uint96 stakingProviderBalance = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n address oldDelegatee = delegates(stakingProvider);\\n _delegates[stakingProvider] = delegatee;\\n emit DelegateChanged(stakingProvider, oldDelegatee, delegatee);\\n moveVotingPower(oldDelegatee, delegatee, stakingProviderBalance);\\n }\\n\\n /// @notice Adds staking providers to the slashing queue along with the\\n /// amount. The notifier will receive reward per each staking\\n /// provider from notifiers treasury. Can only be called by\\n /// application authorized for all staking providers in the array.\\n function notify(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) internal {\\n require(\\n amount > 0 && _stakingProviders.length > 0,\\n \\\"Parameters must be specified\\\"\\n );\\n\\n ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];\\n require(\\n applicationStruct.status == ApplicationStatus.APPROVED,\\n \\\"Application is not approved\\\"\\n );\\n\\n uint256 queueLength = slashingQueue.length;\\n for (uint256 i = 0; i < _stakingProviders.length; i++) {\\n address stakingProvider = _stakingProviders[i];\\n uint256 amountToSlash = MathUpgradeable.min(\\n stakingProviders[stakingProvider]\\n .authorizations[msg.sender]\\n .authorized,\\n amount\\n );\\n if (\\n //slither-disable-next-line incorrect-equality\\n amountToSlash == 0\\n ) {\\n continue;\\n }\\n slashingQueue.push(\\n SlashingEvent(stakingProvider, amountToSlash.toUint96())\\n );\\n }\\n\\n if (notifier != address(0)) {\\n uint256 reward = ((slashingQueue.length - queueLength) *\\n notificationReward).percent(rewardMultiplier);\\n reward = MathUpgradeable.min(reward, notifiersTreasury);\\n emit NotifierRewarded(notifier, reward);\\n if (reward != 0) {\\n notifiersTreasury -= reward;\\n token.safeTransfer(notifier, reward);\\n }\\n }\\n }\\n\\n /// @notice Processes one specified slashing event.\\n /// Executes `involuntaryAuthorizationDecrease` function on each\\n /// affected application.\\n //slither-disable-next-line dead-code\\n function processSlashing(SlashingEvent storage slashing)\\n internal\\n returns (uint96 tAmountToBurn)\\n {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n slashing.stakingProvider\\n ];\\n uint96 tAmountToSlash = slashing.amount;\\n uint96 oldStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n // slash T\\n if (stakingProviderStruct.tStake > 0) {\\n if (tAmountToSlash <= stakingProviderStruct.tStake) {\\n tAmountToBurn = tAmountToSlash;\\n } else {\\n tAmountToBurn = stakingProviderStruct.tStake;\\n }\\n stakingProviderStruct.tStake -= tAmountToBurn;\\n tAmountToSlash -= tAmountToBurn;\\n }\\n\\n // slash KEEP\\n if (tAmountToSlash > 0 && stakingProviderStruct.keepInTStake > 0) {\\n (uint256 keepStakeAmount, , ) = keepStakingContract\\n .getDelegationInfo(slashing.stakingProvider);\\n (uint96 tAmount, ) = convertToT(keepStakeAmount, keepRatio);\\n stakingProviderStruct.keepInTStake = tAmount;\\n\\n tAmountToSlash = seizeKeep(\\n stakingProviderStruct,\\n slashing.stakingProvider,\\n tAmountToSlash,\\n 100\\n );\\n }\\n\\n // slash NU\\n if (tAmountToSlash > 0 && stakingProviderStruct.nuInTStake > 0) {\\n // synchronization skipped due to impossibility of real discrepancy\\n tAmountToSlash = seizeNu(\\n stakingProviderStruct,\\n tAmountToSlash,\\n 100\\n );\\n }\\n\\n uint96 slashedAmount = slashing.amount - tAmountToSlash;\\n emit TokensSeized(slashing.stakingProvider, slashedAmount, false);\\n authorizationDecrease(\\n slashing.stakingProvider,\\n stakingProviderStruct,\\n slashedAmount\\n );\\n uint96 newStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.keepInTStake +\\n stakingProviderStruct.nuInTStake;\\n decreaseStakeCheckpoint(slashing.stakingProvider, oldStake - newStake);\\n }\\n\\n /// @notice Synchronize authorizations (if needed) after slashing stake\\n function authorizationDecrease(\\n address stakingProvider,\\n StakingProviderInfo storage stakingProviderStruct,\\n uint96 slashedAmount\\n ) internal {\\n uint96 totalStake = stakingProviderStruct.tStake +\\n stakingProviderStruct.nuInTStake +\\n stakingProviderStruct.keepInTStake;\\n uint256 applicationsToDelete = 0;\\n for (\\n uint256 i = 0;\\n i < stakingProviderStruct.authorizedApplications.length;\\n i++\\n ) {\\n address authorizedApplication = stakingProviderStruct\\n .authorizedApplications[i];\\n AppAuthorization storage authorization = stakingProviderStruct\\n .authorizations[authorizedApplication];\\n uint96 fromAmount = authorization.authorized;\\n\\n authorization.authorized -= MathUpgradeable\\n .min(fromAmount, slashedAmount)\\n .toUint96();\\n\\n if (authorization.authorized > totalStake) {\\n authorization.authorized = totalStake;\\n }\\n\\n bool successful = true;\\n //slither-disable-next-line calls-loop\\n try\\n IApplication(authorizedApplication)\\n .involuntaryAuthorizationDecrease{\\n gas: GAS_LIMIT_AUTHORIZATION_DECREASE\\n }(stakingProvider, fromAmount, authorization.authorized)\\n {} catch {\\n successful = false;\\n }\\n if (authorization.deauthorizing > authorization.authorized) {\\n authorization.deauthorizing = authorization.authorized;\\n }\\n emit AuthorizationInvoluntaryDecreased(\\n stakingProvider,\\n authorizedApplication,\\n fromAmount,\\n authorization.authorized,\\n successful\\n );\\n if (authorization.authorized == 0) {\\n applicationsToDelete++;\\n }\\n }\\n if (applicationsToDelete > 0) {\\n cleanAuthorizedApplications(\\n stakingProviderStruct,\\n applicationsToDelete\\n );\\n }\\n }\\n\\n /// @notice Convert amount from T to Keep and call `seize` in Keep staking contract.\\n /// Returns remainder of slashing amount in T\\n /// @dev Note this internal function doesn't update stake checkpoints\\n function seizeKeep(\\n StakingProviderInfo storage stakingProviderStruct,\\n address stakingProvider,\\n uint96 tAmountToSlash,\\n uint256 rewardMultiplier\\n ) internal returns (uint96) {\\n if (stakingProviderStruct.keepInTStake == 0) {\\n return tAmountToSlash;\\n }\\n\\n uint96 tPenalty;\\n if (tAmountToSlash <= stakingProviderStruct.keepInTStake) {\\n tPenalty = tAmountToSlash;\\n } else {\\n tPenalty = stakingProviderStruct.keepInTStake;\\n }\\n\\n (uint256 keepPenalty, uint96 tRemainder) = convertFromT(\\n tPenalty,\\n keepRatio\\n );\\n if (keepPenalty == 0) {\\n return tAmountToSlash;\\n }\\n tPenalty -= tRemainder;\\n stakingProviderStruct.keepInTStake -= tPenalty;\\n tAmountToSlash -= tPenalty;\\n\\n address[] memory stakingProviderWrapper = new address[](1);\\n stakingProviderWrapper[0] = stakingProvider;\\n keepStakingContract.seize(\\n keepPenalty,\\n rewardMultiplier,\\n msg.sender,\\n stakingProviderWrapper\\n );\\n return tAmountToSlash;\\n }\\n\\n /// @notice Convert amount from T to NU and call `slashStaker` in NuCypher staking contract.\\n /// Returns remainder of slashing amount in T\\n /// @dev Note this internal function doesn't update the stake checkpoints\\n function seizeNu(\\n StakingProviderInfo storage stakingProviderStruct,\\n uint96 tAmountToSlash,\\n uint256 rewardMultiplier\\n ) internal returns (uint96) {\\n if (stakingProviderStruct.nuInTStake == 0) {\\n return tAmountToSlash;\\n }\\n\\n uint96 tPenalty;\\n if (tAmountToSlash <= stakingProviderStruct.nuInTStake) {\\n tPenalty = tAmountToSlash;\\n } else {\\n tPenalty = stakingProviderStruct.nuInTStake;\\n }\\n\\n (uint256 nuPenalty, uint96 tRemainder) = convertFromT(\\n tPenalty,\\n nucypherRatio\\n );\\n if (nuPenalty == 0) {\\n return tAmountToSlash;\\n }\\n tPenalty -= tRemainder;\\n stakingProviderStruct.nuInTStake -= tPenalty;\\n tAmountToSlash -= tPenalty;\\n\\n uint256 nuReward = nuPenalty.percent(SLASHING_REWARD_PERCENT).percent(\\n rewardMultiplier\\n );\\n nucypherStakingContract.slashStaker(\\n stakingProviderStruct.owner,\\n nuPenalty,\\n msg.sender,\\n nuReward\\n );\\n return tAmountToSlash;\\n }\\n\\n /// @notice Removes application with zero authorization from authorized\\n /// applications array\\n function cleanAuthorizedApplications(\\n StakingProviderInfo storage stakingProviderStruct,\\n uint256 numberToDelete\\n ) internal {\\n uint256 length = stakingProviderStruct.authorizedApplications.length;\\n if (numberToDelete == length) {\\n delete stakingProviderStruct.authorizedApplications;\\n return;\\n }\\n\\n uint256 deleted = 0;\\n uint256 index = 0;\\n uint256 newLength = length - numberToDelete;\\n while (index < newLength && deleted < numberToDelete) {\\n address application = stakingProviderStruct.authorizedApplications[\\n index\\n ];\\n if (\\n stakingProviderStruct.authorizations[application].authorized ==\\n 0\\n ) {\\n stakingProviderStruct.authorizedApplications[\\n index\\n ] = stakingProviderStruct.authorizedApplications[\\n length - deleted - 1\\n ];\\n deleted++;\\n } else {\\n index++;\\n }\\n }\\n\\n for (index = newLength; index < length; index++) {\\n stakingProviderStruct.authorizedApplications.pop();\\n }\\n }\\n\\n /// @notice Creates new checkpoints due to a change of stake amount\\n /// @param _delegator Address of the staking provider acting as delegator\\n /// @param _amount Amount of T to increment\\n /// @param increase True if the change is an increase, false if a decrease\\n function newStakeCheckpoint(\\n address _delegator,\\n uint96 _amount,\\n bool increase\\n ) internal {\\n if (_amount == 0) {\\n return;\\n }\\n writeCheckpoint(\\n _totalSupplyCheckpoints,\\n increase ? add : subtract,\\n _amount\\n );\\n address delegatee = delegates(_delegator);\\n if (delegatee != address(0)) {\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[delegatee],\\n increase ? add : subtract,\\n _amount\\n );\\n emit DelegateVotesChanged(delegatee, oldWeight, newWeight);\\n }\\n }\\n\\n /// @notice Creates new checkpoints due to an increment of a stakers' stake\\n /// @param _delegator Address of the staking provider acting as delegator\\n /// @param _amount Amount of T to increment\\n function increaseStakeCheckpoint(address _delegator, uint96 _amount)\\n internal\\n {\\n newStakeCheckpoint(_delegator, _amount, true);\\n }\\n\\n /// @notice Creates new checkpoints due to a decrease of a stakers' stake\\n /// @param _delegator Address of the stake owner acting as delegator\\n /// @param _amount Amount of T to decrease\\n function decreaseStakeCheckpoint(address _delegator, uint96 _amount)\\n internal\\n {\\n newStakeCheckpoint(_delegator, _amount, false);\\n }\\n\\n /// @notice Returns amount of Nu stake in the NuCypher staking contract for\\n /// the specified staking provider.\\n /// Resulting value in T denomination\\n function getNuAmountInT(address owner, address stakingProvider)\\n internal\\n returns (uint96)\\n {\\n uint256 nuStakeAmount = nucypherStakingContract.requestMerge(\\n owner,\\n stakingProvider\\n );\\n (uint96 tAmount, ) = convertToT(nuStakeAmount, nucypherRatio);\\n return tAmount;\\n }\\n\\n function _transferGovernance(address newGuvnor) internal virtual {\\n address oldGuvnor = governance;\\n governance = newGuvnor;\\n emit GovernanceTransferred(oldGuvnor, newGuvnor);\\n }\\n\\n /// @notice Returns amount of Keep stake in the Keep staking contract for\\n /// the specified staking provider.\\n /// Resulting value in T denomination\\n function getKeepAmountInT(address stakingProvider)\\n internal\\n view\\n returns (uint96)\\n {\\n uint256 keepStakeAmount = keepStakingContract.eligibleStake(\\n stakingProvider,\\n address(this)\\n );\\n (uint96 tAmount, ) = convertToT(keepStakeAmount, keepRatio);\\n return tAmount;\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` legacy\\n /// tokens for the given `ratio`, and the remainder that can't be\\n /// converted.\\n function convertToT(uint256 amount, uint256 ratio)\\n internal\\n pure\\n returns (uint96 tAmount, uint256 remainder)\\n {\\n remainder = amount % CONVERSION_DIVISOR;\\n uint256 convertibleAmount = amount - remainder;\\n tAmount = ((convertibleAmount * ratio) / CONVERSION_DIVISOR).toUint96();\\n }\\n\\n /// @notice Returns the amount of legacy tokens that's obtained from\\n /// `tAmount` T tokens for the given `ratio`, and the T remainder\\n /// that can't be converted.\\n function convertFromT(uint96 tAmount, uint256 ratio)\\n internal\\n pure\\n returns (uint256 amount, uint96 tRemainder)\\n {\\n //slither-disable-next-line weak-prng\\n tRemainder = (tAmount % ratio).toUint96();\\n uint256 convertibleAmount = tAmount - tRemainder;\\n amount = (convertibleAmount * CONVERSION_DIVISOR) / ratio;\\n }\\n}\\n\",\"keccak256\":\"0xa27013f0a67e85cdaffe06db9e9be9f44a4e71db682a6e85835b6242827bc6d2\",\"license\":\"GPL-3.0-or-later\"},\"contracts/test/TokenStakingTestSet.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"../staking/ILegacyTokenStaking.sol\\\";\\nimport \\\"../staking/IApplication.sol\\\";\\nimport \\\"../staking/TokenStaking.sol\\\";\\n\\ncontract KeepTokenStakingMock is IKeepTokenStaking {\\n using PercentUtils for uint256;\\n\\n struct OperatorStruct {\\n address owner;\\n address payable beneficiary;\\n address authorizer;\\n uint256 createdAt;\\n uint256 undelegatedAt;\\n uint256 amount;\\n mapping(address => bool) eligibility;\\n }\\n\\n mapping(address => OperatorStruct) internal operators;\\n mapping(address => uint256) public tattletales;\\n\\n function setOperator(\\n address operator,\\n address owner,\\n address payable beneficiary,\\n address authorizer,\\n uint256 createdAt,\\n uint256 undelegatedAt,\\n uint256 amount\\n ) external {\\n OperatorStruct storage operatorStrut = operators[operator];\\n operatorStrut.owner = owner;\\n operatorStrut.beneficiary = beneficiary;\\n operatorStrut.authorizer = authorizer;\\n operatorStrut.createdAt = createdAt;\\n operatorStrut.undelegatedAt = undelegatedAt;\\n operatorStrut.amount = amount;\\n }\\n\\n function setEligibility(\\n address operator,\\n address application,\\n bool isEligible\\n ) external {\\n operators[operator].eligibility[application] = isEligible;\\n }\\n\\n function setAmount(address operator, uint256 amount) external {\\n operators[operator].amount = amount;\\n }\\n\\n function setUndelegatedAt(address operator, uint256 undelegatedAt)\\n external\\n {\\n operators[operator].undelegatedAt = undelegatedAt;\\n }\\n\\n function seize(\\n uint256 amountToSeize,\\n uint256 rewardMultiplier,\\n address tattletale,\\n address[] memory misbehavedOperators\\n ) external override {\\n require(amountToSeize > 0, \\\"Amount to slash must be greater than zero\\\");\\n // assumed only one will be slashed (per call)\\n require(\\n misbehavedOperators.length == 1,\\n \\\"Only one operator per call in tests\\\"\\n );\\n address operator = misbehavedOperators[0];\\n operators[operator].amount -= amountToSeize;\\n tattletales[tattletale] += amountToSeize.percent(5).percent(\\n rewardMultiplier\\n );\\n }\\n\\n function getDelegationInfo(address operator)\\n external\\n view\\n override\\n returns (\\n uint256 amount,\\n uint256 createdAt,\\n uint256 undelegatedAt\\n )\\n {\\n amount = operators[operator].amount;\\n createdAt = operators[operator].createdAt;\\n undelegatedAt = operators[operator].undelegatedAt;\\n }\\n\\n function ownerOf(address operator)\\n external\\n view\\n override\\n returns (address)\\n {\\n return operators[operator].owner;\\n }\\n\\n function beneficiaryOf(address operator)\\n external\\n view\\n override\\n returns (address payable)\\n {\\n return operators[operator].beneficiary;\\n }\\n\\n function authorizerOf(address operator)\\n external\\n view\\n override\\n returns (address)\\n {\\n return operators[operator].authorizer;\\n }\\n\\n function eligibleStake(address operator, address operatorContract)\\n external\\n view\\n override\\n returns (uint256 balance)\\n {\\n OperatorStruct storage operatorStrut = operators[operator];\\n if (operatorStrut.eligibility[operatorContract]) {\\n return operatorStrut.amount;\\n }\\n return 0;\\n }\\n}\\n\\ncontract NuCypherTokenStakingMock is INuCypherStakingEscrow {\\n struct StakerStruct {\\n uint256 value;\\n address stakingProvider;\\n }\\n\\n mapping(address => StakerStruct) public stakers;\\n mapping(address => uint256) public investigators;\\n\\n function setStaker(address staker, uint256 value) external {\\n stakers[staker].value = value;\\n }\\n\\n function slashStaker(\\n address staker,\\n uint256 penalty,\\n address investigator,\\n uint256 reward\\n ) external override {\\n require(penalty > 0, \\\"Amount to slash must be greater than zero\\\");\\n stakers[staker].value -= penalty;\\n investigators[investigator] += reward;\\n }\\n\\n function requestMerge(address staker, address stakingProvider)\\n external\\n override\\n returns (uint256)\\n {\\n StakerStruct storage stakerStruct = stakers[staker];\\n require(\\n stakerStruct.stakingProvider == address(0) ||\\n stakerStruct.stakingProvider == stakingProvider,\\n \\\"Another provider was already set for this staker\\\"\\n );\\n if (stakerStruct.stakingProvider == address(0)) {\\n stakerStruct.stakingProvider = stakingProvider;\\n }\\n return stakers[staker].value;\\n }\\n\\n function getAllTokens(address staker)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return stakers[staker].value;\\n }\\n\\n function stakerInfo(address staker)\\n public\\n view\\n returns (StakerStruct memory)\\n {\\n return stakers[staker];\\n }\\n}\\n\\ncontract VendingMachineMock {\\n uint256 public constant FLOATING_POINT_DIVISOR = 10**15;\\n\\n uint256 public immutable ratio;\\n\\n constructor(uint96 _wrappedTokenAllocation, uint96 _tTokenAllocation) {\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n}\\n\\ncontract ApplicationMock is IApplication {\\n struct StakingProviderStruct {\\n uint96 authorized;\\n uint96 deauthorizingTo;\\n }\\n\\n TokenStaking internal immutable tokenStaking;\\n mapping(address => StakingProviderStruct) public stakingProviders;\\n\\n constructor(TokenStaking _tokenStaking) {\\n tokenStaking = _tokenStaking;\\n }\\n\\n function withdrawRewards(address) external {\\n // does nothing\\n }\\n\\n function authorizationIncreased(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) external override {\\n stakingProviders[stakingProvider].authorized = toAmount;\\n }\\n\\n function authorizationDecreaseRequested(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) external override {\\n stakingProviders[stakingProvider].deauthorizingTo = toAmount;\\n }\\n\\n function approveAuthorizationDecrease(address stakingProvider) external {\\n StakingProviderStruct storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n stakingProviderStruct.authorized = tokenStaking\\n .approveAuthorizationDecrease(stakingProvider);\\n }\\n\\n function slash(uint96 amount, address[] memory _stakingProviders) external {\\n tokenStaking.slash(amount, _stakingProviders);\\n }\\n\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n address[] memory _stakingProviders\\n ) external {\\n tokenStaking.seize(\\n amount,\\n rewardMultiplier,\\n notifier,\\n _stakingProviders\\n );\\n }\\n\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96,\\n uint96 toAmount\\n ) public virtual override {\\n StakingProviderStruct storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n require(\\n toAmount != stakingProviderStruct.authorized,\\n \\\"Nothing to decrease\\\"\\n );\\n uint96 decrease = stakingProviderStruct.authorized - toAmount;\\n if (stakingProviderStruct.deauthorizingTo > decrease) {\\n stakingProviderStruct.deauthorizingTo -= decrease;\\n } else {\\n stakingProviderStruct.deauthorizingTo = 0;\\n }\\n stakingProviderStruct.authorized = toAmount;\\n }\\n\\n function availableRewards(address) external pure returns (uint96) {\\n return 0;\\n }\\n\\n function minimumAuthorization() external pure returns (uint96) {\\n return 0;\\n }\\n}\\n\\ncontract BrokenApplicationMock is ApplicationMock {\\n constructor(TokenStaking _tokenStaking) ApplicationMock(_tokenStaking) {}\\n\\n function involuntaryAuthorizationDecrease(\\n address,\\n uint96,\\n uint96\\n ) public pure override {\\n revert(\\\"Broken application\\\");\\n }\\n}\\n\\ncontract ExpensiveApplicationMock is ApplicationMock {\\n uint256[] private dummy;\\n\\n constructor(TokenStaking _tokenStaking) ApplicationMock(_tokenStaking) {}\\n\\n function involuntaryAuthorizationDecrease(\\n address stakingProvider,\\n uint96 fromAmount,\\n uint96 toAmount\\n ) public override {\\n super.involuntaryAuthorizationDecrease(\\n stakingProvider,\\n fromAmount,\\n toAmount\\n );\\n for (uint256 i = 0; i < 12; i++) {\\n dummy.push(i);\\n }\\n }\\n}\\n\\ncontract ManagedGrantMock {\\n address public grantee;\\n\\n //slither-disable-next-line missing-zero-check\\n function setGrantee(address _grantee) external {\\n grantee = _grantee;\\n }\\n}\\n\\ncontract ExtendedTokenStaking is TokenStaking {\\n constructor(\\n T _token,\\n IKeepTokenStaking _keepStakingContract,\\n INuCypherStakingEscrow _nucypherStakingContract,\\n VendingMachine _keepVendingMachine,\\n VendingMachine _nucypherVendingMachine,\\n KeepStake _keepStake\\n )\\n TokenStaking(\\n _token,\\n _keepStakingContract,\\n _nucypherStakingContract,\\n _keepVendingMachine,\\n _nucypherVendingMachine,\\n _keepStake\\n )\\n {}\\n\\n function cleanAuthorizedApplications(\\n address stakingProvider,\\n uint256 numberToDelete\\n ) external {\\n StakingProviderInfo storage stakingProviderStruct = stakingProviders[\\n stakingProvider\\n ];\\n cleanAuthorizedApplications(stakingProviderStruct, numberToDelete);\\n }\\n\\n function setAuthorization(\\n address stakingProvider,\\n address application,\\n uint96 amount\\n ) external {\\n stakingProviders[stakingProvider]\\n .authorizations[application]\\n .authorized = amount;\\n }\\n\\n function setAuthorizedApplications(\\n address stakingProvider,\\n address[] memory _applications\\n ) external {\\n stakingProviders[stakingProvider]\\n .authorizedApplications = _applications;\\n }\\n\\n // to decrease size of test contract\\n function processSlashing(uint256 count) external override {}\\n\\n function getAuthorizedApplications(address stakingProvider)\\n external\\n view\\n returns (address[] memory)\\n {\\n return stakingProviders[stakingProvider].authorizedApplications;\\n }\\n}\\n\",\"keccak256\":\"0x55bd1a8dc0c354ff3be00489028bd31f95fbf8c75a2c28a41f1b2466a7f955be\",\"license\":\"GPL-3.0-or-later\"},\"contracts/token/T.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 \\\"../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\",\"keccak256\":\"0x6265416225fd15b1108fce13d570b53a862a5d256ba2e6329bccf658eccac430\",\"license\":\"GPL-3.0-or-later\"},\"contracts/utils/PercentUtils.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\\nlibrary PercentUtils {\\n // Return `b`% of `a`\\n // 200.percent(40) == 80\\n // Commutative, works both ways\\n function percent(uint256 a, uint256 b) internal pure returns (uint256) {\\n return (a * b) / 100;\\n }\\n\\n // Return `a` as percentage of `b`:\\n // 80.asPercentOf(200) == 40\\n //slither-disable-next-line dead-code\\n function asPercentOf(uint256 a, uint256 b) internal pure returns (uint256) {\\n return (a * 100) / b;\\n }\\n}\\n\",\"keccak256\":\"0xf5feadeff9d504b33058dfd6c2b99d31ecebc152b356272646a7afe6ed638d40\",\"license\":\"GPL-3.0-or-later\"},\"contracts/utils/SafeTUpgradeable.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 \\\"../token/T.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\n\\n/// @notice A wrapper around OpenZeppelin's `SafeERC20Upgradeable` but specific\\n/// to the T token. Use this library in upgradeable contracts. If your\\n/// contract is non-upgradeable, then the traditional `SafeERC20` works.\\n/// The motivation is to prevent upgradeable contracts that use T from\\n/// depending on the `Address` library, which can be problematic since\\n/// it uses `delegatecall`, which is discouraged by OpenZeppelin for use\\n/// in upgradeable contracts.\\n/// @dev This implementation force-casts T to `IERC20Upgradeable` to make it\\n/// work with `SafeERC20Upgradeable`.\\nlibrary SafeTUpgradeable {\\n function safeTransfer(\\n T token,\\n address to,\\n uint256 value\\n ) internal {\\n SafeERC20Upgradeable.safeTransfer(\\n IERC20Upgradeable(address(token)),\\n to,\\n value\\n );\\n }\\n\\n function safeTransferFrom(\\n T token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n SafeERC20Upgradeable.safeTransferFrom(\\n IERC20Upgradeable(address(token)),\\n from,\\n to,\\n value\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf53907099650f9f973ff51c403730e7ae7170a5728fbde49f0f00b0a17775ce7\",\"license\":\"GPL-3.0-or-later\"},\"contracts/vending/VendingMachine.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 \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\nimport \\\"../token/T.sol\\\";\\n\\n/// @title T token vending machine\\n/// @notice Contract implements a special update protocol to enable KEEP/NU\\n/// token holders to wrap their tokens and obtain T tokens according\\n/// to a fixed ratio. This will go on indefinitely and enable NU and\\n/// KEEP token holders to join T network without needing to buy or\\n/// sell any assets. Logistically, anyone holding NU or KEEP can wrap\\n/// those assets in order to upgrade to T. They can also unwrap T in\\n/// order to downgrade back to the underlying asset. There is a separate\\n/// instance of this contract deployed for KEEP holders and a separate\\n/// instance of this contract deployed for NU holders.\\ncontract VendingMachine is IReceiveApproval {\\n using SafeERC20 for IERC20;\\n using SafeERC20 for T;\\n\\n /// @notice Number of decimal places of precision in conversion to/from\\n /// wrapped tokens (assuming typical ERC20 token with 18 decimals).\\n /// This implies that amounts of wrapped tokens below this precision\\n /// won't take part in the conversion. E.g., for a value of 3, then\\n /// for a conversion of 1.123456789 wrapped tokens, only 1.123 is\\n /// convertible (i.e., 3 decimal places), and 0.000456789 is left.\\n uint256 public constant WRAPPED_TOKEN_CONVERSION_PRECISION = 3;\\n\\n /// @notice Divisor for precision purposes, used to represent fractions.\\n uint256 public constant FLOATING_POINT_DIVISOR =\\n 10**(18 - WRAPPED_TOKEN_CONVERSION_PRECISION);\\n\\n /// @notice The token being wrapped to T (KEEP/NU).\\n IERC20 public immutable wrappedToken;\\n\\n /// @notice T token contract.\\n T public immutable tToken;\\n\\n /// @notice The ratio with which T token is converted based on the provided\\n /// token being wrapped (KEEP/NU), expressed in 1e18 precision.\\n ///\\n /// When wrapping:\\n /// x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR\\n ///\\n /// When unwrapping:\\n /// x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\\n uint256 public immutable ratio;\\n\\n /// @notice The total balance of wrapped tokens for the given holder\\n /// account. Only holders that have previously wrapped KEEP/NU to T\\n /// can unwrap, up to the amount previously wrapped.\\n mapping(address => uint256) public wrappedBalance;\\n\\n event Wrapped(\\n address indexed recipient,\\n uint256 wrappedTokenAmount,\\n uint256 tTokenAmount\\n );\\n event Unwrapped(\\n address indexed recipient,\\n uint256 tTokenAmount,\\n uint256 wrappedTokenAmount\\n );\\n\\n /// @notice Sets the reference to `wrappedToken` and `tToken`. Initializes\\n /// conversion `ratio` between wrapped token and T based on the\\n /// provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\\n /// @param _wrappedToken Address to ERC20 token that will be wrapped to T\\n /// @param _tToken Address of T token\\n /// @param _wrappedTokenAllocation The total supply of the token that will be\\n /// wrapped to T\\n /// @param _tTokenAllocation The allocation of T this instance of Vending\\n /// Machine will receive\\n /// @dev Multiplications in this contract can't overflow uint256 as we\\n /// restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to\\n /// 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\\n constructor(\\n IERC20 _wrappedToken,\\n T _tToken,\\n uint96 _wrappedTokenAllocation,\\n uint96 _tTokenAllocation\\n ) {\\n wrappedToken = _wrappedToken;\\n tToken = _tToken;\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n\\n /// @notice Wraps up to the the given `amount` of the token (KEEP/NU) and\\n /// releases T token proportionally to the amount being wrapped with\\n /// respect to the wrap ratio. The token holder needs to have at\\n /// least the given amount of the wrapped token (KEEP/NU) approved\\n /// to transfer to the Vending Machine before calling this function.\\n /// @param amount The amount of KEEP/NU to be wrapped\\n function wrap(uint256 amount) external {\\n _wrap(msg.sender, amount);\\n }\\n\\n /// @notice Wraps up to the given amount of the token (KEEP/NU) and releases\\n /// T token proportionally to the amount being wrapped with respect\\n /// to the wrap ratio. This is a shortcut to `wrap` function that\\n /// avoids a separate approval transaction. Only KEEP/NU token\\n /// is allowed as a caller, so please call this function via\\n /// token's `approveAndCall`.\\n /// @param from Caller's address, must be the same as `wrappedToken` field\\n /// @param amount The amount of KEEP/NU to be wrapped\\n /// @param token Token's address, must be the same as `wrappedToken` field\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(\\n token == address(wrappedToken),\\n \\\"Token is not the wrapped token\\\"\\n );\\n require(\\n msg.sender == address(wrappedToken),\\n \\\"Only wrapped token caller allowed\\\"\\n );\\n _wrap(from, amount);\\n }\\n\\n /// @notice Unwraps up to the given `amount` of T back to the legacy token\\n /// (KEEP/NU) according to the wrap ratio. It can only be called by\\n /// a token holder who previously wrapped their tokens in this\\n /// vending machine contract. The token holder can't unwrap more\\n /// tokens than they originally wrapped. The token holder needs to\\n /// have at least the given amount of T tokens approved to transfer\\n /// to the Vending Machine before calling this function.\\n /// @param amount The amount of T to unwrap back to the collateral (KEEP/NU)\\n function unwrap(uint256 amount) external {\\n _unwrap(msg.sender, amount);\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` wrapped\\n /// tokens (KEEP/NU), and the remainder that can't be upgraded.\\n function conversionToT(uint256 amount)\\n public\\n view\\n returns (uint256 tAmount, uint256 wrappedRemainder)\\n {\\n wrappedRemainder = amount % FLOATING_POINT_DIVISOR;\\n uint256 convertibleAmount = amount - wrappedRemainder;\\n tAmount = (convertibleAmount * ratio) / FLOATING_POINT_DIVISOR;\\n }\\n\\n /// @notice The amount of wrapped tokens (KEEP/NU) that's obtained from\\n /// `amount` T tokens, and the remainder that can't be downgraded.\\n function conversionFromT(uint256 amount)\\n public\\n view\\n returns (uint256 wrappedAmount, uint256 tRemainder)\\n {\\n tRemainder = amount % ratio;\\n uint256 convertibleAmount = amount - tRemainder;\\n wrappedAmount = (convertibleAmount * FLOATING_POINT_DIVISOR) / ratio;\\n }\\n\\n function _wrap(address tokenHolder, uint256 wrappedTokenAmount) internal {\\n (uint256 tTokenAmount, uint256 remainder) = conversionToT(\\n wrappedTokenAmount\\n );\\n wrappedTokenAmount -= remainder;\\n require(wrappedTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n emit Wrapped(tokenHolder, wrappedTokenAmount, tTokenAmount);\\n\\n wrappedBalance[tokenHolder] += wrappedTokenAmount;\\n wrappedToken.safeTransferFrom(\\n tokenHolder,\\n address(this),\\n wrappedTokenAmount\\n );\\n tToken.safeTransfer(tokenHolder, tTokenAmount);\\n }\\n\\n function _unwrap(address tokenHolder, uint256 tTokenAmount) internal {\\n (uint256 wrappedTokenAmount, uint256 remainder) = conversionFromT(\\n tTokenAmount\\n );\\n tTokenAmount -= remainder;\\n require(tTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n require(\\n wrappedBalance[tokenHolder] >= wrappedTokenAmount,\\n \\\"Can not unwrap more than previously wrapped\\\"\\n );\\n\\n emit Unwrapped(tokenHolder, tTokenAmount, wrappedTokenAmount);\\n wrappedBalance[tokenHolder] -= wrappedTokenAmount;\\n tToken.safeTransferFrom(tokenHolder, address(this), tTokenAmount);\\n wrappedToken.safeTransfer(tokenHolder, wrappedTokenAmount);\\n }\\n}\\n\",\"keccak256\":\"0xa4e7de5a9063db09b32ca97fa0fb5d8d1cc7b539387d1b44d74d15d3c2ed4134\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506104f7806100206000396000f3fe608060405234801561001057600080fd5b506004361061006d5760003560e01c8063178b6de6146100725780633223ff4b146100ae5780633d4fa8e5146100c15780634e745f1f146100ed5780637da5f6a6146101655780639168ae721461018557806399cc218c146101d2575b600080fd5b61009b6100803660046103b9565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61009b6100bc3660046103db565b6101e5565b6100eb6100cf36600461040e565b6001600160a01b03909116600090815260208190526040902055565b005b6101416100fb3660046103b9565b604080518082018252600080825260209182018190526001600160a01b039384168152808252829020825180840190935280548352600101549092169181019190915290565b60408051825181526020928301516001600160a01b031692810192909252016100a5565b61009b6101733660046103b9565b60016020526000908152604090205481565b6101b56101933660046103b9565b600060208190529081526040902080546001909101546001600160a01b031682565b604080519283526001600160a01b039091166020830152016100a5565b6100eb6101e0366004610438565b6102db565b6001600160a01b038083166000908152602081905260408120600181015491929091161580610223575060018101546001600160a01b038481169116145b61028d5760405162461bcd60e51b815260206004820152603060248201527f416e6f746865722070726f76696465722077617320616c72656164792073657460448201526f103337b9103a3434b99039ba30b5b2b960811b60648201526084015b60405180910390fd5b60018101546001600160a01b03166102bd576001810180546001600160a01b0319166001600160a01b0385161790555b5050506001600160a01b031660009081526020819052604090205490565b6000831161033d5760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f20736c617368206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610284565b6001600160a01b03841660009081526020819052604081208054859290610365908490610492565b90915550506001600160a01b038216600090815260016020526040812080548392906103929084906104a9565b909155505050505050565b80356001600160a01b03811681146103b457600080fd5b919050565b6000602082840312156103cb57600080fd5b6103d48261039d565b9392505050565b600080604083850312156103ee57600080fd5b6103f78361039d565b91506104056020840161039d565b90509250929050565b6000806040838503121561042157600080fd5b61042a8361039d565b946020939093013593505050565b6000806000806080858703121561044e57600080fd5b6104578561039d565b93506020850135925061046c6040860161039d565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b6000828210156104a4576104a461047c565b500390565b600082198211156104bc576104bc61047c565b50019056fea264697066735822122032cfbd37cdeb97fb894be38888d2bf07db9313b28b5c73385e9b2800a1d487ca64736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061006d5760003560e01c8063178b6de6146100725780633223ff4b146100ae5780633d4fa8e5146100c15780634e745f1f146100ed5780637da5f6a6146101655780639168ae721461018557806399cc218c146101d2575b600080fd5b61009b6100803660046103b9565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b61009b6100bc3660046103db565b6101e5565b6100eb6100cf36600461040e565b6001600160a01b03909116600090815260208190526040902055565b005b6101416100fb3660046103b9565b604080518082018252600080825260209182018190526001600160a01b039384168152808252829020825180840190935280548352600101549092169181019190915290565b60408051825181526020928301516001600160a01b031692810192909252016100a5565b61009b6101733660046103b9565b60016020526000908152604090205481565b6101b56101933660046103b9565b600060208190529081526040902080546001909101546001600160a01b031682565b604080519283526001600160a01b039091166020830152016100a5565b6100eb6101e0366004610438565b6102db565b6001600160a01b038083166000908152602081905260408120600181015491929091161580610223575060018101546001600160a01b038481169116145b61028d5760405162461bcd60e51b815260206004820152603060248201527f416e6f746865722070726f76696465722077617320616c72656164792073657460448201526f103337b9103a3434b99039ba30b5b2b960811b60648201526084015b60405180910390fd5b60018101546001600160a01b03166102bd576001810180546001600160a01b0319166001600160a01b0385161790555b5050506001600160a01b031660009081526020819052604090205490565b6000831161033d5760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f20736c617368206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610284565b6001600160a01b03841660009081526020819052604081208054859290610365908490610492565b90915550506001600160a01b038216600090815260016020526040812080548392906103929084906104a9565b909155505050505050565b80356001600160a01b03811681146103b457600080fd5b919050565b6000602082840312156103cb57600080fd5b6103d48261039d565b9392505050565b600080604083850312156103ee57600080fd5b6103f78361039d565b91506104056020840161039d565b90509250929050565b6000806040838503121561042157600080fd5b61042a8361039d565b946020939093013593505050565b6000806000806080858703121561044e57600080fd5b6104578561039d565b93506020850135925061046c6040860161039d565b9396929550929360600135925050565b634e487b7160e01b600052601160045260246000fd5b6000828210156104a4576104a461047c565b500390565b600082198211156104bc576104bc61047c565b50019056fea264697066735822122032cfbd37cdeb97fb894be38888d2bf07db9313b28b5c73385e9b2800a1d487ca64736f6c63430008090033", "devdoc": { "kind": "dev", "methods": { @@ -219,15 +219,15 @@ "storageLayout": { "storage": [ { - "astId": 17639, + "astId": 17613, "contract": "contracts/test/TokenStakingTestSet.sol:NuCypherTokenStakingMock", "label": "stakers", "offset": 0, "slot": "0", - "type": "t_mapping(t_address,t_struct(StakerStruct)17634_storage)" + "type": "t_mapping(t_address,t_struct(StakerStruct)17608_storage)" }, { - "astId": 17643, + "astId": 17617, "contract": "contracts/test/TokenStakingTestSet.sol:NuCypherTokenStakingMock", "label": "investigators", "offset": 0, @@ -241,12 +241,12 @@ "label": "address", "numberOfBytes": "20" }, - "t_mapping(t_address,t_struct(StakerStruct)17634_storage)": { + "t_mapping(t_address,t_struct(StakerStruct)17608_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct NuCypherTokenStakingMock.StakerStruct)", "numberOfBytes": "32", - "value": "t_struct(StakerStruct)17634_storage" + "value": "t_struct(StakerStruct)17608_storage" }, "t_mapping(t_address,t_uint256)": { "encoding": "mapping", @@ -255,12 +255,12 @@ "numberOfBytes": "32", "value": "t_uint256" }, - "t_struct(StakerStruct)17634_storage": { + "t_struct(StakerStruct)17608_storage": { "encoding": "inplace", "label": "struct NuCypherTokenStakingMock.StakerStruct", "members": [ { - "astId": 17631, + "astId": 17605, "contract": "contracts/test/TokenStakingTestSet.sol:NuCypherTokenStakingMock", "label": "value", "offset": 0, @@ -268,7 +268,7 @@ "type": "t_uint256" }, { - "astId": 17633, + "astId": 17607, "contract": "contracts/test/TokenStakingTestSet.sol:NuCypherTokenStakingMock", "label": "stakingProvider", "offset": 0, diff --git a/src/threshold-ts/tbtc/dapp-development-goerli-artifacts/Bridge.json b/src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/Bridge.json similarity index 95% rename from src/threshold-ts/tbtc/dapp-development-goerli-artifacts/Bridge.json rename to src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/Bridge.json index 078157389..9c899a883 100644 --- a/src/threshold-ts/tbtc/dapp-development-goerli-artifacts/Bridge.json +++ b/src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/Bridge.json @@ -1,5 +1,5 @@ { - "address": "0xB07051CE2A47b58C22bdfD1425BCEad27F6072Db", + "address": "0xF614eD3501A615a4d04f171F97f44F920DA35ff8", "abi": [ { "inputs": [], @@ -2671,81 +2671,81 @@ "type": "function" } ], - "transactionHash": "0x5b3f3ec979ce8956ab6e4e93f2523313a2729806e9d807e10683cd4136764969", + "transactionHash": "0x3123c3eda4f29fee34d966f2d6697a33f8c87981e3a876085472699c52970501", "receipt": { "to": null, - "from": "0xfd42E065d5b128a65d752F11A1dA089f74DBf49A", - "contractAddress": "0xB07051CE2A47b58C22bdfD1425BCEad27F6072Db", - "transactionIndex": 26, - "gasUsed": "972378", - "logsBloom": "0x00000000000008000000000000000000400004804000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000900000000040000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000010000020000000000000000000040000000000000400000000000000000000000000000000000000000800000000000000000000000000000000000000000000", - "blockHash": "0xa64ec512de416edb475155db56b429ab4b29c34290962d22ff7af41b5f233771", - "transactionHash": "0x5b3f3ec979ce8956ab6e4e93f2523313a2729806e9d807e10683cd4136764969", + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0xF614eD3501A615a4d04f171F97f44F920DA35ff8", + "transactionIndex": 2, + "gasUsed": "972354", + "logsBloom": "0x00000000000000000000000000000000400000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000002000000000000000800000000000000000000000000000000000000000000000040000000800000000000000000000000000000000020000000000000000000000000000000008080000000000000800000000000000000000000000000000400000000000000000000800000000000000000000020000000000000000000040000000000000400000000000000002000000000000000000000000800000000000000000000000000000000000000000000", + "blockHash": "0x54f050939b79297375e5fdbf7fe52a0dc980bf3b4e4325f3ac11f22ad6502813", + "transactionHash": "0x3123c3eda4f29fee34d966f2d6697a33f8c87981e3a876085472699c52970501", "logs": [ { - "transactionIndex": 26, - "blockNumber": 9460088, - "transactionHash": "0x5b3f3ec979ce8956ab6e4e93f2523313a2729806e9d807e10683cd4136764969", - "address": "0xB07051CE2A47b58C22bdfD1425BCEad27F6072Db", + "transactionIndex": 2, + "blockNumber": 4653113, + "transactionHash": "0x3123c3eda4f29fee34d966f2d6697a33f8c87981e3a876085472699c52970501", + "address": "0xF614eD3501A615a4d04f171F97f44F920DA35ff8", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x00000000000000000000000081e398346e85706261941d1f5fcd1169f33867eb" + "0x0000000000000000000000009a743075a833dc97cfaaa60585b0acf22dc94a26" ], "data": "0x", - "logIndex": 57, - "blockHash": "0xa64ec512de416edb475155db56b429ab4b29c34290962d22ff7af41b5f233771" + "logIndex": 28, + "blockHash": "0x54f050939b79297375e5fdbf7fe52a0dc980bf3b4e4325f3ac11f22ad6502813" }, { - "transactionIndex": 26, - "blockNumber": 9460088, - "transactionHash": "0x5b3f3ec979ce8956ab6e4e93f2523313a2729806e9d807e10683cd4136764969", - "address": "0xB07051CE2A47b58C22bdfD1425BCEad27F6072Db", + "transactionIndex": 2, + "blockNumber": 4653113, + "transactionHash": "0x3123c3eda4f29fee34d966f2d6697a33f8c87981e3a876085472699c52970501", + "address": "0xF614eD3501A615a4d04f171F97f44F920DA35ff8", "topics": [ "0x5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80" ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fd42e065d5b128a65d752f11a1da089f74dbf49a", - "logIndex": 58, - "blockHash": "0xa64ec512de416edb475155db56b429ab4b29c34290962d22ff7af41b5f233771" + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc", + "logIndex": 29, + "blockHash": "0x54f050939b79297375e5fdbf7fe52a0dc980bf3b4e4325f3ac11f22ad6502813" }, { - "transactionIndex": 26, - "blockNumber": 9460088, - "transactionHash": "0x5b3f3ec979ce8956ab6e4e93f2523313a2729806e9d807e10683cd4136764969", - "address": "0xB07051CE2A47b58C22bdfD1425BCEad27F6072Db", + "transactionIndex": 2, + "blockNumber": 4653113, + "transactionHash": "0x3123c3eda4f29fee34d966f2d6697a33f8c87981e3a876085472699c52970501", + "address": "0xF614eD3501A615a4d04f171F97f44F920DA35ff8", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", - "logIndex": 59, - "blockHash": "0xa64ec512de416edb475155db56b429ab4b29c34290962d22ff7af41b5f233771" + "logIndex": 30, + "blockHash": "0x54f050939b79297375e5fdbf7fe52a0dc980bf3b4e4325f3ac11f22ad6502813" }, { - "transactionIndex": 26, - "blockNumber": 9460088, - "transactionHash": "0x5b3f3ec979ce8956ab6e4e93f2523313a2729806e9d807e10683cd4136764969", - "address": "0xB07051CE2A47b58C22bdfD1425BCEad27F6072Db", + "transactionIndex": 2, + "blockNumber": 4653113, + "transactionHash": "0x3123c3eda4f29fee34d966f2d6697a33f8c87981e3a876085472699c52970501", + "address": "0xF614eD3501A615a4d04f171F97f44F920DA35ff8", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c01313673c43882ad39948b9b3de58de7dca3325", - "logIndex": 60, - "blockHash": "0xa64ec512de416edb475155db56b429ab4b29c34290962d22ff7af41b5f233771" + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039f60b25c4598caf7e922d6fc063e9002db45845", + "logIndex": 31, + "blockHash": "0x54f050939b79297375e5fdbf7fe52a0dc980bf3b4e4325f3ac11f22ad6502813" } ], - "blockNumber": 9460088, - "cumulativeGasUsed": "4696777", + "blockNumber": 4653113, + "cumulativeGasUsed": "2151793", "status": 1, "byzantium": true }, "numDeployments": 1, "libraries": { - "Deposit": "0xCEEdBc00386513A25B003f02f52eBF0028870f27", - "DepositSweep": "0x4e7eAd4AE091e7fcc32359E6a742766AF48FF68d", - "Redemption": "0x9B6487279BE41352a205278071a4723199B25B16", - "Wallets": "0x27Db1F214dd143189Cb01EDDE5Fbc3eBb6D583fD", - "Fraud": "0x655cA0652c4Bde6faF7798e55Fbc62F0FE4286ad", - "MovingFunds": "0xfd6f41b774aD1734C829c3396c68EeC724eaAFa5" + "Deposit": "0xFEd9395E6Ac28282af973649abAafb3148aB1AB1", + "DepositSweep": "0xFD361576d68645DAb34A7b9538d847069C75aa55", + "Redemption": "0x33C8eea7Bc7b160742A5b373B1e2e16d7481A51e", + "Wallets": "0x47177176bEEc4182f4B26FD91f02642f2370Ee41", + "Fraud": "0xc4f105B57fa904363C4ea9893915D78Cf2CD51b6", + "MovingFunds": "0x3B6824C8A29d6B46Dc4cfc4B82C9925b7516c232" }, - "implementation": "0x81E398346E85706261941D1F5fCd1169F33867eb", + "implementation": "0x9a743075a833dc97Cfaaa60585b0Acf22Dc94A26", "devdoc": "Contract deployed as upgradable proxy" } diff --git a/src/threshold-ts/tbtc/dapp-development-goerli-artifacts/TBTC.json b/src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/TBTC.json similarity index 98% rename from src/threshold-ts/tbtc/dapp-development-goerli-artifacts/TBTC.json rename to src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/TBTC.json index 6087133e6..e916d564f 100644 --- a/src/threshold-ts/tbtc/dapp-development-goerli-artifacts/TBTC.json +++ b/src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/TBTC.json @@ -1,5 +1,5 @@ { - "address": "0xd33b90D2c792F00d3746eF29cBE9aa0aAef915E1", + "address": "0xD3bA2034821785647b27E17355D66D244D170c8d", "abi": [ { "inputs": [], @@ -524,40 +524,40 @@ "type": "function" } ], - "transactionHash": "0x7d4494a8bf8a1bd83c3954254cfc79c000a297a63e53f864b4d5438846f7d21d", + "transactionHash": "0xba0957ef961d02fb809c7a487464fbc449566fa140daff89f3360bc296ecba1a", "receipt": { "to": null, - "from": "0xfd42E065d5b128a65d752F11A1dA089f74DBf49A", - "contractAddress": "0xd33b90D2c792F00d3746eF29cBE9aa0aAef915E1", - "transactionIndex": 104, + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0xD3bA2034821785647b27E17355D66D244D170c8d", + "transactionIndex": 20, "gasUsed": "1590745", - "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000010000004000000000000040000000000000000000000000000008000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000100008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x9dad9f7770b08e67656200a58be2601839e3e71ea41b2a984a38558ceab1cfac", - "transactionHash": "0x7d4494a8bf8a1bd83c3954254cfc79c000a297a63e53f864b4d5438846f7d21d", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000001000000000000000000000000800000000000020000000000000000000800000000000000000000000000000000400000000200000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000", + "blockHash": "0x798d2c65e6dffb5906e36837cbab8415f8265a6d0d122d6aa5134c0ef96f3d19", + "transactionHash": "0xba0957ef961d02fb809c7a487464fbc449566fa140daff89f3360bc296ecba1a", "logs": [ { - "transactionIndex": 104, - "blockNumber": 9460076, - "transactionHash": "0x7d4494a8bf8a1bd83c3954254cfc79c000a297a63e53f864b4d5438846f7d21d", - "address": "0xd33b90D2c792F00d3746eF29cBE9aa0aAef915E1", + "transactionIndex": 20, + "blockNumber": 4653103, + "transactionHash": "0xba0957ef961d02fb809c7a487464fbc449566fa140daff89f3360bc296ecba1a", + "address": "0xD3bA2034821785647b27E17355D66D244D170c8d", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000fd42e065d5b128a65d752f11a1da089f74dbf49a" + "0x00000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc" ], "data": "0x", - "logIndex": 402, - "blockHash": "0x9dad9f7770b08e67656200a58be2601839e3e71ea41b2a984a38558ceab1cfac" + "logIndex": 83, + "blockHash": "0x798d2c65e6dffb5906e36837cbab8415f8265a6d0d122d6aa5134c0ef96f3d19" } ], - "blockNumber": 9460076, - "cumulativeGasUsed": "29879511", + "blockNumber": 4653103, + "cumulativeGasUsed": "9148634", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "f943ac7ac8b61b06d4f2f338142093d7", + "solcInputHash": "38ae1accfb16a5f54171fc2120e052fc", "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"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\":\"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\":\"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\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"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\":[],\"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\"}],\"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`.\"},\"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.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"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.\"},\"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.\"},\"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`.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/token/TBTC.sol\":\"TBTC\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"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/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/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\",\"keccak256\":\"0xab28a56179c1db258c9bf5235b382698cb650debecb51b23d12be9e241374b68\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"contracts/token/TBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\\\";\\n\\ncontract TBTC is ERC20WithPermit, MisfundRecovery {\\n constructor() ERC20WithPermit(\\\"tBTC v2\\\", \\\"tBTC\\\") {}\\n}\\n\",\"keccak256\":\"0x4542aaa48f7682005b815253768b6433c811daff5d2727db256d5f1879f5ccbf\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", "bytecode": "0x60c06040523480156200001157600080fd5b50604051806040016040528060078152602001663a212a21903b1960c91b815250604051806040016040528060048152602001637442544360e01b8152506200006962000063620000a160201b60201c565b620000a5565b60056200007783826200024b565b5060066200008682826200024b565b504660805262000095620000f5565b60a05250620003959050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600560405162000129919062000317565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620001d157607f821691505b602082108103620001f257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200024657600081815260208120601f850160051c81016020861015620002215750805b601f850160051c820191505b8181101562000242578281556001016200022d565b5050505b505050565b81516001600160401b03811115620002675762000267620001a6565b6200027f81620002788454620001bc565b84620001f8565b602080601f831160018114620002b757600084156200029e5750858301515b600019600386901b1c1916600185901b17855562000242565b600085815260208120601f198616915b82811015620002e857888601518255948401946001909101908401620002c7565b5085821015620003075787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008083546200032781620001bc565b60018281168015620003425760018114620003585762000389565b60ff198416875282151583028701945062000389565b8760005260208060002060005b85811015620003805781548a82015290840190820162000365565b50505082870194505b50929695505050505050565b60805160a051611a61620003c96000396000818161034901526105a80152600081816102d901526105800152611a616000f3fe608060405234801561001057600080fd5b50600436106101985760003560e01c8063715018a6116100e3578063b4f94b2e1161008c578063dd62ed3e11610066578063dd62ed3e14610391578063f2fde38b146103bc578063fc4e51f6146103cf57600080fd5b8063b4f94b2e14610344578063cae9ca511461036b578063d505accf1461037e57600080fd5b80638da5cb5b116100bd5780638da5cb5b1461030e57806395d89b4114610329578063a9059cbb1461033157600080fd5b8063715018a6146102cc578063771da5c5146102d457806379cc6790146102fb57600080fd5b8063313ce5671161014557806342966c681161011f57806342966c681461027957806370a082311461028c57806370ae92d2146102ac57600080fd5b8063313ce567146102445780633644e5151461025e57806340c10f191461026657600080fd5b806318160ddd1161017657806318160ddd146101f357806323b872dd1461020a57806330adf81f1461021d57600080fd5b806306fdde031461019d578063095ea7b3146101bb5780631171bda9146101de575b600080fd5b6101a56103e2565b6040516101b29190611532565b60405180910390f35b6101ce6101c936600461155a565b610470565b60405190151581526020016101b2565b6101f16101ec366004611586565b610487565b005b6101fc60045481565b6040519081526020016101b2565b6101ce610218366004611586565b6104a8565b6101fc7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b61024c601281565b60405160ff90911681526020016101b2565b6101fc61057c565b6101f161027436600461155a565b6105d7565b6101f16102873660046115c7565b6106be565b6101fc61029a3660046115e0565b60016020526000908152604090205481565b6101fc6102ba3660046115e0565b60036020526000908152604090205481565b6101f16106cb565b6101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6101f161030936600461155a565b6106df565b6000546040516001600160a01b0390911681526020016101b2565b6101a5610775565b6101ce61033f36600461155a565b610782565b6101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6101ce610379366004611613565b61078f565b6101f161038c3660046116e0565b610830565b6101fc61039f366004611757565b600260209081526000928352604080842090915290825290205481565b6101f16103ca3660046115e0565b610b40565b6101f16103dd366004611790565b610bcd565b600580546103ef9061182f565b80601f016020809104026020016040519081016040528092919081815260200182805461041b9061182f565b80156104685780601f1061043d57610100808354040283529160200191610468565b820191906000526020600020905b81548152906001019060200180831161044b57829003601f168201915b505050505081565b600061047d338484610c50565b5060015b92915050565b61048f610d5e565b6104a36001600160a01b0384168383610db8565b505050565b6001600160a01b0383166000908152600260209081526040808320338452909152812054600019811461056457828110156105505760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360448201527f650000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610564853361055f868561187f565b610c50565b61056f858585610e38565b60019150505b9392505050565b60007f000000000000000000000000000000000000000000000000000000000000000046036105ca57507f000000000000000000000000000000000000000000000000000000000000000090565b6105d261103f565b905090565b6105df610d5e565b6001600160a01b0382166106355760405162461bcd60e51b815260206004820152601860248201527f4d696e7420746f20746865207a65726f206164647265737300000000000000006044820152606401610547565b80600460008282546106479190611892565b90915550506001600160a01b03821660009081526001602052604081208054839290610674908490611892565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6106c8338261110a565b50565b6106d3610d5e565b6106dd60006111ee565b565b6001600160a01b0382166000908152600260209081526040808320338452909152902054600019811461076b578181101561075c5760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e63650000006044820152606401610547565b61076b833361055f858561187f565b6104a3838361110a565b600680546103ef9061182f565b600061047d338484610e38565b600061079b8484610470565b15610826576040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081526001600160a01b03851690638f4ffcb1906107eb9033908790309088906004016118a5565b600060405180830381600087803b15801561080557600080fd5b505af1158015610819573d6000803e3d6000fd5b5050505060019050610575565b5060009392505050565b428410156108805760405162461bcd60e51b815260206004820152601260248201527f5065726d697373696f6e206578706972656400000000000000000000000000006044820152606401610547565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08111156108f05760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202773272076616c756500000000006044820152606401610547565b8260ff16601b148061090557508260ff16601c145b6109515760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202776272076616c756500000000006044820152606401610547565b600061095b61057c565b6001600160a01b038916600090815260036020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c929091906109a9836118e1565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001610a3d9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610aa8573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610ade5750886001600160a01b0316816001600160a01b0316145b610b2a5760405162461bcd60e51b815260206004820152601160248201527f496e76616c6964207369676e61747572650000000000000000000000000000006044820152606401610547565b610b35898989610c50565b505050505050505050565b610b48610d5e565b6001600160a01b038116610bc45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610547565b6106c8816111ee565b610bd5610d5e565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde90610c2290309088908890889088906004016118fa565b600060405180830381600087803b158015610c3c57600080fd5b505af1158015610b35573d6000803e3d6000fd5b6001600160a01b038316610ca65760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f20616464726573730000006044820152606401610547565b6001600160a01b038216610cfc5760405162461bcd60e51b815260206004820152601b60248201527f417070726f766520746f20746865207a65726f206164647265737300000000006044820152606401610547565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6000546001600160a01b031633146106dd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610547565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526104a3908490611256565b6001600160a01b038316610e8e5760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f206164647265737300006044820152606401610547565b6001600160a01b038216610ee45760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657220746f20746865207a65726f2061646472657373000000006044820152606401610547565b306001600160a01b03831603610f3c5760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e20616464726573730000006044820152606401610547565b6001600160a01b03831660009081526001602052604090205481811015610fa55760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e6365006044820152606401610547565b610faf828261187f565b6001600160a01b038086166000908152600160205260408082209390935590851681529081208054849290610fe5908490611892565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161103191815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051611071919061194e565b604080519182900382208282018252600183527f31000000000000000000000000000000000000000000000000000000000000006020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b038216600090815260016020526040902054818110156111735760405162461bcd60e51b815260206004820152601b60248201527f4275726e20616d6f756e7420657863656564732062616c616e636500000000006044820152606401610547565b61117d828261187f565b6001600160a01b038416600090815260016020526040812091909155600480548492906111ab90849061187f565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610d51565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006112ab826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661133b9092919063ffffffff16565b8051909150156104a357808060200190518101906112c991906119ed565b6104a35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610547565b606061134a8484600085611352565b949350505050565b6060824710156113ca5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610547565b600080866001600160a01b031685876040516113e69190611a0f565b60006040518083038185875af1925050503d8060008114611423576040519150601f19603f3d011682016040523d82523d6000602084013e611428565b606091505b509150915061143987838387611444565b979650505050505050565b606083156114b35782516000036114ac576001600160a01b0385163b6114ac5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610547565b508161134a565b61134a83838151156114c85781518083602001fd5b8060405162461bcd60e51b81526004016105479190611532565b60005b838110156114fd5781810151838201526020016114e5565b50506000910152565b6000815180845261151e8160208601602086016114e2565b601f01601f19169290920160200192915050565b6020815260006105756020830184611506565b6001600160a01b03811681146106c857600080fd5b6000806040838503121561156d57600080fd5b823561157881611545565b946020939093013593505050565b60008060006060848603121561159b57600080fd5b83356115a681611545565b925060208401356115b681611545565b929592945050506040919091013590565b6000602082840312156115d957600080fd5b5035919050565b6000602082840312156115f257600080fd5b813561057581611545565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561162857600080fd5b833561163381611545565b925060208401359150604084013567ffffffffffffffff8082111561165757600080fd5b818601915086601f83011261166b57600080fd5b81358181111561167d5761167d6115fd565b604051601f8201601f19908116603f011681019083821181831017156116a5576116a56115fd565b816040528281528960208487010111156116be57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a0312156116fb57600080fd5b873561170681611545565b9650602088013561171681611545565b95506040880135945060608801359350608088013560ff8116811461173a57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561176a57600080fd5b823561177581611545565b9150602083013561178581611545565b809150509250929050565b6000806000806000608086880312156117a857600080fd5b85356117b381611545565b945060208601356117c381611545565b935060408601359250606086013567ffffffffffffffff808211156117e757600080fd5b818801915088601f8301126117fb57600080fd5b81358181111561180a57600080fd5b89602082850101111561181c57600080fd5b9699959850939650602001949392505050565b600181811c9082168061184357607f821691505b60208210810361186357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561048157610481611869565b8082018082111561048157610481611869565b60006001600160a01b038087168352856020840152808516604084015250608060608301526118d76080830184611506565b9695505050505050565b6000600182016118f3576118f3611869565b5060010190565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600080835481600182811c91508083168061196a57607f831692505b6020808410820361198957634e487b7160e01b86526022600452602486fd5b81801561199d57600181146119b2576119df565b60ff19861689528415158502890196506119df565b60008a81526020902060005b868110156119d75781548b8201529085019083016119be565b505084890196505b509498975050505050505050565b6000602082840312156119ff57600080fd5b8151801515811461057557600080fd5b60008251611a218184602087016114e2565b919091019291505056fea2646970667358221220ac40ec86f0507767ccbaf14ca6220c6808fea4caff0cd29f52eba919adea057664736f6c63430008110033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101985760003560e01c8063715018a6116100e3578063b4f94b2e1161008c578063dd62ed3e11610066578063dd62ed3e14610391578063f2fde38b146103bc578063fc4e51f6146103cf57600080fd5b8063b4f94b2e14610344578063cae9ca511461036b578063d505accf1461037e57600080fd5b80638da5cb5b116100bd5780638da5cb5b1461030e57806395d89b4114610329578063a9059cbb1461033157600080fd5b8063715018a6146102cc578063771da5c5146102d457806379cc6790146102fb57600080fd5b8063313ce5671161014557806342966c681161011f57806342966c681461027957806370a082311461028c57806370ae92d2146102ac57600080fd5b8063313ce567146102445780633644e5151461025e57806340c10f191461026657600080fd5b806318160ddd1161017657806318160ddd146101f357806323b872dd1461020a57806330adf81f1461021d57600080fd5b806306fdde031461019d578063095ea7b3146101bb5780631171bda9146101de575b600080fd5b6101a56103e2565b6040516101b29190611532565b60405180910390f35b6101ce6101c936600461155a565b610470565b60405190151581526020016101b2565b6101f16101ec366004611586565b610487565b005b6101fc60045481565b6040519081526020016101b2565b6101ce610218366004611586565b6104a8565b6101fc7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b61024c601281565b60405160ff90911681526020016101b2565b6101fc61057c565b6101f161027436600461155a565b6105d7565b6101f16102873660046115c7565b6106be565b6101fc61029a3660046115e0565b60016020526000908152604090205481565b6101fc6102ba3660046115e0565b60036020526000908152604090205481565b6101f16106cb565b6101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6101f161030936600461155a565b6106df565b6000546040516001600160a01b0390911681526020016101b2565b6101a5610775565b6101ce61033f36600461155a565b610782565b6101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6101ce610379366004611613565b61078f565b6101f161038c3660046116e0565b610830565b6101fc61039f366004611757565b600260209081526000928352604080842090915290825290205481565b6101f16103ca3660046115e0565b610b40565b6101f16103dd366004611790565b610bcd565b600580546103ef9061182f565b80601f016020809104026020016040519081016040528092919081815260200182805461041b9061182f565b80156104685780601f1061043d57610100808354040283529160200191610468565b820191906000526020600020905b81548152906001019060200180831161044b57829003601f168201915b505050505081565b600061047d338484610c50565b5060015b92915050565b61048f610d5e565b6104a36001600160a01b0384168383610db8565b505050565b6001600160a01b0383166000908152600260209081526040808320338452909152812054600019811461056457828110156105505760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360448201527f650000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610564853361055f868561187f565b610c50565b61056f858585610e38565b60019150505b9392505050565b60007f000000000000000000000000000000000000000000000000000000000000000046036105ca57507f000000000000000000000000000000000000000000000000000000000000000090565b6105d261103f565b905090565b6105df610d5e565b6001600160a01b0382166106355760405162461bcd60e51b815260206004820152601860248201527f4d696e7420746f20746865207a65726f206164647265737300000000000000006044820152606401610547565b80600460008282546106479190611892565b90915550506001600160a01b03821660009081526001602052604081208054839290610674908490611892565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6106c8338261110a565b50565b6106d3610d5e565b6106dd60006111ee565b565b6001600160a01b0382166000908152600260209081526040808320338452909152902054600019811461076b578181101561075c5760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e63650000006044820152606401610547565b61076b833361055f858561187f565b6104a3838361110a565b600680546103ef9061182f565b600061047d338484610e38565b600061079b8484610470565b15610826576040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081526001600160a01b03851690638f4ffcb1906107eb9033908790309088906004016118a5565b600060405180830381600087803b15801561080557600080fd5b505af1158015610819573d6000803e3d6000fd5b5050505060019050610575565b5060009392505050565b428410156108805760405162461bcd60e51b815260206004820152601260248201527f5065726d697373696f6e206578706972656400000000000000000000000000006044820152606401610547565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08111156108f05760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202773272076616c756500000000006044820152606401610547565b8260ff16601b148061090557508260ff16601c145b6109515760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202776272076616c756500000000006044820152606401610547565b600061095b61057c565b6001600160a01b038916600090815260036020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c929091906109a9836118e1565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001610a3d9291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610aa8573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610ade5750886001600160a01b0316816001600160a01b0316145b610b2a5760405162461bcd60e51b815260206004820152601160248201527f496e76616c6964207369676e61747572650000000000000000000000000000006044820152606401610547565b610b35898989610c50565b505050505050505050565b610b48610d5e565b6001600160a01b038116610bc45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610547565b6106c8816111ee565b610bd5610d5e565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde90610c2290309088908890889088906004016118fa565b600060405180830381600087803b158015610c3c57600080fd5b505af1158015610b35573d6000803e3d6000fd5b6001600160a01b038316610ca65760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f20616464726573730000006044820152606401610547565b6001600160a01b038216610cfc5760405162461bcd60e51b815260206004820152601b60248201527f417070726f766520746f20746865207a65726f206164647265737300000000006044820152606401610547565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6000546001600160a01b031633146106dd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610547565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526104a3908490611256565b6001600160a01b038316610e8e5760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f206164647265737300006044820152606401610547565b6001600160a01b038216610ee45760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657220746f20746865207a65726f2061646472657373000000006044820152606401610547565b306001600160a01b03831603610f3c5760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e20616464726573730000006044820152606401610547565b6001600160a01b03831660009081526001602052604090205481811015610fa55760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e6365006044820152606401610547565b610faf828261187f565b6001600160a01b038086166000908152600160205260408082209390935590851681529081208054849290610fe5908490611892565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161103191815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051611071919061194e565b604080519182900382208282018252600183527f31000000000000000000000000000000000000000000000000000000000000006020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b038216600090815260016020526040902054818110156111735760405162461bcd60e51b815260206004820152601b60248201527f4275726e20616d6f756e7420657863656564732062616c616e636500000000006044820152606401610547565b61117d828261187f565b6001600160a01b038416600090815260016020526040812091909155600480548492906111ab90849061187f565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610d51565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006112ab826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661133b9092919063ffffffff16565b8051909150156104a357808060200190518101906112c991906119ed565b6104a35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610547565b606061134a8484600085611352565b949350505050565b6060824710156113ca5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610547565b600080866001600160a01b031685876040516113e69190611a0f565b60006040518083038185875af1925050503d8060008114611423576040519150601f19603f3d011682016040523d82523d6000602084013e611428565b606091505b509150915061143987838387611444565b979650505050505050565b606083156114b35782516000036114ac576001600160a01b0385163b6114ac5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610547565b508161134a565b61134a83838151156114c85781518083602001fd5b8060405162461bcd60e51b81526004016105479190611532565b60005b838110156114fd5781810151838201526020016114e5565b50506000910152565b6000815180845261151e8160208601602086016114e2565b601f01601f19169290920160200192915050565b6020815260006105756020830184611506565b6001600160a01b03811681146106c857600080fd5b6000806040838503121561156d57600080fd5b823561157881611545565b946020939093013593505050565b60008060006060848603121561159b57600080fd5b83356115a681611545565b925060208401356115b681611545565b929592945050506040919091013590565b6000602082840312156115d957600080fd5b5035919050565b6000602082840312156115f257600080fd5b813561057581611545565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561162857600080fd5b833561163381611545565b925060208401359150604084013567ffffffffffffffff8082111561165757600080fd5b818601915086601f83011261166b57600080fd5b81358181111561167d5761167d6115fd565b604051601f8201601f19908116603f011681019083821181831017156116a5576116a56115fd565b816040528281528960208487010111156116be57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a0312156116fb57600080fd5b873561170681611545565b9650602088013561171681611545565b95506040880135945060608801359350608088013560ff8116811461173a57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561176a57600080fd5b823561177581611545565b9150602083013561178581611545565b809150509250929050565b6000806000806000608086880312156117a857600080fd5b85356117b381611545565b945060208601356117c381611545565b935060408601359250606086013567ffffffffffffffff808211156117e757600080fd5b818801915088601f8301126117fb57600080fd5b81358181111561180a57600080fd5b89602082850101111561181c57600080fd5b9699959850939650602001949392505050565b600181811c9082168061184357607f821691505b60208210810361186357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561048157610481611869565b8082018082111561048157610481611869565b60006001600160a01b038087168352856020840152808516604084015250608060608301526118d76080830184611506565b9695505050505050565b6000600182016118f3576118f3611869565b5060010190565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600080835481600182811c91508083168061196a57607f831692505b6020808410820361198957634e487b7160e01b86526022600452602486fd5b81801561199d57600181146119b2576119df565b60ff19861689528415158502890196506119df565b60008a81526020902060005b868110156119d75781548b8201529085019083016119be565b505084890196505b509498975050505050505050565b6000602082840312156119ff57600080fd5b8151801515811461057557600080fd5b60008251611a218184602087016114e2565b919091019291505056fea2646970667358221220ac40ec86f0507767ccbaf14ca6220c6808fea4caff0cd29f52eba919adea057664736f6c63430008110033", @@ -672,7 +672,7 @@ "storageLayout": { "storage": [ { - "astId": 17301, + "astId": 17299, "contract": "contracts/token/TBTC.sol:TBTC", "label": "_owner", "offset": 0, @@ -680,7 +680,7 @@ "type": "t_address" }, { - "astId": 21562, + "astId": 21560, "contract": "contracts/token/TBTC.sol:TBTC", "label": "balanceOf", "offset": 0, @@ -688,7 +688,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 21570, + "astId": 21568, "contract": "contracts/token/TBTC.sol:TBTC", "label": "allowance", "offset": 0, @@ -696,7 +696,7 @@ "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" }, { - "astId": 21576, + "astId": 21574, "contract": "contracts/token/TBTC.sol:TBTC", "label": "nonce", "offset": 0, @@ -704,7 +704,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 21591, + "astId": 21589, "contract": "contracts/token/TBTC.sol:TBTC", "label": "totalSupply", "offset": 0, @@ -712,7 +712,7 @@ "type": "t_uint256" }, { - "astId": 21595, + "astId": 21593, "contract": "contracts/token/TBTC.sol:TBTC", "label": "name", "offset": 0, @@ -720,7 +720,7 @@ "type": "t_string_storage" }, { - "astId": 21599, + "astId": 21597, "contract": "contracts/token/TBTC.sol:TBTC", "label": "symbol", "offset": 0, diff --git a/src/threshold-ts/tbtc/dapp-development-goerli-artifacts/TBTCVault.json b/src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/TBTCVault.json similarity index 99% rename from src/threshold-ts/tbtc/dapp-development-goerli-artifacts/TBTCVault.json rename to src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/TBTCVault.json index 65f5e9400..730fa4b0e 100644 --- a/src/threshold-ts/tbtc/dapp-development-goerli-artifacts/TBTCVault.json +++ b/src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/TBTCVault.json @@ -1,5 +1,5 @@ { - "address": "0x0099960098f5A5343Bef3185e7E365d3a558D36a", + "address": "0xABB6D7E6FB4970F32222AD11c5157a1ffBA2E1fC", "abi": [ { "inputs": [ @@ -1116,44 +1116,44 @@ "type": "function" } ], - "transactionHash": "0x9c84f708c82e15acf326daafe996c99bcdbec1b3f08252f1e64cdaa07216725e", + "transactionHash": "0x36a6cc1fa73167fe063d1f03e1f40061f4183db88897c0898a8efb9026e8cd7a", "receipt": { "to": null, - "from": "0xfd42E065d5b128a65d752F11A1dA089f74DBf49A", - "contractAddress": "0x0099960098f5A5343Bef3185e7E365d3a558D36a", - "transactionIndex": 32, - "gasUsed": "3121953", - "logsBloom": "0x00000000000000004000000000000000000000000000000000800000000000000000000000000010000004000000000008000000000000000000000000000001008000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x488e3d39dd4c51c5d3ae7edd03edb234534b55d5720dad1a5fd752b36ad04c2f", - "transactionHash": "0x9c84f708c82e15acf326daafe996c99bcdbec1b3f08252f1e64cdaa07216725e", + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0xABB6D7E6FB4970F32222AD11c5157a1ffBA2E1fC", + "transactionIndex": 12, + "gasUsed": "3121941", + "logsBloom": "0x00000000001000000800000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000200000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xbb64b8ac750dc064fff0cd52198f5175e65e0d98e8f0b6d57de488e2629bf8f9", + "transactionHash": "0x36a6cc1fa73167fe063d1f03e1f40061f4183db88897c0898a8efb9026e8cd7a", "logs": [ { - "transactionIndex": 32, - "blockNumber": 9460089, - "transactionHash": "0x9c84f708c82e15acf326daafe996c99bcdbec1b3f08252f1e64cdaa07216725e", - "address": "0x0099960098f5A5343Bef3185e7E365d3a558D36a", + "transactionIndex": 12, + "blockNumber": 4653116, + "transactionHash": "0x36a6cc1fa73167fe063d1f03e1f40061f4183db88897c0898a8efb9026e8cd7a", + "address": "0xABB6D7E6FB4970F32222AD11c5157a1ffBA2E1fC", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000fd42e065d5b128a65d752f11a1da089f74dbf49a" + "0x00000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc" ], "data": "0x", - "logIndex": 98, - "blockHash": "0x488e3d39dd4c51c5d3ae7edd03edb234534b55d5720dad1a5fd752b36ad04c2f" + "logIndex": 52, + "blockHash": "0xbb64b8ac750dc064fff0cd52198f5175e65e0d98e8f0b6d57de488e2629bf8f9" } ], - "blockNumber": 9460089, - "cumulativeGasUsed": "7252018", + "blockNumber": 4653116, + "cumulativeGasUsed": "8938986", "status": 1, "byzantium": true }, "args": [ - "0xf1FEc015acF82Ce1f94BECDa65AA61a042C0D359", - "0xd33b90D2c792F00d3746eF29cBE9aa0aAef915E1", - "0xB07051CE2A47b58C22bdfD1425BCEad27F6072Db" + "0x3F14399DC2379eA0efBaDdEb69A713D8c97E8900", + "0xD3bA2034821785647b27E17355D66D244D170c8d", + "0xF614eD3501A615a4d04f171F97f44F920DA35ff8" ], "numDeployments": 1, - "solcInputHash": "f943ac7ac8b61b06d4f2f338142093d7", + "solcInputHash": "38ae1accfb16a5f54171fc2120e052fc", "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract Bank\",\"name\":\"_bank\",\"type\":\"address\"},{\"internalType\":\"contract TBTC\",\"name\":\"_tbtcToken\",\"type\":\"address\"},{\"internalType\":\"contract Bridge\",\"name\":\"_bridge\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"GuardianAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"GuardianRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Minted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"MinterAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"MinterRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingCancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticMintingDebt\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingDebtRepaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingDelayUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingDelayUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingFeeUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticMintingDebt\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"OptimisticMintingPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"OptimisticMintingUnpaused\",\"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\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unminted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVault\",\"type\":\"address\"}],\"name\":\"UpgradeFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVault\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"UpgradeInitiated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GOVERNANCE_DELAY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SATOSHI_MULTIPLIER\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"addGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"addMinter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"amountToSatoshis\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"convertibleAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"remainder\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"satoshis\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bank\",\"outputs\":[{\"internalType\":\"contract Bank\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"beginOptimisticMintingDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"beginOptimisticMintingFeeUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contract Bridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"calculateDepositKey\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"cancelOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"finalizeOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeOptimisticMintingDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeOptimisticMintingFeeUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinters\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newVault\",\"type\":\"address\"}],\"name\":\"initiateUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isGuardian\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isMinter\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isOptimisticMintingPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"minters\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newOptimisticMintingDelay\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newOptimisticMintingFeeDivisor\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newVault\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"optimisticMintingDebt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingDelay\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingDelayUpdateInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingFeeDivisor\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingFeeUpdateInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"optimisticMintingRequests\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"requestedAt\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"finalizedAt\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseOptimisticMinting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"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\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"satoshis\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveBalanceApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"depositors\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"depositedSatoshiAmounts\",\"type\":\"uint256[]\"}],\"name\":\"receiveBalanceIncrease\",\"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 IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverERC20FromToken\",\"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\":[{\"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\":\"recoverERC721FromToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"removeGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"removeMinter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"requestOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcToken\",\"outputs\":[{\"internalType\":\"contract TBTC\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unmint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"redemptionData\",\"type\":\"bytes\"}],\"name\":\"unmintAndRedeem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpauseOptimisticMinting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"upgradeInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"TBTC Vault is the owner of TBTC token contract and is the only contract minting the token.\",\"kind\":\"dev\",\"methods\":{\"amountToSatoshis(uint256)\":{\"returns\":{\"convertibleAmount\":\"Amount of TBTC to be minted/unminted.\",\"remainder\":\"Not convertible remainder if amount is not divisible by SATOSHI_MULTIPLIER.\",\"satoshis\":\"Amount in satoshis - the Bank balance to be transferred for the given mint/unmint\"}},\"beginOptimisticMintingFeeUpdate(uint32)\":{\"details\":\"See the documentation for optimisticMintingFeeDivisor.\"},\"cancelOptimisticMint(bytes32,uint32)\":{\"details\":\"Guardians must validate the following conditions for every deposit for which the optimistic minting was requested: - The deposit happened on Bitcoin side and it has enough confirmations. - The optimistic minting has been requested early enough so that the wallet has enough time to sweep the deposit. - The wallet is an active one and it does perform sweeps or it will perform sweeps once the sweeps are activated.\"},\"initiateUpgrade(address)\":{\"params\":{\"_newVault\":\"The new vault address.\"}},\"mint(uint256)\":{\"details\":\"TBTC Vault must have an allowance for caller's balance in the Bank for at least `amount / SATOSHI_MULTIPLIER`.\",\"params\":{\"amount\":\"Amount of TBTC to mint.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"details\":\"This function is doing the same as `unmint` or `unmintAndRedeem` (depending on `extraData` parameter) but it allows to execute unminting without a separate approval transaction. The function can be called only via `approveAndCall` of TBTC token.\",\"params\":{\"amount\":\"Amount of TBTC to unmint.\",\"extraData\":\"Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function. If empty, `receiveApproval` is not requesting a redemption of Bank balance but is instead performing just TBTC unminting to a Bank balance.\",\"from\":\"TBTC token holder executing unminting.\",\"token\":\"TBTC token address.\"}},\"receiveBalanceApproval(address,uint256,bytes)\":{\"details\":\"Can only be called by the Bank via `approveBalanceAndCall`.\",\"params\":{\"owner\":\"The owner who approved their Bank balance.\",\"satoshis\":\"Amount of satoshis used to mint TBTC.\"}},\"receiveBalanceIncrease(address[],uint256[])\":{\"details\":\"Fails if `depositors` array is empty. Expects the length of `depositors` and `depositedSatoshiAmounts` is the same.\"},\"recoverERC20(address,address,uint256)\":{\"params\":{\"amount\":\"Recovered amount.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC20 token contract.\"}},\"recoverERC20FromToken(address,address,uint256)\":{\"params\":{\"amount\":\"Recovered amount.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC20 token contract.\"}},\"recoverERC721(address,address,uint256,bytes)\":{\"params\":{\"data\":\"Additional data.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC721 token contract.\",\"tokenId\":\"Identifier of the recovered token.\"}},\"recoverERC721FromToken(address,address,uint256,bytes)\":{\"params\":{\"data\":\"Additional data.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC721 token contract.\",\"tokenId\":\"Identifier of the recovered token.\"}},\"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.\"},\"requestOptimisticMint(bytes32,uint32)\":{\"details\":\"The deposit done on the Bitcoin side must be revealed early enough to the Bridge on Ethereum to pass the Bridge's validation. The validation passes successfully only if the deposit reveal is done respectively earlier than the moment when the deposit refund locktime is reached, i.e. the deposit becomes refundable. It may happen that the wallet does not sweep a revealed deposit and one of the Minters requests an optimistic mint for that deposit just before the locktime is reached. Guardians must cancel optimistic minting for this deposit because the wallet will not be able to sweep it. The on-chain optimistic minting code does not perform any validation for gas efficiency: it would have to perform the same validation as `validateDepositRefundLocktime` and expect the entire `DepositRevealInfo` to be passed to assemble the expected script hash on-chain. Guardians must validate if the deposit happened on Bitcoin, that the script hash has the expected format, and that the wallet is an active one so they can also validate the time left for the refund.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unmint(uint256)\":{\"details\":\"Caller must have at least `amount` of TBTC approved to TBTC Vault.\",\"params\":{\"amount\":\"Amount of TBTC to unmint.\"}},\"unmintAndRedeem(uint256,bytes)\":{\"details\":\"Caller must have at least `amount` of TBTC approved to TBTC Vault.\",\"params\":{\"amount\":\"Amount of TBTC to unmint and request to redeem in Bridge.\",\"redemptionData\":\"Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function.\"}}},\"title\":\"TBTC application vault\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"GOVERNANCE_DELAY()\":{\"notice\":\"The time delay that needs to pass between initializing and finalizing the upgrade of governable parameters.\"},\"SATOSHI_MULTIPLIER()\":{\"notice\":\"Multiplier to convert satoshi to TBTC token units.\"},\"addGuardian(address)\":{\"notice\":\"Adds the address to the Guardian set.\"},\"addMinter(address)\":{\"notice\":\"Adds the address to the Minter list.\"},\"amountToSatoshis(uint256)\":{\"notice\":\"Returns the amount of TBTC to be minted/unminted, the remainder, and the Bank balance to be transferred for the given mint/unmint. Note that if the `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account when minting or unminting.\"},\"beginOptimisticMintingDelayUpdate(uint32)\":{\"notice\":\"Begins the process of updating optimistic minting delay.\"},\"beginOptimisticMintingFeeUpdate(uint32)\":{\"notice\":\"Begins the process of updating optimistic minting fee. The fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2% of each deposit, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`.\"},\"calculateDepositKey(bytes32,uint32)\":{\"notice\":\"Calculates deposit key the same way as the Bridge contract. The deposit key is computed as `keccak256(fundingTxHash | fundingOutputIndex)`.\"},\"cancelOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Guardian to cancel optimistic minting request. The following conditions must be met: - The optimistic minting request for the given deposit exists. - The optimistic minting request for the given deposit has not been finalized yet. Optimistic minting request is removed. It is possible to request optimistic minting again for the same deposit later.\"},\"finalizeOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Minter to finalize previously requested optimistic minting. The following conditions must be met: - The optimistic minting has been requested for the given deposit. - The deposit has not been swept yet. - At least `optimisticMintingDelay` passed since the optimistic minting was requested for the given deposit. - The optimistic minting has not been finalized earlier for the given deposit. - The optimistic minting request for the given deposit has not been canceled by a Guardian. - The optimistic minting is not paused. This function mints TBTC and increases `optimisticMintingDebt` for the given depositor. The optimistic minting request is marked as finalized.\"},\"finalizeOptimisticMintingDelayUpdate()\":{\"notice\":\"Finalizes the update process of the optimistic minting delay.\"},\"finalizeOptimisticMintingFeeUpdate()\":{\"notice\":\"Finalizes the update process of the optimistic minting fee.\"},\"finalizeUpgrade()\":{\"notice\":\"Allows the governance to finalize vault upgrade process. The upgrade process needs to be first initiated with a call to `initiateUpgrade` and the `GOVERNANCE_DELAY` needs to pass. Once the upgrade is finalized, the new vault becomes the owner of the TBTC token and receives the whole Bank balance of this vault.\"},\"getMinters()\":{\"notice\":\"Allows to fetch a list of all Minters.\"},\"initiateUpgrade(address)\":{\"notice\":\"Initiates vault upgrade process. The upgrade process needs to be finalized with a call to `finalizeUpgrade` function after the `UPGRADE_GOVERNANCE_DELAY` passes. Only the governance can initiate the upgrade.\"},\"isGuardian(address)\":{\"notice\":\"Indicates if the given address is a Guardian. Only Guardians can cancel requested optimistic minting.\"},\"isMinter(address)\":{\"notice\":\"Indicates if the given address is a Minter. Only Minters can request optimistic minting.\"},\"isOptimisticMintingPaused()\":{\"notice\":\"Indicates if the optimistic minting has been paused. Only the Governance can pause optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits.\"},\"mint(uint256)\":{\"notice\":\"Mints the given `amount` of TBTC to the caller previously transferring `amount / SATOSHI_MULTIPLIER` of the Bank balance from caller to TBTC Vault. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's Bank balance.\"},\"minters(uint256)\":{\"notice\":\"List of all Minters.\"},\"newOptimisticMintingDelay()\":{\"notice\":\"New optimistic minting delay value. Set only when the parameter update process is pending. Once the update gets finalized, this\"},\"newOptimisticMintingFeeDivisor()\":{\"notice\":\"New optimistic minting fee divisor value. Set only when the parameter update process is pending. Once the update gets\"},\"newVault()\":{\"notice\":\"The address of a new TBTC vault. Set only when the upgrade process is pending. Once the upgrade gets finalized, the new TBTC vault will become an owner of TBTC token.\"},\"optimisticMintingDebt(address)\":{\"notice\":\"Optimistic minting debt value per depositor's address. The debt represents the total value of all depositor's deposits revealed to the Bridge that has not been yet swept and led to the optimistic minting of TBTC. When `TBTCVault` sweeps a deposit, the debt is fully or partially paid off, no matter if that particular swept deposit was used for the optimistic minting or not. The values are in 1e18 Ethereum precision.\"},\"optimisticMintingDelay()\":{\"notice\":\"The time that needs to pass between the moment the optimistic minting is requested and the moment optimistic minting is finalized with minting TBTC.\"},\"optimisticMintingDelayUpdateInitiatedTimestamp()\":{\"notice\":\"The timestamp at which the update of the optimistic minting delay started. Zero if update is not in progress.\"},\"optimisticMintingFeeDivisor()\":{\"notice\":\"Divisor used to compute the treasury fee taken from each optimistically minted deposit and transferred to the treasury upon finalization of the optimistic mint. This fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2%, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`. The optimistic minting fee does not replace the deposit treasury fee cut by the Bridge. The optimistic fee is a percentage AFTER the treasury fee is cut: `optimisticMintingFee = (depositAmount - treasuryFee) / optimisticMintingFeeDivisor`\"},\"optimisticMintingFeeUpdateInitiatedTimestamp()\":{\"notice\":\"The timestamp at which the update of the optimistic minting fee divisor started. Zero if update is not in progress.\"},\"optimisticMintingRequests(uint256)\":{\"notice\":\"Collection of all revealed deposits for which the optimistic minting was requested. Indexed by a deposit key computed as `keccak256(fundingTxHash | fundingOutputIndex)`.\"},\"pauseOptimisticMinting()\":{\"notice\":\"Pauses the optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance. If `extraData` is empty, transfers `amount` back to the caller's balance in the Bank. If `extraData` is not empty, requests redemption in the Bridge using the `extraData` as a `redemptionData` parameter to Bridge's `receiveBalanceApproval` function. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account. Note that it may left a token approval equal to the remainder.\"},\"receiveBalanceApproval(address,uint256,bytes)\":{\"notice\":\"Transfers `satoshis` of the Bank balance from the caller to TBTC Vault and mints `satoshis * SATOSHI_MULTIPLIER` of TBTC to the caller.\"},\"receiveBalanceIncrease(address[],uint256[])\":{\"notice\":\"Mints the same amount of TBTC as the deposited satoshis amount multiplied by SATOSHI_MULTIPLIER for each depositor in the array. Can only be called by the Bank after the Bridge swept deposits and Bank increased balance for the vault.\"},\"recoverERC20(address,address,uint256)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC20 token sent - mistakenly or not - to the vault address. This function should be used to withdraw TBTC v1 tokens transferred to TBTCVault as a result of VendingMachine > TBTCVault upgrade.\"},\"recoverERC20FromToken(address,address,uint256)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC20 token sent mistakenly to the TBTC token contract address.\"},\"recoverERC721(address,address,uint256,bytes)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the vault address.\"},\"recoverERC721FromToken(address,address,uint256,bytes)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the TBTC token contract address.\"},\"removeGuardian(address)\":{\"notice\":\"Removes the address from the Guardian set.\"},\"removeMinter(address)\":{\"notice\":\"Removes the address from the Minter list.\"},\"requestOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Minter to request for an optimistic minting of TBTC. The following conditions must be met: - There is no optimistic minting request for the deposit, finalized or not. - The deposit with the given Bitcoin funding transaction hash and output index has been revealed to the Bridge. - The deposit has not been swept yet. - The deposit is targeted into the TBTCVault. - The optimistic minting is not paused. After calling this function, the Minter has to wait for `optimisticMintingDelay` before finalizing the mint with a call to finalizeOptimisticMint.\"},\"unmint(uint256)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` back to the caller's balance in the Bank. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account.\"},\"unmintAndRedeem(uint256,bytes)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` of Bank balance to the Bridge requesting redemption based on the provided `redemptionData`. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account.\"},\"unpauseOptimisticMinting()\":{\"notice\":\"Unpauses the optimistic minting.\"},\"upgradeInitiatedTimestamp()\":{\"notice\":\"The timestamp at which an upgrade to a new TBTC vault was initiated. Set only when the upgrade process is pending.\"}},\"notice\":\"TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of Bitcoin. It facilitates Bitcoin holders to act on the Ethereum blockchain and access the decentralized finance (DeFi) ecosystem. TBTC Vault mints and unmints TBTC based on Bitcoin balances in the Bank.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/vault/TBTCVault.sol\":\"TBTCVault\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to \\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/CheckBitcoinSigs.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title CheckBitcoinSigs */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {BTCUtils} from \\\"./BTCUtils.sol\\\";\\n\\n\\nlibrary CheckBitcoinSigs {\\n\\n using BytesLib for bytes;\\n using BTCUtils for bytes;\\n\\n /// @notice Derives an Ethereum Account address from a pubkey\\n /// @dev The address is the last 20 bytes of the keccak256 of the address\\n /// @param _pubkey The public key X & Y. Unprefixed, as a 64-byte array\\n /// @return The account address\\n function accountFromPubkey(bytes memory _pubkey) internal pure returns (address) {\\n require(_pubkey.length == 64, \\\"Pubkey must be 64-byte raw, uncompressed key.\\\");\\n\\n // keccak hash of uncompressed unprefixed pubkey\\n bytes32 _digest = keccak256(_pubkey);\\n return address(uint160(uint256(_digest)));\\n }\\n\\n /// @notice Calculates the p2wpkh output script of a pubkey\\n /// @dev Compresses keys to 33 bytes as required by Bitcoin\\n /// @param _pubkey The public key, compressed or uncompressed\\n /// @return The p2wkph output script\\n function p2wpkhFromPubkey(bytes memory _pubkey) internal view returns (bytes memory) {\\n bytes memory _compressedPubkey;\\n uint8 _prefix;\\n\\n if (_pubkey.length == 64) {\\n _prefix = uint8(_pubkey[_pubkey.length - 1]) % 2 == 1 ? 3 : 2;\\n _compressedPubkey = abi.encodePacked(_prefix, _pubkey.slice32(0));\\n } else if (_pubkey.length == 65) {\\n _prefix = uint8(_pubkey[_pubkey.length - 1]) % 2 == 1 ? 3 : 2;\\n _compressedPubkey = abi.encodePacked(_prefix, _pubkey.slice32(1));\\n } else {\\n _compressedPubkey = _pubkey;\\n }\\n\\n require(_compressedPubkey.length == 33, \\\"Witness PKH requires compressed keys\\\");\\n\\n bytes20 _pubkeyHash = _compressedPubkey.hash160View();\\n return abi.encodePacked(hex\\\"0014\\\", _pubkeyHash);\\n }\\n\\n /// @notice checks a signed message's validity under a pubkey\\n /// @dev does this using ecrecover because Ethereum has no soul\\n /// @param _pubkey the public key to check (64 bytes)\\n /// @param _digest the message digest signed\\n /// @param _v the signature recovery value\\n /// @param _r the signature r value\\n /// @param _s the signature s value\\n /// @return true if signature is valid, else false\\n function checkSig(\\n bytes memory _pubkey,\\n bytes32 _digest,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) internal pure returns (bool) {\\n require(_pubkey.length == 64, \\\"Requires uncompressed unprefixed pubkey\\\");\\n address _expected = accountFromPubkey(_pubkey);\\n address _actual = ecrecover(_digest, _v, _r, _s);\\n return _actual == _expected;\\n }\\n\\n /// @notice checks a signed message against a bitcoin p2wpkh output script\\n /// @dev does this my verifying the p2wpkh matches an ethereum account\\n /// @param _p2wpkhOutputScript the bitcoin output script\\n /// @param _pubkey the uncompressed, unprefixed public key to check\\n /// @param _digest the message digest signed\\n /// @param _v the signature recovery value\\n /// @param _r the signature r value\\n /// @param _s the signature s value\\n /// @return true if signature is valid, else false\\n function checkBitcoinSig(\\n bytes memory _p2wpkhOutputScript,\\n bytes memory _pubkey,\\n bytes32 _digest,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) internal view returns (bool) {\\n require(_pubkey.length == 64, \\\"Requires uncompressed unprefixed pubkey\\\");\\n\\n bool _isExpectedSigner = keccak256(p2wpkhFromPubkey(_pubkey)) == keccak256(_p2wpkhOutputScript); // is it the expected signer?\\n if (!_isExpectedSigner) {return false;}\\n\\n bool _sigResult = checkSig(_pubkey, _digest, _v, _r, _s);\\n return _sigResult;\\n }\\n\\n /// @notice checks if a message is the sha256 preimage of a digest\\n /// @dev this is NOT the hash256! this step is necessary for ECDSA security!\\n /// @param _digest the digest\\n /// @param _candidate the purported preimage\\n /// @return true if the preimage matches the digest, else false\\n function isSha256Preimage(\\n bytes memory _candidate,\\n bytes32 _digest\\n ) internal pure returns (bool) {\\n return sha256(_candidate) == _digest;\\n }\\n\\n /// @notice checks if a message is the keccak256 preimage of a digest\\n /// @dev this step is necessary for ECDSA security!\\n /// @param _digest the digest\\n /// @param _candidate the purported preimage\\n /// @return true if the preimage matches the digest, else false\\n function isKeccak256Preimage(\\n bytes memory _candidate,\\n bytes32 _digest\\n ) internal pure returns (bool) {\\n return keccak256(_candidate) == _digest;\\n }\\n\\n /// @notice calculates the signature hash of a Bitcoin transaction with the provided details\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputScript the length-prefixed output script\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function wpkhSpendSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes memory _outputScript // lenght-prefixed output script\\n ) internal view returns (bytes32) {\\n // Fixes elements to easily make a 1-in 1-out sighash digest\\n // Does not support timelocks\\n // bytes memory _scriptCode = abi.encodePacked(\\n // hex\\\"1976a914\\\", // length, dup, hash160, pkh_length\\n // _inputPKH,\\n // hex\\\"88ac\\\"); // equal, checksig\\n\\n bytes32 _hashOutputs = abi.encodePacked(\\n _outputValue, // 8-byte LE\\n _outputScript).hash256View();\\n\\n bytes memory _sighashPreimage = abi.encodePacked(\\n hex\\\"01000000\\\", // version\\n _outpoint.hash256View(), // hashPrevouts\\n hex\\\"8cb9012517c817fead650287d61bdd9c68803b6bf9c64133dcab3e65b5a50cb9\\\", // hashSequence(00000000)\\n _outpoint, // outpoint\\n // p2wpkh script code\\n hex\\\"1976a914\\\", // length, dup, hash160, pkh_length\\n _inputPKH,\\n hex\\\"88ac\\\", // equal, checksig\\n // end script code\\n _inputValue, // value of the input in 8-byte LE\\n hex\\\"00000000\\\", // input nSequence\\n _hashOutputs, // hash of the single output\\n hex\\\"00000000\\\", // nLockTime\\n hex\\\"01000000\\\" // SIGHASH_ALL\\n );\\n return _sighashPreimage.hash256View();\\n }\\n\\n /// @notice calculates the signature hash of a Bitcoin transaction with the provided details\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputPKH the output pubkeyhash (hash160(recipient_pubkey))\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function wpkhToWpkhSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes20 _outputPKH // 20-byte hash160\\n ) internal view returns (bytes32) {\\n return wpkhSpendSighash(\\n _outpoint,\\n _inputPKH,\\n _inputValue,\\n _outputValue,\\n abi.encodePacked(\\n hex\\\"160014\\\", // wpkh tag\\n _outputPKH)\\n );\\n }\\n\\n /// @notice Preserved for API compatibility with older version\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputPKH the output pubkeyhash (hash160(recipient_pubkey))\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function oneInputOneOutputSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes20 _outputPKH // 20-byte hash160\\n ) internal view returns (bytes32) {\\n return wpkhToWpkhSighash(_outpoint, _inputPKH, _inputValue, _outputValue, _outputPKH);\\n }\\n\\n}\\n\",\"keccak256\":\"0xfffbd5486af77058fe9385d63d433da914a043994b1affdfcb87248aa10a234c\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\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:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\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\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title ValidateSPV*/\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\nimport {BTCUtils} from \\\"./BTCUtils.sol\\\";\\n\\n\\nlibrary ValidateSPV {\\n\\n using BTCUtils for bytes;\\n using BTCUtils for uint256;\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n enum InputTypes { NONE, LEGACY, COMPATIBILITY, WITNESS }\\n enum OutputTypes { NONE, WPKH, WSH, OP_RETURN, PKH, SH, NONSTANDARD }\\n\\n uint256 constant ERR_BAD_LENGTH = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n uint256 constant ERR_INVALID_CHAIN = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe;\\n uint256 constant ERR_LOW_WORK = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd;\\n\\n function getErrBadLength() internal pure returns (uint256) {\\n return ERR_BAD_LENGTH;\\n }\\n\\n function getErrInvalidChain() internal pure returns (uint256) {\\n return ERR_INVALID_CHAIN;\\n }\\n\\n function getErrLowWork() internal pure returns (uint256) {\\n return ERR_LOW_WORK;\\n }\\n\\n /// @notice Validates a tx inclusion in the block\\n /// @dev `index` is not a reliable indicator of location within a block\\n /// @param _txid The txid (LE)\\n /// @param _merkleRoot The merkle root (as in the block header)\\n /// @param _intermediateNodes The proof's intermediate nodes (digests between leaf and root)\\n /// @param _index The leaf's index in the tree (0-indexed)\\n /// @return true if fully valid, false otherwise\\n function prove(\\n bytes32 _txid,\\n bytes32 _merkleRoot,\\n bytes memory _intermediateNodes,\\n uint _index\\n ) internal view returns (bool) {\\n // Shortcut the empty-block case\\n if (_txid == _merkleRoot && _index == 0 && _intermediateNodes.length == 0) {\\n return true;\\n }\\n\\n // If the Merkle proof failed, bubble up error\\n return BTCUtils.verifyHash256Merkle(\\n _txid,\\n _intermediateNodes,\\n _merkleRoot,\\n _index\\n );\\n }\\n\\n /// @notice Hashes transaction to get txid\\n /// @dev Supports Legacy and Witness\\n /// @param _version 4-bytes version\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @param _locktime 4-byte tx locktime\\n /// @return 32-byte transaction id, little endian\\n function calculateTxId(\\n bytes4 _version,\\n bytes memory _vin,\\n bytes memory _vout,\\n bytes4 _locktime\\n ) internal view returns (bytes32) {\\n // Get transaction hash double-Sha256(version + nIns + inputs + nOuts + outputs + locktime)\\n return abi.encodePacked(_version, _vin, _vout, _locktime).hash256View();\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @notice Compares the hash of each header to the prevHash in the next header\\n /// @param headers Raw byte array of header chain\\n /// @return totalDifficulty The total accumulated difficulty of the header chain, or an error code\\n function validateHeaderChain(\\n bytes memory headers\\n ) internal view returns (uint256 totalDifficulty) {\\n\\n // Check header chain length\\n if (headers.length % 80 != 0) {return ERR_BAD_LENGTH;}\\n\\n // Initialize header start index\\n bytes32 digest;\\n\\n totalDifficulty = 0;\\n\\n for (uint256 start = 0; start < headers.length; start += 80) {\\n\\n // After the first header, check that headers are in a chain\\n if (start != 0) {\\n if (!validateHeaderPrevHash(headers, start, digest)) {return ERR_INVALID_CHAIN;}\\n }\\n\\n // ith header target\\n uint256 target = headers.extractTargetAt(start);\\n\\n // Require that the header has sufficient work\\n digest = headers.hash256Slice(start, 80);\\n if(uint256(digest).reverseUint256() > target) {\\n return ERR_LOW_WORK;\\n }\\n\\n // Add ith header difficulty to difficulty sum\\n totalDifficulty = totalDifficulty + target.calculateDifficulty();\\n }\\n }\\n\\n /// @notice Checks validity of header work\\n /// @param digest Header digest\\n /// @param target The target threshold\\n /// @return true if header work is valid, false otherwise\\n function validateHeaderWork(\\n bytes32 digest,\\n uint256 target\\n ) internal pure returns (bool) {\\n if (digest == bytes32(0)) {return false;}\\n return (uint256(digest).reverseUint256() < target);\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @dev Compares current header prevHash to previous header's digest\\n /// @param headers The raw bytes array containing the header\\n /// @param at The position of the header\\n /// @param prevHeaderDigest The previous header's digest\\n /// @return true if the connect is valid, false otherwise\\n function validateHeaderPrevHash(\\n bytes memory headers,\\n uint256 at,\\n bytes32 prevHeaderDigest\\n ) internal pure returns (bool) {\\n\\n // Extract prevHash of current header\\n bytes32 prevHash = headers.extractPrevBlockLEAt(at);\\n\\n // Compare prevHash of current header to previous header's digest\\n if (prevHash != prevHeaderDigest) {return false;}\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0xce3febbf3ad3a7ff8a8effd0c7ccaf7ccfa2719578b537d49ea196f0bae8062b\"},\"@keep-network/ecdsa/contracts/EcdsaDkgValidator.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\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// Initial version copied from Keep Network Random Beacon:\\n// https://github.com/keep-network/keep-core/blob/5138c7628868dbeed3ae2164f76fccc6c1fbb9e8/solidity/random-beacon/contracts/DKGValidator.sol\\n//\\n// With the following differences:\\n// - group public key length,\\n// - group size and related thresholds,\\n// - documentation.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\\\";\\nimport \\\"@keep-network/sortition-pools/contracts/SortitionPool.sol\\\";\\nimport \\\"./libraries/EcdsaDkg.sol\\\";\\n\\n/// @title DKG result validator\\n/// @notice EcdsaDkgValidator allows performing a full validation of DKG result,\\n/// including checking the format of fields in the result, declared\\n/// selected group members, and signatures of operators supporting the\\n/// result. The operator submitting the result should perform the\\n/// validation using a free contract call before submitting the result\\n/// to ensure their result is valid and can not be challenged. All other\\n/// network operators should perform validation of the submitted result\\n/// using a free contract call and challenge the result if the\\n/// validation fails.\\ncontract EcdsaDkgValidator {\\n using BytesLib for bytes;\\n using ECDSA for bytes32;\\n\\n /// @dev Size of a group in DKG.\\n uint256 public constant groupSize = 100;\\n\\n /// @dev The minimum number of group members needed to interact according to\\n /// the protocol to produce a signature. The adversary can not learn\\n /// anything about the key as long as it does not break into\\n /// groupThreshold+1 of members.\\n uint256 public constant groupThreshold = 51;\\n\\n /// @dev The minimum number of active and properly behaving group members\\n /// during the DKG needed to accept the result. This number is higher\\n /// than `groupThreshold` to keep a safety margin for members becoming\\n /// inactive after DKG so that the group can still produce signature.\\n uint256 public constant activeThreshold = 90; // 90% of groupSize\\n\\n /// @dev Size in bytes of a public key produced by group members during the\\n /// the DKG. The length assumes uncompressed ECDSA public key.\\n uint256 public constant publicKeyByteSize = 64;\\n\\n /// @dev Size in bytes of a single signature produced by operator supporting\\n /// DKG result.\\n uint256 public constant signatureByteSize = 65;\\n\\n SortitionPool public immutable sortitionPool;\\n\\n constructor(SortitionPool _sortitionPool) {\\n sortitionPool = _sortitionPool;\\n }\\n\\n /// @notice Performs a full validation of DKG result, including checking the\\n /// format of fields in the result, declared selected group members,\\n /// and signatures of operators supporting the result.\\n /// @param seed seed used to start the DKG and select group members\\n /// @param startBlock DKG start block\\n /// @return isValid true if the result is valid, false otherwise\\n /// @return errorMsg validation error message; empty for a valid result\\n function validate(\\n EcdsaDkg.Result calldata result,\\n uint256 seed,\\n uint256 startBlock\\n ) external view returns (bool isValid, string memory errorMsg) {\\n (bool hasValidFields, string memory error) = validateFields(result);\\n if (!hasValidFields) {\\n return (false, error);\\n }\\n\\n if (!validateSignatures(result, startBlock)) {\\n return (false, \\\"Invalid signatures\\\");\\n }\\n\\n if (!validateGroupMembers(result, seed)) {\\n return (false, \\\"Invalid group members\\\");\\n }\\n\\n // At this point all group members and misbehaved members were verified\\n if (!validateMembersHash(result)) {\\n return (false, \\\"Invalid members hash\\\");\\n }\\n\\n return (true, \\\"\\\");\\n }\\n\\n /// @notice Performs a static validation of DKG result fields: lengths,\\n /// ranges, and order of arrays.\\n /// @return isValid true if the result is valid, false otherwise\\n /// @return errorMsg validation error message; empty for a valid result\\n function validateFields(EcdsaDkg.Result calldata result)\\n public\\n pure\\n returns (bool isValid, string memory errorMsg)\\n {\\n if (result.groupPubKey.length != publicKeyByteSize) {\\n return (false, \\\"Malformed group public key\\\");\\n }\\n\\n // The number of misbehaved members can not exceed the threshold.\\n // Misbehaved member indices needs to be unique, between [1, groupSize],\\n // and sorted in ascending order.\\n uint8[] calldata misbehavedMembersIndices = result\\n .misbehavedMembersIndices;\\n if (groupSize - misbehavedMembersIndices.length < activeThreshold) {\\n return (false, \\\"Too many members misbehaving during DKG\\\");\\n }\\n if (misbehavedMembersIndices.length > 1) {\\n if (\\n misbehavedMembersIndices[0] < 1 ||\\n misbehavedMembersIndices[misbehavedMembersIndices.length - 1] >\\n groupSize\\n ) {\\n return (false, \\\"Corrupted misbehaved members indices\\\");\\n }\\n for (uint256 i = 1; i < misbehavedMembersIndices.length; i++) {\\n if (\\n misbehavedMembersIndices[i - 1] >=\\n misbehavedMembersIndices[i]\\n ) {\\n return (false, \\\"Corrupted misbehaved members indices\\\");\\n }\\n }\\n }\\n\\n // Each signature needs to have a correct length and signatures need to\\n // be provided.\\n uint256 signaturesCount = result.signatures.length / signatureByteSize;\\n if (result.signatures.length == 0) {\\n return (false, \\\"No signatures provided\\\");\\n }\\n if (result.signatures.length % signatureByteSize != 0) {\\n return (false, \\\"Malformed signatures array\\\");\\n }\\n\\n // We expect the same amount of signatures as the number of declared\\n // group member indices that signed the result.\\n uint256[] calldata signingMembersIndices = result.signingMembersIndices;\\n if (signaturesCount != signingMembersIndices.length) {\\n return (false, \\\"Unexpected signatures count\\\");\\n }\\n if (signaturesCount < groupThreshold) {\\n return (false, \\\"Too few signatures\\\");\\n }\\n if (signaturesCount > groupSize) {\\n return (false, \\\"Too many signatures\\\");\\n }\\n\\n // Signing member indices needs to be unique, between [1,groupSize],\\n // and sorted in ascending order.\\n if (\\n signingMembersIndices[0] < 1 ||\\n signingMembersIndices[signingMembersIndices.length - 1] > groupSize\\n ) {\\n return (false, \\\"Corrupted signing member indices\\\");\\n }\\n for (uint256 i = 1; i < signingMembersIndices.length; i++) {\\n if (signingMembersIndices[i - 1] >= signingMembersIndices[i]) {\\n return (false, \\\"Corrupted signing member indices\\\");\\n }\\n }\\n\\n return (true, \\\"\\\");\\n }\\n\\n /// @notice Performs validation of group members as declared in DKG\\n /// result against group members selected by the sortition pool.\\n /// @param seed seed used to start the DKG and select group members\\n /// @return true if group members matches; false otherwise\\n function validateGroupMembers(EcdsaDkg.Result calldata result, uint256 seed)\\n public\\n view\\n returns (bool)\\n {\\n uint32[] calldata resultMembers = result.members;\\n uint32[] memory actualGroupMembers = sortitionPool.selectGroup(\\n groupSize,\\n bytes32(seed)\\n );\\n if (resultMembers.length != actualGroupMembers.length) {\\n return false;\\n }\\n for (uint256 i = 0; i < resultMembers.length; i++) {\\n if (resultMembers[i] != actualGroupMembers[i]) {\\n return false;\\n }\\n }\\n return true;\\n }\\n\\n /// @notice Performs validation of signatures supplied in DKG result.\\n /// Note that this function does not check if addresses which\\n /// supplied signatures supporting the result are the ones selected\\n /// to the group by sortition pool. This function should be used\\n /// together with `validateGroupMembers`.\\n /// @param startBlock DKG start block\\n /// @return true if group members matches; false otherwise\\n function validateSignatures(\\n EcdsaDkg.Result calldata result,\\n uint256 startBlock\\n ) public view returns (bool) {\\n bytes32 hash = keccak256(\\n abi.encode(\\n block.chainid,\\n result.groupPubKey,\\n result.misbehavedMembersIndices,\\n startBlock\\n )\\n ).toEthSignedMessageHash();\\n\\n uint256[] calldata signingMembersIndices = result.signingMembersIndices;\\n uint32[] memory signingMemberIds = new uint32[](\\n signingMembersIndices.length\\n );\\n for (uint256 i = 0; i < signingMembersIndices.length; i++) {\\n signingMemberIds[i] = result.members[signingMembersIndices[i] - 1];\\n }\\n\\n address[] memory signingMemberAddresses = sortitionPool.getIDOperators(\\n signingMemberIds\\n );\\n\\n bytes memory current; // Current signature to be checked.\\n\\n uint256 signaturesCount = result.signatures.length / signatureByteSize;\\n for (uint256 i = 0; i < signaturesCount; i++) {\\n current = result.signatures.slice(\\n signatureByteSize * i,\\n signatureByteSize\\n );\\n address recoveredAddress = hash.recover(current);\\n\\n if (signingMemberAddresses[i] != recoveredAddress) {\\n return false;\\n }\\n }\\n\\n return true;\\n }\\n\\n /// @notice Performs validation of hashed group members that actively took\\n /// part in DKG.\\n /// @param result DKG result\\n /// @return true if calculated result's group members hash matches with the\\n /// one that is challenged.\\n function validateMembersHash(EcdsaDkg.Result calldata result)\\n public\\n pure\\n returns (bool)\\n {\\n if (result.misbehavedMembersIndices.length > 0) {\\n // members that generated a group signing key\\n uint32[] memory groupMembers = new uint32[](\\n result.members.length - result.misbehavedMembersIndices.length\\n );\\n uint256 k = 0; // misbehaved members counter\\n uint256 j = 0; // group members counter\\n for (uint256 i = 0; i < result.members.length; i++) {\\n // misbehaved member indices start from 1, so we need to -1 on misbehaved\\n if (i != result.misbehavedMembersIndices[k] - 1) {\\n groupMembers[j] = result.members[i];\\n j++;\\n } else if (k < result.misbehavedMembersIndices.length - 1) {\\n k++;\\n }\\n }\\n\\n return keccak256(abi.encode(groupMembers)) == result.membersHash;\\n }\\n\\n return keccak256(abi.encode(result.members)) == result.membersHash;\\n }\\n}\\n\",\"keccak256\":\"0xe8f3d63ef4213ac71d447726be3971c5ed6b0b0eb145763d324faecdce707bf6\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/api/IWalletOwner.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\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\\npragma solidity 0.8.17;\\n\\ninterface IWalletOwner {\\n /// @notice Callback function executed once a new wallet is created.\\n /// @dev Should be callable only by the Wallet Registry.\\n /// @param walletID Wallet's unique identifier.\\n /// @param publicKeyY Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n function __ecdsaWalletCreatedCallback(\\n bytes32 walletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external;\\n\\n /// @notice Callback function executed once a wallet heartbeat failure\\n /// is detected.\\n /// @dev Should be callable only by the Wallet Registry.\\n /// @param walletID Wallet's unique identifier.\\n /// @param publicKeyY Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n function __ecdsaWalletHeartbeatFailedCallback(\\n bytes32 walletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external;\\n}\\n\",\"keccak256\":\"0x8d4654269ab20710e8a729c225c2c69edae7f01ddbd5e037ab591df65e32faa8\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/api/IWalletRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\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\\npragma solidity 0.8.17;\\n\\nimport \\\"../libraries/EcdsaDkg.sol\\\";\\n\\ninterface IWalletRegistry {\\n /// @notice Requests a new wallet creation.\\n /// @dev Only the Wallet Owner can call this function.\\n function requestNewWallet() external;\\n\\n /// @notice Closes an existing wallet.\\n /// @param walletID ID of the wallet.\\n /// @dev Only the Wallet Owner can call this function.\\n function closeWallet(bytes32 walletID) external;\\n\\n /// @notice Adds all signing group members of the wallet with the given ID\\n /// to the slashing queue of the staking contract. The notifier will\\n /// receive reward per each group member from the staking contract\\n /// notifiers treasury. The reward is scaled by the\\n /// `rewardMultiplier` provided as a parameter.\\n /// @param amount Amount of tokens to seize from each signing group member\\n /// @param rewardMultiplier Fraction of the staking contract notifiers\\n /// reward the notifier should receive; should be between [0, 100]\\n /// @param notifier Address of the misbehavior notifier\\n /// @param walletID ID of the wallet\\n /// @param walletMembersIDs Identifiers of the wallet signing group members\\n /// @dev Only the Wallet Owner can call this function.\\n /// Requirements:\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events.\\n /// - `rewardMultiplier` must be between [0, 100].\\n /// - This function does revert if staking contract call reverts.\\n /// The calling code needs to handle the potential revert.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n bytes32 walletID,\\n uint32[] calldata walletMembersIDs\\n ) external;\\n\\n /// @notice Gets public key of a wallet with a given wallet ID.\\n /// The public key is returned in an uncompressed format as a 64-byte\\n /// concatenation of X and Y coordinates.\\n /// @param walletID ID of the wallet.\\n /// @return Uncompressed public key of the wallet.\\n function getWalletPublicKey(bytes32 walletID)\\n external\\n view\\n returns (bytes memory);\\n\\n /// @notice Check current wallet creation state.\\n function getWalletCreationState() external view returns (EcdsaDkg.State);\\n\\n /// @notice Checks whether the given operator is a member of the given\\n /// wallet signing group.\\n /// @param walletID ID of the wallet\\n /// @param walletMembersIDs Identifiers of the wallet signing group members\\n /// @param operator Address of the checked operator\\n /// @param walletMemberIndex Position of the operator in the wallet signing\\n /// group members list\\n /// @return True - if the operator is a member of the given wallet signing\\n /// group. False - otherwise.\\n /// @dev Requirements:\\n /// - The `operator` parameter must be an actual sortition pool operator.\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events.\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]\\n function isWalletMember(\\n bytes32 walletID,\\n uint32[] calldata walletMembersIDs,\\n address operator,\\n uint256 walletMemberIndex\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xb97ece7c12601396fed705386a4e3337ee3a4809dca090a5acb62c2949337c68\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/libraries/EcdsaDkg.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\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//\\n\\n// Initial version copied from Keep Network Random Beacon:\\n// https://github.com/keep-network/keep-core/blob/5138c7628868dbeed3ae2164f76fccc6c1fbb9e8/solidity/random-beacon/contracts/libraries/DKG.sol\\n//\\n// With the following differences:\\n// - the group size was set to 100,\\n// - offchainDkgTimeout was removed,\\n// - submission eligibility verification is not performed on-chain,\\n// - submission eligibility delay was replaced with a submission timeout,\\n// - seed timeout notification requires seedTimeout period to pass.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol\\\";\\nimport \\\"@keep-network/sortition-pools/contracts/SortitionPool.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\\\";\\nimport \\\"../EcdsaDkgValidator.sol\\\";\\n\\nlibrary EcdsaDkg {\\n using BytesLib for bytes;\\n using ECDSAUpgradeable for bytes32;\\n\\n struct Parameters {\\n // Time in blocks during which a seed is expected to be delivered.\\n // DKG starts only after a seed is delivered. The time the contract\\n // awaits for a seed is not included in the DKG timeout.\\n uint256 seedTimeout;\\n // Time in blocks during which a submitted result can be challenged.\\n uint256 resultChallengePeriodLength;\\n // Extra gas required to be left at the end of the challenge DKG result\\n // transaction.\\n uint256 resultChallengeExtraGas;\\n // Time in blocks during which a result is expected to be submitted.\\n uint256 resultSubmissionTimeout;\\n // Time in blocks during which only the result submitter is allowed to\\n // approve it. Once this period ends and the submitter have not approved\\n // the result, anyone can do it.\\n uint256 submitterPrecedencePeriodLength;\\n // This struct doesn't contain `__gap` property as the structure is\\n // stored inside `Data` struct, that already have a gap that can be used\\n // on upgrade.\\n }\\n\\n struct Data {\\n // Address of the Sortition Pool contract.\\n SortitionPool sortitionPool;\\n // Address of the EcdsaDkgValidator contract.\\n EcdsaDkgValidator dkgValidator;\\n // DKG parameters. The parameters should persist between DKG executions.\\n // They should be updated with dedicated set functions only when DKG is not\\n // in progress.\\n Parameters parameters;\\n // Time in block at which DKG state was locked.\\n uint256 stateLockBlock;\\n // Time in blocks at which DKG started.\\n uint256 startBlock;\\n // Seed used to start DKG.\\n uint256 seed;\\n // Time in blocks that should be added to result submission eligibility\\n // delay calculation. It is used in case of a challenge to adjust\\n // DKG timeout calculation.\\n uint256 resultSubmissionStartBlockOffset;\\n // Hash of submitted DKG result.\\n bytes32 submittedResultHash;\\n // Block number from the moment of the DKG result submission.\\n uint256 submittedResultBlock;\\n // Reserved storage space in case we need to add more variables.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[38] __gap;\\n }\\n\\n /// @notice DKG result.\\n struct Result {\\n // Claimed submitter candidate group member index.\\n // Must be in range [1, groupSize].\\n uint256 submitterMemberIndex;\\n // Generated candidate group public key\\n bytes groupPubKey;\\n // Array of misbehaved members indices (disqualified or inactive).\\n // Indices must be in range [1, groupSize], unique, and sorted in ascending\\n // order.\\n uint8[] misbehavedMembersIndices;\\n // Concatenation of signatures from members supporting the result.\\n // The message to be signed by each member is keccak256 hash of the\\n // calculated group public key, misbehaved members indices and DKG\\n // start block. The calculated hash should be prefixed with prefixed with\\n // `\\\\x19Ethereum signed message:\\\\n` before signing, so the message to\\n // sign is:\\n // `\\\\x19Ethereum signed message:\\\\n${keccak256(\\n // groupPubKey, misbehavedMembersIndices, dkgStartBlock\\n // )}`\\n bytes signatures;\\n // Indices of members corresponding to each signature. Indices must be\\n // be in range [1, groupSize], unique, and sorted in ascending order.\\n uint256[] signingMembersIndices;\\n // Identifiers of candidate group members as outputted by the group\\n // selection protocol.\\n uint32[] members;\\n // Keccak256 hash of group members identifiers that actively took part\\n // in DKG (excluding IA/DQ members).\\n bytes32 membersHash;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice States for phases of group creation. The states doesn't include\\n /// timeouts which should be tracked and notified individually.\\n enum State {\\n // Group creation is not in progress. It is a state set after group creation\\n // completion either by timeout or by a result approval.\\n IDLE,\\n // Group creation is awaiting the seed and sortition pool is locked.\\n AWAITING_SEED,\\n // DKG protocol execution is in progress. A result is being calculated\\n // by the clients in this state and the contract awaits a result submission.\\n // This is a state to which group creation returns in case of a result\\n // challenge notification.\\n AWAITING_RESULT,\\n // DKG result was submitted and awaits an approval or a challenge. If a result\\n // gets challenge the state returns to `AWAITING_RESULT`. If a result gets\\n // approval the state changes to `IDLE`.\\n CHALLENGE\\n }\\n\\n /// @dev Size of a group in ECDSA wallet.\\n uint256 public constant groupSize = 100;\\n\\n event DkgStarted(uint256 indexed seed);\\n\\n // To recreate the members that actively took part in dkg, the selected members\\n // array should be filtered out from misbehavedMembersIndices.\\n event DkgResultSubmitted(\\n bytes32 indexed resultHash,\\n uint256 indexed seed,\\n Result result\\n );\\n\\n event DkgTimedOut();\\n\\n event DkgResultApproved(\\n bytes32 indexed resultHash,\\n address indexed approver\\n );\\n\\n event DkgResultChallenged(\\n bytes32 indexed resultHash,\\n address indexed challenger,\\n string reason\\n );\\n\\n event DkgStateLocked();\\n\\n event DkgSeedTimedOut();\\n\\n /// @notice Initializes SortitionPool and EcdsaDkgValidator addresses.\\n /// Can be performed only once.\\n /// @param _sortitionPool Sortition Pool reference\\n /// @param _dkgValidator EcdsaDkgValidator reference\\n function init(\\n Data storage self,\\n SortitionPool _sortitionPool,\\n EcdsaDkgValidator _dkgValidator\\n ) internal {\\n require(\\n address(self.sortitionPool) == address(0),\\n \\\"Sortition Pool address already set\\\"\\n );\\n\\n require(\\n address(self.dkgValidator) == address(0),\\n \\\"DKG Validator address already set\\\"\\n );\\n\\n self.sortitionPool = _sortitionPool;\\n self.dkgValidator = _dkgValidator;\\n }\\n\\n /// @notice Determines the current state of group creation. It doesn't take\\n /// timeouts into consideration. The timeouts should be tracked and\\n /// notified separately.\\n function currentState(Data storage self)\\n internal\\n view\\n returns (State state)\\n {\\n state = State.IDLE;\\n\\n if (self.sortitionPool.isLocked()) {\\n state = State.AWAITING_SEED;\\n\\n if (self.startBlock > 0) {\\n state = State.AWAITING_RESULT;\\n\\n if (self.submittedResultBlock > 0) {\\n state = State.CHALLENGE;\\n }\\n }\\n }\\n }\\n\\n /// @notice Locks the sortition pool and starts awaiting for the\\n /// group creation seed.\\n function lockState(Data storage self) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n emit DkgStateLocked();\\n\\n self.sortitionPool.lock();\\n\\n self.stateLockBlock = block.number;\\n }\\n\\n function start(Data storage self, uint256 seed) internal {\\n require(\\n currentState(self) == State.AWAITING_SEED,\\n \\\"Current state is not AWAITING_SEED\\\"\\n );\\n\\n emit DkgStarted(seed);\\n\\n self.startBlock = block.number;\\n self.seed = seed;\\n }\\n\\n /// @notice Allows to submit a DKG result. The submitted result does not go\\n /// through a validation and before it gets accepted, it needs to\\n /// wait through the challenge period during which everyone has\\n /// a chance to challenge the result as invalid one. Submitter of\\n /// the result needs to be in the sortition pool and if the result\\n /// gets challenged, the submitter will get slashed.\\n function submitResult(Data storage self, Result calldata result) internal {\\n require(\\n currentState(self) == State.AWAITING_RESULT,\\n \\\"Current state is not AWAITING_RESULT\\\"\\n );\\n require(!hasDkgTimedOut(self), \\\"DKG timeout already passed\\\");\\n\\n SortitionPool sortitionPool = self.sortitionPool;\\n\\n // Submitter must be an operator in the sortition pool.\\n // Declared submitter's member index in the DKG result needs to match\\n // the address calling this function.\\n require(\\n sortitionPool.isOperatorInPool(msg.sender),\\n \\\"Submitter not in the sortition pool\\\"\\n );\\n require(\\n sortitionPool.getIDOperator(\\n result.members[result.submitterMemberIndex - 1]\\n ) == msg.sender,\\n \\\"Unexpected submitter index\\\"\\n );\\n\\n self.submittedResultHash = keccak256(abi.encode(result));\\n self.submittedResultBlock = block.number;\\n\\n emit DkgResultSubmitted(self.submittedResultHash, self.seed, result);\\n }\\n\\n /// @notice Checks if awaiting seed timed out.\\n /// @return True if awaiting seed timed out, false otherwise.\\n function hasSeedTimedOut(Data storage self) internal view returns (bool) {\\n return\\n currentState(self) == State.AWAITING_SEED &&\\n block.number > (self.stateLockBlock + self.parameters.seedTimeout);\\n }\\n\\n /// @notice Checks if DKG timed out. The DKG timeout period includes time required\\n /// for off-chain protocol execution and time for the result publication.\\n /// After this time a result cannot be submitted and DKG can be notified\\n /// about the timeout. DKG period is adjusted by result submission\\n /// offset that include blocks that were mined while invalid result\\n /// has been registered until it got challenged.\\n /// @return True if DKG timed out, false otherwise.\\n function hasDkgTimedOut(Data storage self) internal view returns (bool) {\\n return\\n currentState(self) == State.AWAITING_RESULT &&\\n block.number >\\n (self.startBlock +\\n self.resultSubmissionStartBlockOffset +\\n self.parameters.resultSubmissionTimeout);\\n }\\n\\n /// @notice Notifies about the seed was not delivered and restores the\\n /// initial DKG state (IDLE).\\n function notifySeedTimeout(Data storage self) internal {\\n require(hasSeedTimedOut(self), \\\"Awaiting seed has not timed out\\\");\\n\\n emit DkgSeedTimedOut();\\n\\n complete(self);\\n }\\n\\n /// @notice Notifies about DKG timeout.\\n function notifyDkgTimeout(Data storage self) internal {\\n require(hasDkgTimedOut(self), \\\"DKG has not timed out\\\");\\n\\n emit DkgTimedOut();\\n\\n complete(self);\\n }\\n\\n /// @notice Approves DKG result. Can be called when the challenge period for\\n /// the submitted result is finished. Considers the submitted result\\n /// as valid. For the first `submitterPrecedencePeriodLength`\\n /// blocks after the end of the challenge period can be called only\\n /// by the DKG result submitter. After that time, can be called by\\n /// anyone.\\n /// @dev Can be called after a challenge period for the submitted result.\\n /// @param result Result to approve. Must match the submitted result stored\\n /// during `submitResult`.\\n /// @return misbehavedMembers Identifiers of members who misbehaved during DKG.\\n function approveResult(Data storage self, Result calldata result)\\n internal\\n returns (uint32[] memory misbehavedMembers)\\n {\\n require(\\n currentState(self) == State.CHALLENGE,\\n \\\"Current state is not CHALLENGE\\\"\\n );\\n\\n uint256 challengePeriodEnd = self.submittedResultBlock +\\n self.parameters.resultChallengePeriodLength;\\n\\n require(\\n block.number > challengePeriodEnd,\\n \\\"Challenge period has not passed yet\\\"\\n );\\n\\n require(\\n keccak256(abi.encode(result)) == self.submittedResultHash,\\n \\\"Result under approval is different than the submitted one\\\"\\n );\\n\\n // Extract submitter member address. Submitter member index is in\\n // range [1, groupSize] so we need to -1 when fetching identifier from members\\n // array.\\n address submitterMember = self.sortitionPool.getIDOperator(\\n result.members[result.submitterMemberIndex - 1]\\n );\\n\\n require(\\n msg.sender == submitterMember ||\\n block.number >\\n challengePeriodEnd +\\n self.parameters.submitterPrecedencePeriodLength,\\n \\\"Only the DKG result submitter can approve the result at this moment\\\"\\n );\\n\\n // Extract misbehaved members identifiers. Misbehaved members indices\\n // are in range [1, groupSize], so we need to -1 when fetching identifiers from\\n // members array.\\n misbehavedMembers = new uint32[](\\n result.misbehavedMembersIndices.length\\n );\\n for (uint256 i = 0; i < result.misbehavedMembersIndices.length; i++) {\\n misbehavedMembers[i] = result.members[\\n result.misbehavedMembersIndices[i] - 1\\n ];\\n }\\n\\n emit DkgResultApproved(self.submittedResultHash, msg.sender);\\n\\n return misbehavedMembers;\\n }\\n\\n /// @notice Challenges DKG result. If the submitted result is proved to be\\n /// invalid it reverts the DKG back to the result submission phase.\\n /// @dev Can be called during a challenge period for the submitted result.\\n /// @param result Result to challenge. Must match the submitted result\\n /// stored during `submitResult`.\\n /// @return maliciousResultHash Hash of the malicious result.\\n /// @return maliciousSubmitter Identifier of the malicious submitter.\\n function challengeResult(Data storage self, Result calldata result)\\n internal\\n returns (bytes32 maliciousResultHash, uint32 maliciousSubmitter)\\n {\\n require(\\n currentState(self) == State.CHALLENGE,\\n \\\"Current state is not CHALLENGE\\\"\\n );\\n\\n require(\\n block.number <=\\n self.submittedResultBlock +\\n self.parameters.resultChallengePeriodLength,\\n \\\"Challenge period has already passed\\\"\\n );\\n\\n require(\\n keccak256(abi.encode(result)) == self.submittedResultHash,\\n \\\"Result under challenge is different than the submitted one\\\"\\n );\\n\\n // https://github.com/crytic/slither/issues/982\\n // slither-disable-next-line unused-return\\n try\\n self.dkgValidator.validate(result, self.seed, self.startBlock)\\n returns (\\n // slither-disable-next-line uninitialized-local,variable-scope\\n bool isValid,\\n // slither-disable-next-line uninitialized-local,variable-scope\\n string memory errorMsg\\n ) {\\n if (isValid) {\\n revert(\\\"unjustified challenge\\\");\\n }\\n\\n emit DkgResultChallenged(\\n self.submittedResultHash,\\n msg.sender,\\n errorMsg\\n );\\n } catch {\\n // if the validation reverted we consider the DKG result as invalid\\n emit DkgResultChallenged(\\n self.submittedResultHash,\\n msg.sender,\\n \\\"validation reverted\\\"\\n );\\n }\\n\\n // Consider result hash as malicious.\\n maliciousResultHash = self.submittedResultHash;\\n maliciousSubmitter = result.members[result.submitterMemberIndex - 1];\\n\\n // Adjust DKG result submission block start, so submission stage starts\\n // from the beginning.\\n self.resultSubmissionStartBlockOffset = block.number - self.startBlock;\\n\\n submittedResultCleanup(self);\\n\\n return (maliciousResultHash, maliciousSubmitter);\\n }\\n\\n /// @notice Due to EIP150, 1/64 of the gas is not forwarded to the call, and\\n /// will be kept to execute the remaining operations in the function\\n /// after the call inside the try-catch.\\n ///\\n /// To ensure there is no way for the caller to manipulate gas limit\\n /// in such a way that the call inside try-catch fails with out-of-gas\\n /// and the rest of the function is executed with the remaining\\n /// 1/64 of gas, we require an extra gas amount to be left at the\\n /// end of the call to the function challenging DKG result and\\n /// wrapping the call to EcdsaDkgValidator and TokenStaking\\n /// contracts inside a try-catch.\\n function requireChallengeExtraGas(Data storage self) internal view {\\n require(\\n gasleft() >= self.parameters.resultChallengeExtraGas,\\n \\\"Not enough extra gas left\\\"\\n );\\n }\\n\\n /// @notice Checks if DKG result is valid for the current DKG.\\n /// @param result DKG result.\\n /// @return True if the result is valid. If the result is invalid it returns\\n /// false and an error message.\\n function isResultValid(Data storage self, Result calldata result)\\n internal\\n view\\n returns (bool, string memory)\\n {\\n require(self.startBlock > 0, \\\"DKG has not been started\\\");\\n\\n return self.dkgValidator.validate(result, self.seed, self.startBlock);\\n }\\n\\n /// @notice Set setSeedTimeout parameter.\\n function setSeedTimeout(Data storage self, uint256 newSeedTimeout)\\n internal\\n {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(newSeedTimeout > 0, \\\"New value should be greater than zero\\\");\\n\\n self.parameters.seedTimeout = newSeedTimeout;\\n }\\n\\n /// @notice Set resultChallengePeriodLength parameter.\\n function setResultChallengePeriodLength(\\n Data storage self,\\n uint256 newResultChallengePeriodLength\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newResultChallengePeriodLength > 0,\\n \\\"New value should be greater than zero\\\"\\n );\\n\\n self\\n .parameters\\n .resultChallengePeriodLength = newResultChallengePeriodLength;\\n }\\n\\n /// @notice Set resultChallengeExtraGas parameter.\\n function setResultChallengeExtraGas(\\n Data storage self,\\n uint256 newResultChallengeExtraGas\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n self.parameters.resultChallengeExtraGas = newResultChallengeExtraGas;\\n }\\n\\n /// @notice Set resultSubmissionTimeout parameter.\\n function setResultSubmissionTimeout(\\n Data storage self,\\n uint256 newResultSubmissionTimeout\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newResultSubmissionTimeout > 0,\\n \\\"New value should be greater than zero\\\"\\n );\\n\\n self.parameters.resultSubmissionTimeout = newResultSubmissionTimeout;\\n }\\n\\n /// @notice Set submitterPrecedencePeriodLength parameter.\\n function setSubmitterPrecedencePeriodLength(\\n Data storage self,\\n uint256 newSubmitterPrecedencePeriodLength\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newSubmitterPrecedencePeriodLength <\\n self.parameters.resultSubmissionTimeout,\\n \\\"New value should be less than result submission period length\\\"\\n );\\n\\n self\\n .parameters\\n .submitterPrecedencePeriodLength = newSubmitterPrecedencePeriodLength;\\n }\\n\\n /// @notice Completes DKG by cleaning up state.\\n /// @dev Should be called after DKG times out or a result is approved.\\n function complete(Data storage self) internal {\\n delete self.startBlock;\\n delete self.seed;\\n delete self.resultSubmissionStartBlockOffset;\\n submittedResultCleanup(self);\\n self.sortitionPool.unlock();\\n }\\n\\n /// @notice Cleans up submitted result state either after DKG completion\\n /// (as part of `complete` method) or after justified challenge.\\n function submittedResultCleanup(Data storage self) private {\\n delete self.submittedResultHash;\\n delete self.submittedResultBlock;\\n }\\n}\\n\",\"keccak256\":\"0xd6c442e1db2dc95730443fb6496d47889a69bed2fbace466b27f9727484c25ec\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/Governable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\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\\npragma solidity 0.8.17;\\n\\n/// @notice Governable contract.\\n/// @dev A constructor is not defined, which makes the contract compatible with\\n/// upgradable proxies. This requires calling explicitly `_transferGovernance`\\n/// function in a child contract.\\nabstract contract Governable {\\n // Governance of the contract\\n // The variable should be initialized by the implementing contract.\\n // slither-disable-next-line uninitialized-state\\n address public governance;\\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[49] private __gap;\\n\\n event GovernanceTransferred(address oldGovernance, address newGovernance);\\n\\n modifier onlyGovernance() virtual {\\n require(governance == msg.sender, \\\"Caller is not the governance\\\");\\n _;\\n }\\n\\n /// @notice Transfers governance of the contract to `newGovernance`.\\n function transferGovernance(address newGovernance)\\n external\\n virtual\\n onlyGovernance\\n {\\n require(\\n newGovernance != address(0),\\n \\\"New governance is the zero address\\\"\\n );\\n _transferGovernance(newGovernance);\\n }\\n\\n function _transferGovernance(address newGovernance) internal virtual {\\n address oldGovernance = governance;\\n governance = newGovernance;\\n emit GovernanceTransferred(oldGovernance, newGovernance);\\n }\\n}\\n\",\"keccak256\":\"0xcc6a0fe8fdf05a805d2874dc7dd76dede1eb16e3ab77f2d0069dbb92272ab0a3\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\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\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\n\\ncontract ReimbursementPool is Ownable, ReentrancyGuard {\\n /// @notice Authorized contracts that can interact with the reimbursment pool.\\n /// Authorization can be granted and removed by the owner.\\n mapping(address => bool) public isAuthorized;\\n\\n /// @notice Static gas includes:\\n /// - cost of the refund function\\n /// - base transaction cost\\n uint256 public staticGas;\\n\\n /// @notice Max gas price used to reimburse a transaction submitter. Protects\\n /// against malicious operator-miners.\\n uint256 public maxGasPrice;\\n\\n event StaticGasUpdated(uint256 newStaticGas);\\n\\n event MaxGasPriceUpdated(uint256 newMaxGasPrice);\\n\\n event SendingEtherFailed(uint256 refundAmount, address receiver);\\n\\n event AuthorizedContract(address thirdPartyContract);\\n\\n event UnauthorizedContract(address thirdPartyContract);\\n\\n event FundsWithdrawn(uint256 withdrawnAmount, address receiver);\\n\\n constructor(uint256 _staticGas, uint256 _maxGasPrice) {\\n staticGas = _staticGas;\\n maxGasPrice = _maxGasPrice;\\n }\\n\\n /// @notice Receive ETH\\n receive() external payable {}\\n\\n /// @notice Refunds ETH to a spender for executing specific transactions.\\n /// @dev Ignoring the result of sending ETH to a receiver is made on purpose.\\n /// For EOA receiving ETH should always work. If a receiver is a smart\\n /// contract, then we do not want to fail a transaction, because in some\\n /// cases the refund is done at the very end of multiple calls where all\\n /// the previous calls were already paid off. It is a receiver's smart\\n /// contract resposibility to make sure it can receive ETH.\\n /// @dev Only authorized contracts are allowed calling this function.\\n /// @param gasSpent Gas spent on a transaction that needs to be reimbursed.\\n /// @param receiver Address where the reimbursment is sent.\\n function refund(uint256 gasSpent, address receiver) external nonReentrant {\\n require(\\n isAuthorized[msg.sender],\\n \\\"Contract is not authorized for a refund\\\"\\n );\\n require(receiver != address(0), \\\"Receiver's address cannot be zero\\\");\\n\\n uint256 gasPrice = tx.gasprice < maxGasPrice\\n ? tx.gasprice\\n : maxGasPrice;\\n\\n uint256 refundAmount = (gasSpent + staticGas) * gasPrice;\\n\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel\\n (bool sent, ) = receiver.call{value: refundAmount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n if (!sent) {\\n // slither-disable-next-line reentrancy-events\\n emit SendingEtherFailed(refundAmount, receiver);\\n }\\n }\\n\\n /// @notice Authorize a contract that can interact with this reimbursment pool.\\n /// Can be authorized by the owner only.\\n /// @param _contract Authorized contract.\\n function authorize(address _contract) external onlyOwner {\\n isAuthorized[_contract] = true;\\n\\n emit AuthorizedContract(_contract);\\n }\\n\\n /// @notice Unauthorize a contract that was previously authorized to interact\\n /// with this reimbursment pool. Can be unauthorized by the\\n /// owner only.\\n /// @param _contract Authorized contract.\\n function unauthorize(address _contract) external onlyOwner {\\n delete isAuthorized[_contract];\\n\\n emit UnauthorizedContract(_contract);\\n }\\n\\n /// @notice Setting a static gas cost for executing a transaction. Can be set\\n /// by the owner only.\\n /// @param _staticGas Static gas cost.\\n function setStaticGas(uint256 _staticGas) external onlyOwner {\\n staticGas = _staticGas;\\n\\n emit StaticGasUpdated(_staticGas);\\n }\\n\\n /// @notice Setting a max gas price for transactions. Can be set by the\\n /// owner only.\\n /// @param _maxGasPrice Max gas price used to reimburse tx submitters.\\n function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwner {\\n maxGasPrice = _maxGasPrice;\\n\\n emit MaxGasPriceUpdated(_maxGasPrice);\\n }\\n\\n /// @notice Withdraws all ETH from this pool which are sent to a given\\n /// address. Can be set by the owner only.\\n /// @param receiver An address where ETH is sent.\\n function withdrawAll(address receiver) external onlyOwner {\\n withdraw(address(this).balance, receiver);\\n }\\n\\n /// @notice Withdraws ETH amount from this pool which are sent to a given\\n /// address. Can be set by the owner only.\\n /// @param amount Amount to withdraw from the pool.\\n /// @param receiver An address where ETH is sent.\\n function withdraw(uint256 amount, address receiver) public onlyOwner {\\n require(\\n address(this).balance >= amount,\\n \\\"Insufficient contract balance\\\"\\n );\\n require(receiver != address(0), \\\"Receiver's address cannot be zero\\\");\\n\\n emit FundsWithdrawn(amount, receiver);\\n\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,arbitrary-send\\n (bool sent, ) = receiver.call{value: amount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n}\\n\",\"keccak256\":\"0xd6c24368cc4c6349b8b614e878ca961cad8254b8e8db1cc0abe452a70022ce50\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\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//\\n\\npragma solidity 0.8.17;\\n\\n/*\\nVersion pulled from keep-core v1:\\nhttps://github.com/keep-network/keep-core/blob/f297202db00c027978ad8e7103a356503de5773c/solidity-v1/contracts/utils/BytesLib.sol\\n\\nTo compile it with solidity 0.8 `_preBytes_slot` was replaced with `_preBytes.slot`.\\n*/\\n\\n/*\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\nThis is free and unencumbered software released into the public domain.\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\nFor more information, please refer to \\n*/\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes)\\n internal\\n {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(\\n and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)),\\n 2\\n )\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes)\\n internal\\n view\\n returns (bool)\\n {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(\\n and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)),\\n 2\\n )\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {\\n\\n } eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function concat(bytes memory _preBytes, bytes memory _postBytes)\\n internal\\n pure\\n returns (bytes memory)\\n {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(\\n 0x40,\\n and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n )\\n )\\n }\\n\\n return tempBytes;\\n }\\n\\n function slice(\\n bytes memory _bytes,\\n uint256 _start,\\n uint256 _length\\n ) internal pure returns (bytes memory res) {\\n uint256 _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n function toAddress(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (address)\\n {\\n uint256 _totalLen = _start + 20;\\n require(\\n _totalLen > _start && _bytes.length >= _totalLen,\\n \\\"Address conversion out of bounds.\\\"\\n );\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(\\n mload(add(add(_bytes, 0x20), _start)),\\n 0x1000000000000000000000000\\n )\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint8(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (uint8)\\n {\\n require(\\n _bytes.length >= (_start + 1),\\n \\\"Uint8 conversion out of bounds.\\\"\\n );\\n uint8 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x1), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function toUint(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 _totalLen = _start + 32;\\n require(\\n _totalLen > _start && _bytes.length >= _totalLen,\\n \\\"Uint conversion out of bounds.\\\"\\n );\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes)\\n internal\\n pure\\n returns (bool)\\n {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source)\\n internal\\n pure\\n returns (bytes32 result)\\n {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(\\n bytes memory _bytes,\\n uint256 _start,\\n uint256 _length\\n ) internal pure returns (bytes32 result) {\\n uint256 _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3b76e2fe36eb777440250dcf2ea7a689375e8af22f3cc33521095ff6954becdb\",\"license\":\"GPL-3.0-only\"},\"@keep-network/sortition-pools/contracts/Branch.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\n/// @notice The implicit 8-ary trees of the sortition pool\\n/// rely on packing 8 \\\"slots\\\" of 32-bit values into each uint256.\\n/// The Branch library permits efficient calculations on these slots.\\nlibrary Branch {\\n /// @notice Calculate the right shift required\\n /// to make the 32 least significant bits of an uint256\\n /// be the bits of the `position`th slot\\n /// when treating the uint256 as a uint32[8].\\n ///\\n /// @dev Not used for efficiency reasons,\\n /// but left to illustrate the meaning of a common pattern.\\n /// I wish solidity had macros, even C macros.\\n function slotShift(uint256 position) internal pure returns (uint256) {\\n unchecked {\\n return position * Constants.SLOT_WIDTH;\\n }\\n }\\n\\n /// @notice Return the `position`th slot of the `node`,\\n /// treating `node` as a uint32[32].\\n function getSlot(uint256 node, uint256 position)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Doing a bitwise AND with `SLOT_MAX`\\n // clears all but the 32 least significant bits.\\n // Because of the right shift by `slotShift(position)` bits,\\n // those 32 bits contain the 32 bits in the `position`th slot of `node`.\\n return (node >> shiftBits) & Constants.SLOT_MAX;\\n }\\n }\\n\\n /// @notice Return `node` with the `position`th slot set to zero.\\n function clearSlot(uint256 node, uint256 position)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Shifting `SLOT_MAX` left by `slotShift(position)` bits\\n // gives us a number where all bits of the `position`th slot are set,\\n // and all other bits are unset.\\n //\\n // Using a bitwise NOT on this number,\\n // we get a uint256 where all bits are set\\n // except for those of the `position`th slot.\\n //\\n // Bitwise ANDing the original `node` with this number\\n // sets the bits of `position`th slot to zero,\\n // leaving all other bits unchanged.\\n return node & ~(Constants.SLOT_MAX << shiftBits);\\n }\\n }\\n\\n /// @notice Return `node` with the `position`th slot set to `weight`.\\n ///\\n /// @param weight The weight of of the node.\\n /// Safely truncated to a 32-bit number,\\n /// but this should never be called with an overflowing weight regardless.\\n function setSlot(\\n uint256 node,\\n uint256 position,\\n uint256 weight\\n ) internal pure returns (uint256) {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Clear the `position`th slot like in `clearSlot()`.\\n uint256 clearedNode = node & ~(Constants.SLOT_MAX << shiftBits);\\n // Bitwise AND `weight` with `SLOT_MAX`\\n // to clear all but the 32 least significant bits.\\n //\\n // Shift this left by `slotShift(position)` bits\\n // to obtain a uint256 with all bits unset\\n // except in the `position`th slot\\n // which contains the 32-bit value of `weight`.\\n uint256 shiftedWeight = (weight & Constants.SLOT_MAX) << shiftBits;\\n // When we bitwise OR these together,\\n // all other slots except the `position`th one come from the left argument,\\n // and the `position`th gets filled with `weight` from the right argument.\\n return clearedNode | shiftedWeight;\\n }\\n }\\n\\n /// @notice Calculate the summed weight of all slots in the `node`.\\n function sumWeight(uint256 node) internal pure returns (uint256 sum) {\\n unchecked {\\n sum = node & Constants.SLOT_MAX;\\n // Iterate through each slot\\n // by shifting `node` right in increments of 32 bits,\\n // and adding the 32 least significant bits to the `sum`.\\n uint256 newNode = node >> Constants.SLOT_WIDTH;\\n while (newNode > 0) {\\n sum += (newNode & Constants.SLOT_MAX);\\n newNode = newNode >> Constants.SLOT_WIDTH;\\n }\\n return sum;\\n }\\n }\\n\\n /// @notice Pick a slot in `node` that corresponds to `index`.\\n /// Treats the node like an array of virtual stakers,\\n /// the number of virtual stakers in each slot corresponding to its weight,\\n /// and picks which slot contains the `index`th virtual staker.\\n ///\\n /// @dev Requires that `index` be lower than `sumWeight(node)`.\\n /// However, this is not enforced for performance reasons.\\n /// If `index` exceeds the permitted range,\\n /// `pickWeightedSlot()` returns the rightmost slot\\n /// and an excessively high `newIndex`.\\n ///\\n /// @return slot The slot of `node` containing the `index`th virtual staker.\\n ///\\n /// @return newIndex The index of the `index`th virtual staker of `node`\\n /// within the returned slot.\\n function pickWeightedSlot(uint256 node, uint256 index)\\n internal\\n pure\\n returns (uint256 slot, uint256 newIndex)\\n {\\n unchecked {\\n newIndex = index;\\n uint256 newNode = node;\\n uint256 currentSlotWeight = newNode & Constants.SLOT_MAX;\\n while (newIndex >= currentSlotWeight) {\\n newIndex -= currentSlotWeight;\\n slot++;\\n newNode = newNode >> Constants.SLOT_WIDTH;\\n currentSlotWeight = newNode & Constants.SLOT_MAX;\\n }\\n return (slot, newIndex);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa7fb1c9c9789f30493e9a40e24a24f46875dc5e7630b4f67478167759f6d1882\"},\"@keep-network/sortition-pools/contracts/Chaosnet.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\n/// @title Chaosnet\\n/// @notice This is a beta staker program for stakers willing to go the extra\\n/// mile with monitoring, share their logs with the dev team, and allow to more\\n/// carefully monitor the bootstrapping network. As the network matures, the\\n/// beta program will be ended.\\ncontract Chaosnet {\\n /// @notice Indicates if the chaosnet is active. The chaosnet is active\\n /// after the contract deployment and can be ended with a call to\\n /// `deactivateChaosnet()`. Once deactivated chaosnet can not be activated\\n /// again.\\n bool public isChaosnetActive;\\n\\n /// @notice Indicates if the given operator is a beta operator for chaosnet.\\n mapping(address => bool) public isBetaOperator;\\n\\n /// @notice Address controlling chaosnet status and beta operator addresses.\\n address public chaosnetOwner;\\n\\n event BetaOperatorsAdded(address[] operators);\\n\\n event ChaosnetOwnerRoleTransferred(\\n address oldChaosnetOwner,\\n address newChaosnetOwner\\n );\\n\\n event ChaosnetDeactivated();\\n\\n constructor() {\\n _transferChaosnetOwner(msg.sender);\\n isChaosnetActive = true;\\n }\\n\\n modifier onlyChaosnetOwner() {\\n require(msg.sender == chaosnetOwner, \\\"Not the chaosnet owner\\\");\\n _;\\n }\\n\\n modifier onlyOnChaosnet() {\\n require(isChaosnetActive, \\\"Chaosnet is not active\\\");\\n _;\\n }\\n\\n /// @notice Adds beta operator to chaosnet. Can be called only by the\\n /// chaosnet owner when the chaosnet is active. Once the operator is added\\n /// as a beta operator, it can not be removed.\\n function addBetaOperators(address[] calldata operators)\\n public\\n onlyOnChaosnet\\n onlyChaosnetOwner\\n {\\n for (uint256 i = 0; i < operators.length; i++) {\\n isBetaOperator[operators[i]] = true;\\n }\\n\\n emit BetaOperatorsAdded(operators);\\n }\\n\\n /// @notice Deactivates the chaosnet. Can be called only by the chaosnet\\n /// owner. Once deactivated chaosnet can not be activated again.\\n function deactivateChaosnet() public onlyOnChaosnet onlyChaosnetOwner {\\n isChaosnetActive = false;\\n emit ChaosnetDeactivated();\\n }\\n\\n /// @notice Transfers the chaosnet owner role to another non-zero address.\\n function transferChaosnetOwnerRole(address newChaosnetOwner)\\n public\\n onlyChaosnetOwner\\n {\\n require(\\n newChaosnetOwner != address(0),\\n \\\"New chaosnet owner must not be zero address\\\"\\n );\\n _transferChaosnetOwner(newChaosnetOwner);\\n }\\n\\n function _transferChaosnetOwner(address newChaosnetOwner) internal {\\n address oldChaosnetOwner = chaosnetOwner;\\n chaosnetOwner = newChaosnetOwner;\\n emit ChaosnetOwnerRoleTransferred(oldChaosnetOwner, newChaosnetOwner);\\n }\\n}\\n\",\"keccak256\":\"0xeaf7bdd5626f88c329793a012621039692ce1b6e1f13013997ddb13d7e3032df\"},\"@keep-network/sortition-pools/contracts/Constants.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nlibrary Constants {\\n ////////////////////////////////////////////////////////////////////////////\\n // Parameters for configuration\\n\\n // How many bits a position uses per level of the tree;\\n // each branch of the tree contains 2**SLOT_BITS slots.\\n uint256 constant SLOT_BITS = 3;\\n uint256 constant LEVELS = 7;\\n ////////////////////////////////////////////////////////////////////////////\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // Derived constants, do not touch\\n uint256 constant SLOT_COUNT = 2**SLOT_BITS;\\n uint256 constant SLOT_WIDTH = 256 / SLOT_COUNT;\\n uint256 constant LAST_SLOT = SLOT_COUNT - 1;\\n uint256 constant SLOT_MAX = (2**SLOT_WIDTH) - 1;\\n uint256 constant POOL_CAPACITY = SLOT_COUNT**LEVELS;\\n\\n uint256 constant ID_WIDTH = SLOT_WIDTH;\\n uint256 constant ID_MAX = SLOT_MAX;\\n\\n uint256 constant BLOCKHEIGHT_WIDTH = 96 - ID_WIDTH;\\n uint256 constant BLOCKHEIGHT_MAX = (2**BLOCKHEIGHT_WIDTH) - 1;\\n\\n uint256 constant SLOT_POINTER_MAX = (2**SLOT_BITS) - 1;\\n uint256 constant LEAF_FLAG = 1 << 255;\\n\\n uint256 constant WEIGHT_WIDTH = 256 / SLOT_COUNT;\\n ////////////////////////////////////////////////////////////////////////////\\n}\\n\",\"keccak256\":\"0xaef690ced707935745ff1482b7bb9bd9eb77bf6a39c717465e64cf12db8a7d39\"},\"@keep-network/sortition-pools/contracts/Leaf.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary Leaf {\\n function make(\\n address _operator,\\n uint256 _creationBlock,\\n uint256 _id\\n ) internal pure returns (uint256) {\\n assert(_creationBlock <= type(uint64).max);\\n assert(_id <= type(uint32).max);\\n // Converting a bytesX type into a larger type\\n // adds zero bytes on the right.\\n uint256 op = uint256(bytes32(bytes20(_operator)));\\n // Bitwise AND the id to erase\\n // all but the 32 least significant bits\\n uint256 uid = _id & Constants.ID_MAX;\\n // Erase all but the 64 least significant bits,\\n // then shift left by 32 bits to make room for the id\\n uint256 cb = (_creationBlock & Constants.BLOCKHEIGHT_MAX) <<\\n Constants.ID_WIDTH;\\n // Bitwise OR them all together to get\\n // [address operator || uint64 creationBlock || uint32 id]\\n return (op | cb | uid);\\n }\\n\\n function operator(uint256 leaf) internal pure returns (address) {\\n // Converting a bytesX type into a smaller type\\n // truncates it on the right.\\n return address(bytes20(bytes32(leaf)));\\n }\\n\\n /// @notice Return the block number the leaf was created in.\\n function creationBlock(uint256 leaf) internal pure returns (uint256) {\\n return ((leaf >> Constants.ID_WIDTH) & Constants.BLOCKHEIGHT_MAX);\\n }\\n\\n function id(uint256 leaf) internal pure returns (uint32) {\\n // Id is stored in the 32 least significant bits.\\n // Bitwise AND ensures that we only get the contents of those bits.\\n return uint32(leaf & Constants.ID_MAX);\\n }\\n}\\n\",\"keccak256\":\"0xbd107a1a43e48884885e5e966ffcbcd8fa5e89863715d717bb4006e9f89cdc2b\"},\"@keep-network/sortition-pools/contracts/Position.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary Position {\\n // Return the last 3 bits of a position number,\\n // corresponding to its slot in its parent\\n function slot(uint256 a) internal pure returns (uint256) {\\n return a & Constants.SLOT_POINTER_MAX;\\n }\\n\\n // Return the parent of a position number\\n function parent(uint256 a) internal pure returns (uint256) {\\n return a >> Constants.SLOT_BITS;\\n }\\n\\n // Return the location of the child of a at the given slot\\n function child(uint256 a, uint256 s) internal pure returns (uint256) {\\n return (a << Constants.SLOT_BITS) | (s & Constants.SLOT_POINTER_MAX); // slot(s)\\n }\\n\\n // Return the uint p as a flagged position uint:\\n // the least significant 21 bits contain the position\\n // and the 22nd bit is set as a flag\\n // to distinguish the position 0x000000 from an empty field.\\n function setFlag(uint256 p) internal pure returns (uint256) {\\n return p | Constants.LEAF_FLAG;\\n }\\n\\n // Turn a flagged position into an unflagged position\\n // by removing the flag at the 22nd least significant bit.\\n //\\n // We shouldn't _actually_ need this\\n // as all position-manipulating code should ignore non-position bits anyway\\n // but it's cheap to call so might as well do it.\\n function unsetFlag(uint256 p) internal pure returns (uint256) {\\n return p & (~Constants.LEAF_FLAG);\\n }\\n}\\n\",\"keccak256\":\"0xd3a927908080ac21353a92a6bce3d69e94a5c30f6b51f16b271b6cc679f110e2\"},\"@keep-network/sortition-pools/contracts/RNG.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Leaf.sol\\\";\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary RNG {\\n /// @notice Get an index in the range `[0 .. range-1]`\\n /// and the new state of the RNG,\\n /// using the provided `state` of the RNG.\\n ///\\n /// @param range The upper bound of the index, exclusive.\\n ///\\n /// @param state The previous state of the RNG.\\n /// The initial state needs to be obtained\\n /// from a trusted randomness oracle (the random beacon),\\n /// or from a chain of earlier calls to `RNG.getIndex()`\\n /// on an originally trusted seed.\\n ///\\n /// @dev Calculates the number of bits required for the desired range,\\n /// takes the least significant bits of `state`\\n /// and checks if the obtained index is within the desired range.\\n /// The original state is hashed with `keccak256` to get a new state.\\n /// If the index is outside the range,\\n /// the function retries until it gets a suitable index.\\n ///\\n /// @return index A random integer between `0` and `range - 1`, inclusive.\\n ///\\n /// @return newState The new state of the RNG.\\n /// When `getIndex()` is called one or more times,\\n /// care must be taken to always use the output `state`\\n /// of the most recent call as the input `state` of a subsequent call.\\n /// At the end of a transaction calling `RNG.getIndex()`,\\n /// the previous stored state must be overwritten with the latest output.\\n function getIndex(\\n uint256 range,\\n bytes32 state,\\n uint256 bits\\n ) internal view returns (uint256, bytes32) {\\n bool found = false;\\n uint256 index = 0;\\n bytes32 newState = state;\\n while (!found) {\\n index = truncate(bits, uint256(newState));\\n newState = keccak256(abi.encodePacked(newState, address(this)));\\n if (index < range) {\\n found = true;\\n }\\n }\\n return (index, newState);\\n }\\n\\n /// @notice Calculate how many bits are required\\n /// for an index in the range `[0 .. range-1]`.\\n ///\\n /// @param range The upper bound of the desired range, exclusive.\\n ///\\n /// @return uint The smallest number of bits\\n /// that can contain the number `range-1`.\\n function bitsRequired(uint256 range) internal pure returns (uint256) {\\n unchecked {\\n if (range == 1) {\\n return 0;\\n }\\n\\n uint256 bits = Constants.WEIGHT_WIDTH - 1;\\n\\n // Left shift by `bits`,\\n // so we have a 1 in the (bits + 1)th least significant bit\\n // and 0 in other bits.\\n // If this number is equal or greater than `range`,\\n // the range [0, range-1] fits in `bits` bits.\\n //\\n // Because we loop from high bits to low bits,\\n // we find the highest number of bits that doesn't fit the range,\\n // and return that number + 1.\\n while (1 << bits >= range) {\\n bits--;\\n }\\n\\n return bits + 1;\\n }\\n }\\n\\n /// @notice Truncate `input` to the `bits` least significant bits.\\n function truncate(uint256 bits, uint256 input)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return input & ((1 << bits) - 1);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x67f87f589cd5123ffa32f883ea2f09b0e56258508bae82b8c655b3c27c71eb5e\"},\"@keep-network/sortition-pools/contracts/Rewards.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\n/// @title Rewards\\n/// @notice Rewards are allocated proportionally to operators\\n/// present in the pool at payout based on their weight in the pool.\\n///\\n/// To facilitate this, we use a global accumulator value\\n/// to track the total rewards one unit of weight would've earned\\n/// since the creation of the pool.\\n///\\n/// Whenever a reward is paid, the accumulator is increased\\n/// by the size of the reward divided by the total weight\\n/// of all eligible operators in the pool.\\n///\\n/// Each operator has an individual accumulator value,\\n/// set to equal the global accumulator when the operator joins the pool.\\n/// This accumulator reflects the amount of rewards\\n/// that have already been accounted for with that operator.\\n///\\n/// Whenever an operator's weight in the pool changes,\\n/// we can update the amount of rewards the operator has earned\\n/// by subtracting the operator's accumulator from the global accumulator.\\n/// This gives us the amount of rewards one unit of weight has earned\\n/// since the last time the operator's rewards have been updated.\\n/// Then we multiply that by the operator's previous (pre-change) weight\\n/// to determine how much rewards in total the operator has earned,\\n/// and add this to the operator's earned rewards.\\n/// Finally, we set the operator's accumulator to the global accumulator value.\\ncontract Rewards {\\n struct OperatorRewards {\\n // The state of the global accumulator\\n // when the operator's rewards were last updated\\n uint96 accumulated;\\n // The amount of rewards collected by the operator after the latest update.\\n // The amount the operator could withdraw may equal `available`\\n // or it may be greater, if more rewards have been paid in since then.\\n // To evaulate the most recent amount including rewards potentially paid\\n // since the last update, use `availableRewards` function.\\n uint96 available;\\n // If nonzero, the operator is ineligible for rewards\\n // and may only re-enable rewards after the specified timestamp.\\n // XXX: unsigned 32-bit integer unix seconds, will break around 2106\\n uint32 ineligibleUntil;\\n // Locally cached weight of the operator,\\n // used to reduce the cost of setting operators ineligible.\\n uint32 weight;\\n }\\n\\n // The global accumulator of how much rewards\\n // a hypothetical operator of weight 1 would have earned\\n // since the creation of the pool.\\n uint96 internal globalRewardAccumulator;\\n // If the amount of reward tokens paid in\\n // does not divide cleanly by pool weight,\\n // the difference is recorded as rounding dust\\n // and added to the next reward.\\n uint96 internal rewardRoundingDust;\\n\\n // The amount of rewards that would've been earned by ineligible operators\\n // had they not been ineligible.\\n uint96 public ineligibleEarnedRewards;\\n\\n // Ineligibility times are calculated from this offset,\\n // set at contract creation.\\n uint256 internal immutable ineligibleOffsetStart;\\n\\n mapping(uint32 => OperatorRewards) internal operatorRewards;\\n\\n constructor() {\\n // solhint-disable-next-line not-rely-on-time\\n ineligibleOffsetStart = block.timestamp;\\n }\\n\\n /// @notice Return whether the operator is eligible for rewards or not.\\n function isEligibleForRewards(uint32 operator) internal view returns (bool) {\\n return operatorRewards[operator].ineligibleUntil == 0;\\n }\\n\\n /// @notice Return the time the operator's reward eligibility can be restored.\\n function rewardsEligibilityRestorableAt(uint32 operator)\\n internal\\n view\\n returns (uint256)\\n {\\n uint32 until = operatorRewards[operator].ineligibleUntil;\\n require(until != 0, \\\"Operator already eligible\\\");\\n return (uint256(until) + ineligibleOffsetStart);\\n }\\n\\n /// @notice Return whether the operator is able to restore their eligibility\\n /// for rewards right away.\\n function canRestoreRewardEligibility(uint32 operator)\\n internal\\n view\\n returns (bool)\\n {\\n // solhint-disable-next-line not-rely-on-time\\n return rewardsEligibilityRestorableAt(operator) <= block.timestamp;\\n }\\n\\n /// @notice Internal function for updating the global state of rewards.\\n function addRewards(uint96 rewardAmount, uint32 currentPoolWeight) internal {\\n require(currentPoolWeight > 0, \\\"No recipients in pool\\\");\\n\\n uint96 totalAmount = rewardAmount + rewardRoundingDust;\\n uint96 perWeightReward = totalAmount / currentPoolWeight;\\n uint96 newRoundingDust = totalAmount % currentPoolWeight;\\n\\n globalRewardAccumulator += perWeightReward;\\n rewardRoundingDust = newRoundingDust;\\n }\\n\\n /// @notice Internal function for updating the operator's reward state.\\n function updateOperatorRewards(uint32 operator, uint32 newWeight) internal {\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n if (o.ineligibleUntil == 0) {\\n // If operator is not ineligible, update their earned rewards\\n o.available += accruedRewards;\\n } else {\\n // If ineligible, put the rewards into the ineligible pot\\n ineligibleEarnedRewards += accruedRewards;\\n }\\n // In any case, update their accumulator and weight\\n o.accumulated = acc;\\n o.weight = newWeight;\\n operatorRewards[operator] = o;\\n }\\n\\n /// @notice Set the amount of withdrawable tokens to zero\\n /// and return the previous withdrawable amount.\\n /// @dev Does not update the withdrawable amount,\\n /// but should usually be accompanied by an update.\\n function withdrawOperatorRewards(uint32 operator)\\n internal\\n returns (uint96 withdrawable)\\n {\\n OperatorRewards storage o = operatorRewards[operator];\\n withdrawable = o.available;\\n o.available = 0;\\n }\\n\\n /// @notice Set the amount of ineligible-earned tokens to zero\\n /// and return the previous amount.\\n function withdrawIneligibleRewards() internal returns (uint96 withdrawable) {\\n withdrawable = ineligibleEarnedRewards;\\n ineligibleEarnedRewards = 0;\\n }\\n\\n /// @notice Set the given operators as ineligible for rewards.\\n /// The operators can restore their eligibility at the given time.\\n function setIneligible(uint32[] memory operators, uint256 until) internal {\\n OperatorRewards memory o = OperatorRewards(0, 0, 0, 0);\\n uint96 globalAcc = globalRewardAccumulator;\\n uint96 accrued = 0;\\n // Record ineligibility as seconds after contract creation\\n uint32 _until = uint32(until - ineligibleOffsetStart);\\n\\n for (uint256 i = 0; i < operators.length; i++) {\\n uint32 operator = operators[i];\\n OperatorRewards storage r = operatorRewards[operator];\\n o.available = r.available;\\n o.accumulated = r.accumulated;\\n o.ineligibleUntil = r.ineligibleUntil;\\n o.weight = r.weight;\\n\\n if (o.ineligibleUntil != 0) {\\n // If operator is already ineligible,\\n // don't earn rewards or shorten its ineligibility\\n if (o.ineligibleUntil < _until) {\\n o.ineligibleUntil = _until;\\n }\\n } else {\\n // The operator becomes ineligible -> earn rewards\\n o.ineligibleUntil = _until;\\n accrued = (globalAcc - o.accumulated) * uint96(o.weight);\\n o.available += accrued;\\n }\\n o.accumulated = globalAcc;\\n\\n r.available = o.available;\\n r.accumulated = o.accumulated;\\n r.ineligibleUntil = o.ineligibleUntil;\\n r.weight = o.weight;\\n }\\n }\\n\\n /// @notice Restore the given operator's eligibility for rewards.\\n function restoreEligibility(uint32 operator) internal {\\n // solhint-disable-next-line not-rely-on-time\\n require(canRestoreRewardEligibility(operator), \\\"Operator still ineligible\\\");\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n ineligibleEarnedRewards += accruedRewards;\\n o.accumulated = acc;\\n o.ineligibleUntil = 0;\\n operatorRewards[operator] = o;\\n }\\n\\n /// @notice Returns the amount of rewards currently available for withdrawal\\n /// for the given operator.\\n function availableRewards(uint32 operator) internal view returns (uint96) {\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n if (o.ineligibleUntil == 0) {\\n // If operator is not ineligible, calculate newly accrued rewards and add\\n // them to the available ones, calculated during the last update.\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n return o.available + accruedRewards;\\n } else {\\n // If ineligible, return only the rewards calculated during the last\\n // update.\\n return o.available;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3a10abb408b44335a092387b2c7ee01db3b27997f1f2c888d9b7a2d92934c4e2\"},\"@keep-network/sortition-pools/contracts/SortitionPool.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./RNG.sol\\\";\\nimport \\\"./SortitionTree.sol\\\";\\nimport \\\"./Rewards.sol\\\";\\nimport \\\"./Chaosnet.sol\\\";\\n\\n/// @title Sortition Pool\\n/// @notice A logarithmic data structure used to store the pool of eligible\\n/// operators weighted by their stakes. It allows to select a group of operators\\n/// based on the provided pseudo-random seed.\\ncontract SortitionPool is\\n SortitionTree,\\n Rewards,\\n Ownable,\\n Chaosnet,\\n IReceiveApproval\\n{\\n using Branch for uint256;\\n using Leaf for uint256;\\n using Position for uint256;\\n\\n IERC20WithPermit public immutable rewardToken;\\n\\n uint256 public immutable poolWeightDivisor;\\n\\n bool public isLocked;\\n\\n event IneligibleForRewards(uint32[] ids, uint256 until);\\n\\n event RewardEligibilityRestored(address indexed operator, uint32 indexed id);\\n\\n /// @notice Reverts if called while pool is locked.\\n modifier onlyUnlocked() {\\n require(!isLocked, \\\"Sortition pool locked\\\");\\n _;\\n }\\n\\n /// @notice Reverts if called while pool is unlocked.\\n modifier onlyLocked() {\\n require(isLocked, \\\"Sortition pool unlocked\\\");\\n _;\\n }\\n\\n constructor(IERC20WithPermit _rewardToken, uint256 _poolWeightDivisor) {\\n rewardToken = _rewardToken;\\n poolWeightDivisor = _poolWeightDivisor;\\n }\\n\\n function receiveApproval(\\n address sender,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(token == address(rewardToken), \\\"Unsupported token\\\");\\n rewardToken.transferFrom(sender, address(this), amount);\\n Rewards.addRewards(uint96(amount), uint32(root.sumWeight()));\\n }\\n\\n /// @notice Withdraws all available rewards for the given operator to the\\n /// given beneficiary.\\n /// @dev Can be called only be the owner. Does not validate if the provided\\n /// beneficiary is associated with the provided operator - this needs to\\n /// be done by the owner calling this function.\\n /// @return The amount of rewards withdrawn in this call.\\n function withdrawRewards(address operator, address beneficiary)\\n public\\n onlyOwner\\n returns (uint96)\\n {\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(getPoolWeight(operator)));\\n uint96 earned = Rewards.withdrawOperatorRewards(id);\\n rewardToken.transfer(beneficiary, uint256(earned));\\n return earned;\\n }\\n\\n /// @notice Withdraws rewards not allocated to operators marked as ineligible\\n /// to the given recipient address.\\n /// @dev Can be called only by the owner.\\n function withdrawIneligible(address recipient) public onlyOwner {\\n uint96 earned = Rewards.withdrawIneligibleRewards();\\n rewardToken.transfer(recipient, uint256(earned));\\n }\\n\\n /// @notice Locks the sortition pool. In locked state, members cannot be\\n /// inserted and removed from the pool. Members statuses cannot\\n /// be updated as well.\\n /// @dev Can be called only by the contract owner.\\n function lock() public onlyOwner {\\n isLocked = true;\\n }\\n\\n /// @notice Unlocks the sortition pool. Removes all restrictions set by\\n /// the `lock` method.\\n /// @dev Can be called only by the contract owner.\\n function unlock() public onlyOwner {\\n isLocked = false;\\n }\\n\\n /// @notice Inserts an operator to the pool. Reverts if the operator is\\n /// already present. Reverts if the operator is not eligible because of their\\n /// authorized stake. Reverts if the chaosnet is active and the operator is\\n /// not a beta operator.\\n /// @dev Can be called only by the contract owner.\\n /// @param operator Address of the inserted operator.\\n /// @param authorizedStake Inserted operator's authorized stake for the application.\\n function insertOperator(address operator, uint256 authorizedStake)\\n public\\n onlyOwner\\n onlyUnlocked\\n {\\n uint256 weight = getWeight(authorizedStake);\\n require(weight > 0, \\\"Operator not eligible\\\");\\n\\n if (isChaosnetActive) {\\n require(isBetaOperator[operator], \\\"Not beta operator for chaosnet\\\");\\n }\\n\\n _insertOperator(operator, weight);\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(weight));\\n }\\n\\n /// @notice Update the operator's weight if present and eligible,\\n /// or remove from the pool if present and ineligible.\\n /// @dev Can be called only by the contract owner.\\n /// @param operator Address of the updated operator.\\n /// @param authorizedStake Operator's authorized stake for the application.\\n function updateOperatorStatus(address operator, uint256 authorizedStake)\\n public\\n onlyOwner\\n onlyUnlocked\\n {\\n uint256 weight = getWeight(authorizedStake);\\n\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(weight));\\n\\n if (weight == 0) {\\n _removeOperator(operator);\\n } else {\\n updateOperator(operator, weight);\\n }\\n }\\n\\n /// @notice Set the given operators as ineligible for rewards.\\n /// The operators can restore their eligibility at the given time.\\n function setRewardIneligibility(uint32[] calldata operators, uint256 until)\\n public\\n onlyOwner\\n {\\n Rewards.setIneligible(operators, until);\\n emit IneligibleForRewards(operators, until);\\n }\\n\\n /// @notice Restores reward eligibility for the operator.\\n function restoreRewardEligibility(address operator) public {\\n uint32 id = getOperatorID(operator);\\n Rewards.restoreEligibility(id);\\n emit RewardEligibilityRestored(operator, id);\\n }\\n\\n /// @notice Returns whether the operator is eligible for rewards or not.\\n function isEligibleForRewards(address operator) public view returns (bool) {\\n uint32 id = getOperatorID(operator);\\n return Rewards.isEligibleForRewards(id);\\n }\\n\\n /// @notice Returns the time the operator's reward eligibility can be restored.\\n function rewardsEligibilityRestorableAt(address operator)\\n public\\n view\\n returns (uint256)\\n {\\n uint32 id = getOperatorID(operator);\\n return Rewards.rewardsEligibilityRestorableAt(id);\\n }\\n\\n /// @notice Returns whether the operator is able to restore their eligibility\\n /// for rewards right away.\\n function canRestoreRewardEligibility(address operator)\\n public\\n view\\n returns (bool)\\n {\\n uint32 id = getOperatorID(operator);\\n return Rewards.canRestoreRewardEligibility(id);\\n }\\n\\n /// @notice Returns the amount of rewards withdrawable for the given operator.\\n function getAvailableRewards(address operator) public view returns (uint96) {\\n uint32 id = getOperatorID(operator);\\n return availableRewards(id);\\n }\\n\\n /// @notice Return whether the operator is present in the pool.\\n function isOperatorInPool(address operator) public view returns (bool) {\\n return getFlaggedLeafPosition(operator) != 0;\\n }\\n\\n /// @notice Return whether the operator's weight in the pool\\n /// matches their eligible weight.\\n function isOperatorUpToDate(address operator, uint256 authorizedStake)\\n public\\n view\\n returns (bool)\\n {\\n return getWeight(authorizedStake) == getPoolWeight(operator);\\n }\\n\\n /// @notice Return the weight of the operator in the pool,\\n /// which may or may not be out of date.\\n function getPoolWeight(address operator) public view returns (uint256) {\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n if (flaggedPosition == 0) {\\n return 0;\\n } else {\\n uint256 leafPosition = flaggedPosition.unsetFlag();\\n uint256 leafWeight = getLeafWeight(leafPosition);\\n return leafWeight;\\n }\\n }\\n\\n /// @notice Selects a new group of operators of the provided size based on\\n /// the provided pseudo-random seed. At least one operator has to be\\n /// registered in the pool, otherwise the function fails reverting the\\n /// transaction.\\n /// @param groupSize Size of the requested group\\n /// @param seed Pseudo-random number used to select operators to group\\n /// @return selected Members of the selected group\\n function selectGroup(uint256 groupSize, bytes32 seed)\\n public\\n view\\n onlyLocked\\n returns (uint32[] memory)\\n {\\n uint256 _root = root;\\n\\n bytes32 rngState = seed;\\n uint256 rngRange = _root.sumWeight();\\n require(rngRange > 0, \\\"Not enough operators in pool\\\");\\n uint256 currentIndex;\\n\\n uint256 bits = RNG.bitsRequired(rngRange);\\n\\n uint32[] memory selected = new uint32[](groupSize);\\n\\n for (uint256 i = 0; i < groupSize; i++) {\\n (currentIndex, rngState) = RNG.getIndex(rngRange, rngState, bits);\\n\\n uint256 leafPosition = pickWeightedLeaf(currentIndex, _root);\\n\\n uint256 leaf = leaves[leafPosition];\\n selected[i] = leaf.id();\\n }\\n return selected;\\n }\\n\\n function getWeight(uint256 authorization) internal view returns (uint256) {\\n return authorization / poolWeightDivisor;\\n }\\n}\\n\",\"keccak256\":\"0xab42e7c5b1828f42a73f699eb2dc96d4f793572a6323b8b1fbd7c5e0c065bda7\"},\"@keep-network/sortition-pools/contracts/SortitionTree.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Branch.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Leaf.sol\\\";\\nimport \\\"./Constants.sol\\\";\\n\\ncontract SortitionTree {\\n using Branch for uint256;\\n using Position for uint256;\\n using Leaf for uint256;\\n\\n // implicit tree\\n // root 8\\n // level2 64\\n // level3 512\\n // level4 4k\\n // level5 32k\\n // level6 256k\\n // level7 2M\\n uint256 internal root;\\n\\n // A 2-index mapping from layer => (index (0-index) => branch). For example,\\n // to access the 6th branch in the 2nd layer (right below the root node; the\\n // first branch layer), call branches[2][5]. Mappings are used in place of\\n // arrays for efficiency. The root is the first layer, the branches occupy\\n // layers 2 through 7, and layer 8 is for the leaves. Following this\\n // convention, the first index in `branches` is `2`, and the last index is\\n // `7`.\\n mapping(uint256 => mapping(uint256 => uint256)) internal branches;\\n\\n // A 0-index mapping from index => leaf, acting as an array. For example, to\\n // access the 42nd leaf, call leaves[41].\\n mapping(uint256 => uint256) internal leaves;\\n\\n // the flagged (see setFlag() and unsetFlag() in Position.sol) positions\\n // of all operators present in the pool\\n mapping(address => uint256) internal flaggedLeafPosition;\\n\\n // the leaf after the rightmost occupied leaf of each stack\\n uint256 internal rightmostLeaf;\\n\\n // the empty leaves in each stack\\n // between 0 and the rightmost occupied leaf\\n uint256[] internal emptyLeaves;\\n\\n // Each operator has an uint32 ID number\\n // which is allocated when they first join the pool\\n // and remains unchanged even if they leave and rejoin the pool.\\n mapping(address => uint32) internal operatorID;\\n\\n // The idAddress array records the address corresponding to each ID number.\\n // The ID number 0 is initialized with a zero address and is not used.\\n address[] internal idAddress;\\n\\n constructor() {\\n root = 0;\\n rightmostLeaf = 0;\\n idAddress.push();\\n }\\n\\n /// @notice Return the ID number of the given operator address. An ID number\\n /// of 0 means the operator has not been allocated an ID number yet.\\n /// @param operator Address of the operator.\\n /// @return the ID number of the given operator address\\n function getOperatorID(address operator) public view returns (uint32) {\\n return operatorID[operator];\\n }\\n\\n /// @notice Get the operator address corresponding to the given ID number. A\\n /// zero address means the ID number has not been allocated yet.\\n /// @param id ID of the operator\\n /// @return the address of the operator\\n function getIDOperator(uint32 id) public view returns (address) {\\n return idAddress.length > id ? idAddress[id] : address(0);\\n }\\n\\n /// @notice Gets the operator addresses corresponding to the given ID\\n /// numbers. A zero address means the ID number has not been allocated yet.\\n /// This function works just like getIDOperator except that it allows to fetch\\n /// operator addresses for multiple IDs in one call.\\n /// @param ids the array of the operator ids\\n /// @return an array of the associated operator addresses\\n function getIDOperators(uint32[] calldata ids)\\n public\\n view\\n returns (address[] memory)\\n {\\n uint256 idCount = idAddress.length;\\n\\n address[] memory operators = new address[](ids.length);\\n for (uint256 i = 0; i < ids.length; i++) {\\n uint32 id = ids[i];\\n operators[i] = idCount > id ? idAddress[id] : address(0);\\n }\\n return operators;\\n }\\n\\n /// @notice Checks if operator is already registered in the pool.\\n /// @param operator the address of the operator\\n /// @return whether or not the operator is already registered in the pool\\n function isOperatorRegistered(address operator) public view returns (bool) {\\n return getFlaggedLeafPosition(operator) != 0;\\n }\\n\\n /// @notice Sum the number of operators in each trunk.\\n /// @return the number of operators in the pool\\n function operatorsInPool() public view returns (uint256) {\\n // Get the number of leaves that might be occupied;\\n // if `rightmostLeaf` equals `firstLeaf()` the tree must be empty,\\n // otherwise the difference between these numbers\\n // gives the number of leaves that may be occupied.\\n uint256 nPossiblyUsedLeaves = rightmostLeaf;\\n // Get the number of empty leaves\\n // not accounted for by the `rightmostLeaf`\\n uint256 nEmptyLeaves = emptyLeaves.length;\\n\\n return (nPossiblyUsedLeaves - nEmptyLeaves);\\n }\\n\\n /// @notice Convenience method to return the total weight of the pool\\n /// @return the total weight of the pool\\n function totalWeight() public view returns (uint256) {\\n return root.sumWeight();\\n }\\n\\n /// @notice Give the operator a new ID number.\\n /// Does not check if the operator already has an ID number.\\n /// @param operator the address of the operator\\n /// @return a new ID for that operator\\n function allocateOperatorID(address operator) internal returns (uint256) {\\n uint256 id = idAddress.length;\\n\\n require(id <= type(uint32).max, \\\"Pool capacity exceeded\\\");\\n\\n operatorID[operator] = uint32(id);\\n idAddress.push(operator);\\n return id;\\n }\\n\\n /// @notice Inserts an operator into the sortition pool\\n /// @param operator the address of an operator to insert\\n /// @param weight how much weight that operator has in the pool\\n function _insertOperator(address operator, uint256 weight) internal {\\n require(\\n !isOperatorRegistered(operator),\\n \\\"Operator is already registered in the pool\\\"\\n );\\n\\n // Fetch the operator's ID, and if they don't have one, allocate them one.\\n uint256 id = getOperatorID(operator);\\n if (id == 0) {\\n id = allocateOperatorID(operator);\\n }\\n\\n // Determine which leaf to insert them into\\n uint256 position = getEmptyLeafPosition();\\n // Record the block the operator was inserted in\\n uint256 theLeaf = Leaf.make(operator, block.number, id);\\n\\n // Update the leaf, and propagate the weight changes all the way up to the\\n // root.\\n root = setLeaf(position, theLeaf, weight, root);\\n\\n // Without position flags,\\n // the position 0x000000 would be treated as empty\\n flaggedLeafPosition[operator] = position.setFlag();\\n }\\n\\n /// @notice Remove an operator (and their weight) from the pool.\\n /// @param operator the address of the operator to remove\\n function _removeOperator(address operator) internal {\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n require(flaggedPosition != 0, \\\"Operator is not registered in the pool\\\");\\n uint256 unflaggedPosition = flaggedPosition.unsetFlag();\\n\\n // Update the leaf, and propagate the weight changes all the way up to the\\n // root.\\n root = removeLeaf(unflaggedPosition, root);\\n removeLeafPositionRecord(operator);\\n }\\n\\n /// @notice Update an operator's weight in the pool.\\n /// @param operator the address of the operator to update\\n /// @param weight the new weight\\n function updateOperator(address operator, uint256 weight) internal {\\n require(\\n isOperatorRegistered(operator),\\n \\\"Operator is not registered in the pool\\\"\\n );\\n\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n uint256 unflaggedPosition = flaggedPosition.unsetFlag();\\n root = updateLeaf(unflaggedPosition, weight, root);\\n }\\n\\n /// @notice Helper method to remove a leaf position record for an operator.\\n /// @param operator the address of the operator to remove the record for\\n function removeLeafPositionRecord(address operator) internal {\\n flaggedLeafPosition[operator] = 0;\\n }\\n\\n /// @notice Removes the data and weight from a particular leaf.\\n /// @param position the leaf index to remove\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function removeLeaf(uint256 position, uint256 _root)\\n internal\\n returns (uint256)\\n {\\n uint256 rightmostSubOne = rightmostLeaf - 1;\\n bool isRightmost = position == rightmostSubOne;\\n\\n // Clears out the data in the leaf node, and then propagates the weight\\n // changes all the way up to the root.\\n uint256 newRoot = setLeaf(position, 0, 0, _root);\\n\\n // Infer if need to fall back on emptyLeaves yet\\n if (isRightmost) {\\n rightmostLeaf = rightmostSubOne;\\n } else {\\n emptyLeaves.push(position);\\n }\\n return newRoot;\\n }\\n\\n /// @notice Updates the tree to give a particular leaf a new weight.\\n /// @param position the index of the leaf to update\\n /// @param weight the new weight\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function updateLeaf(\\n uint256 position,\\n uint256 weight,\\n uint256 _root\\n ) internal returns (uint256) {\\n if (getLeafWeight(position) != weight) {\\n return updateTree(position, weight, _root);\\n } else {\\n return _root;\\n }\\n }\\n\\n /// @notice Places a leaf into a particular position, with a given weight and\\n /// propagates that change.\\n /// @param position the index to place the leaf in\\n /// @param theLeaf the new leaf to place in the position\\n /// @param leafWeight the weight of the leaf\\n /// @param _root the root containing the new leaf\\n /// @return the updated root node\\n function setLeaf(\\n uint256 position,\\n uint256 theLeaf,\\n uint256 leafWeight,\\n uint256 _root\\n ) internal returns (uint256) {\\n // set leaf\\n leaves[position] = theLeaf;\\n\\n return (updateTree(position, leafWeight, _root));\\n }\\n\\n /// @notice Propagates a weight change at a position through the tree,\\n /// eventually returning the updated root.\\n /// @param position the index of leaf to update\\n /// @param weight the new weight of the leaf\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function updateTree(\\n uint256 position,\\n uint256 weight,\\n uint256 _root\\n ) internal returns (uint256) {\\n uint256 childSlot;\\n uint256 treeNode;\\n uint256 newNode;\\n uint256 nodeWeight = weight;\\n\\n uint256 parent = position;\\n // set levels 7 to 2\\n for (uint256 level = Constants.LEVELS; level >= 2; level--) {\\n childSlot = parent.slot();\\n parent = parent.parent();\\n treeNode = branches[level][parent];\\n newNode = treeNode.setSlot(childSlot, nodeWeight);\\n branches[level][parent] = newNode;\\n nodeWeight = newNode.sumWeight();\\n }\\n\\n // set level Root\\n childSlot = parent.slot();\\n return _root.setSlot(childSlot, nodeWeight);\\n }\\n\\n /// @notice Retrieves the next available empty leaf position. Tries to fill\\n /// left to right first, ignoring leaf removals, and then fills\\n /// most-recent-removals first.\\n /// @return the position of the empty leaf\\n function getEmptyLeafPosition() internal returns (uint256) {\\n uint256 rLeaf = rightmostLeaf;\\n bool spaceOnRight = (rLeaf + 1) < Constants.POOL_CAPACITY;\\n if (spaceOnRight) {\\n rightmostLeaf = rLeaf + 1;\\n return rLeaf;\\n } else {\\n uint256 emptyLeafCount = emptyLeaves.length;\\n require(emptyLeafCount > 0, \\\"Pool is full\\\");\\n uint256 emptyLeaf = emptyLeaves[emptyLeafCount - 1];\\n emptyLeaves.pop();\\n return emptyLeaf;\\n }\\n }\\n\\n /// @notice Gets the flagged leaf position for an operator.\\n /// @param operator the address of the operator\\n /// @return the leaf position of that operator\\n function getFlaggedLeafPosition(address operator)\\n internal\\n view\\n returns (uint256)\\n {\\n return flaggedLeafPosition[operator];\\n }\\n\\n /// @notice Gets the weight of a leaf at a particular position.\\n /// @param position the index of the leaf\\n /// @return the weight of the leaf at that position\\n function getLeafWeight(uint256 position) internal view returns (uint256) {\\n uint256 slot = position.slot();\\n uint256 parent = position.parent();\\n\\n // A leaf's weight information is stored a 32-bit slot in the branch layer\\n // directly above the leaf layer. To access it, we calculate that slot and\\n // parent position, and always know the hard-coded layer index.\\n uint256 node = branches[Constants.LEVELS][parent];\\n return node.getSlot(slot);\\n }\\n\\n /// @notice Picks a leaf given a random index.\\n /// @param index a number in `[0, _root.totalWeight())` used to decide\\n /// between leaves\\n /// @param _root the root of the tree\\n function pickWeightedLeaf(uint256 index, uint256 _root)\\n internal\\n view\\n returns (uint256 leafPosition)\\n {\\n uint256 currentIndex = index;\\n uint256 currentNode = _root;\\n uint256 currentPosition = 0;\\n uint256 currentSlot;\\n\\n require(index < currentNode.sumWeight(), \\\"Index exceeds weight\\\");\\n\\n // get root slot\\n (currentSlot, currentIndex) = currentNode.pickWeightedSlot(currentIndex);\\n\\n // get slots from levels 2 to 7\\n for (uint256 level = 2; level <= Constants.LEVELS; level++) {\\n currentPosition = currentPosition.child(currentSlot);\\n currentNode = branches[level][currentPosition];\\n (currentSlot, currentIndex) = currentNode.pickWeightedSlot(currentIndex);\\n }\\n\\n // get leaf position\\n leafPosition = currentPosition.child(currentSlot);\\n }\\n}\\n\",\"keccak256\":\"0x51daeca62ef52be78a1a9de4d2a1c5900c873165f59eda14d5965d7d7da90a03\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0x6b9a5d35b744b25529a2856a8093e7c03fb35a34b1c4fb5499e560f8ade140da\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../StringsUpgradeable.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSAUpgradeable {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV // Deprecated in v4.8\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", StringsUpgradeable.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0x12f297cafe6e2847ae0378502f155654d0764b532a9873c8afe4350950fa7971\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.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 SafeCastUpgradeable {\\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\":\"0xcef50f95b43b038aa40aed25b62fc45906c681a5c1d504a4fdcf3bc6330a8d4b\",\"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/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n _nonReentrantBefore();\\n _;\\n _nonReentrantAfter();\\n }\\n\\n function _nonReentrantBefore() private {\\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n }\\n\\n function _nonReentrantAfter() private {\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x190dd6f8d592b7e4e930feb7f4313aeb8e1c4ad3154c27ce1cf6a512fc30d8cc\",\"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/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\",\"keccak256\":\"0xab28a56179c1db258c9bf5235b382698cb650debecb51b23d12be9e241374b68\",\"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/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/Math.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = Math.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, Math.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0xa4d1d62251f8574deb032a35fc948386a9b4de74b812d4f545a1ac120486b48a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV // Deprecated in v4.8\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0xda898fa084aa1ddfdb346e6a40459e00a59d87071cce7c315a46d648dd71d0ba\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"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\"},\"@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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"contracts/GovernanceUtils.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nlibrary GovernanceUtils {\\n /// @notice Reverts if the governance delay has not passed since\\n /// the change initiated time or if the change has not been\\n /// initiated.\\n /// @param changeInitiatedTimestamp The timestamp at which the change has\\n /// been initiated.\\n /// @param delay Governance delay.\\n function onlyAfterGovernanceDelay(\\n uint256 changeInitiatedTimestamp,\\n uint256 delay\\n ) internal view {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - changeInitiatedTimestamp >= delay,\\n \\\"Governance delay has not elapsed\\\"\\n );\\n }\\n\\n /// @notice Gets the time remaining until the governable parameter update\\n /// can be committed.\\n /// @param changeInitiatedTimestamp Timestamp indicating the beginning of\\n /// the change.\\n /// @param delay Governance delay.\\n /// @return Remaining time in seconds.\\n function getRemainingGovernanceDelay(\\n uint256 changeInitiatedTimestamp,\\n uint256 delay\\n ) internal view returns (uint256) {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n uint256 elapsed = block.timestamp - changeInitiatedTimestamp;\\n if (elapsed >= delay) {\\n return 0;\\n } else {\\n return delay - elapsed;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9d16501e1b7c368ced397fd2eff0ab1bd1db8d26cc3700d0b7740942ee3c3c31\",\"license\":\"GPL-3.0-only\"},\"contracts/bank/Bank.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IReceiveBalanceApproval.sol\\\";\\nimport \\\"../vault/IVault.sol\\\";\\n\\n/// @title Bitcoin Bank\\n/// @notice Bank is a central component tracking Bitcoin balances. Balances can\\n/// be transferred between balance owners, and balance owners can\\n/// approve their balances to be spent by others. Balances in the Bank\\n/// are updated for depositors who deposited their Bitcoin into the\\n/// Bridge and only the Bridge can increase balances.\\n/// @dev Bank is a governable contract and the Governance can upgrade the Bridge\\n/// address.\\ncontract Bank is Ownable {\\n address public bridge;\\n\\n /// @notice The balance of the given account in the Bank. Zero by default.\\n mapping(address => uint256) public balanceOf;\\n\\n /// @notice The remaining amount of balance a spender will be\\n /// allowed to transfer on behalf of an owner using\\n /// `transferBalanceFrom`. Zero by default.\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /// @notice Returns the current nonce for an EIP2612 permission for the\\n /// provided balance owner to protect against replay attacks. Used\\n /// to construct an EIP2612 signature provided to the `permit`\\n /// function.\\n mapping(address => uint256) public nonces;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns an EIP2612 Permit message hash. Used to construct\\n /// an EIP2612 signature provided to the `permit` function.\\n bytes32 public constant PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n event BalanceTransferred(\\n address indexed from,\\n address indexed to,\\n uint256 amount\\n );\\n\\n event BalanceApproved(\\n address indexed owner,\\n address indexed spender,\\n uint256 amount\\n );\\n\\n event BalanceIncreased(address indexed owner, uint256 amount);\\n\\n event BalanceDecreased(address indexed owner, uint256 amount);\\n\\n event BridgeUpdated(address newBridge);\\n\\n modifier onlyBridge() {\\n require(msg.sender == address(bridge), \\\"Caller is not the bridge\\\");\\n _;\\n }\\n\\n constructor() {\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Allows the Governance to upgrade the Bridge address.\\n /// @dev The function does not implement any governance delay and does not\\n /// check the status of the Bridge. The Governance implementation needs\\n /// to ensure all requirements for the upgrade are satisfied before\\n /// executing this function.\\n /// Requirements:\\n /// - The new Bridge address must not be zero.\\n /// @param _bridge The new Bridge address.\\n function updateBridge(address _bridge) external onlyOwner {\\n require(_bridge != address(0), \\\"Bridge address must not be 0x0\\\");\\n bridge = _bridge;\\n emit BridgeUpdated(_bridge);\\n }\\n\\n /// @notice Moves the given `amount` of balance from the caller to\\n /// `recipient`.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n /// @param recipient The recipient of the balance.\\n /// @param amount The amount of the balance transferred.\\n function transferBalance(address recipient, uint256 amount) external {\\n _transferBalance(msg.sender, recipient, amount);\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// balance. Does not allow updating an existing allowance to\\n /// a value that is non-zero to avoid someone using both the old and\\n /// the new allowance by unfortunate transaction ordering. To update\\n /// an allowance to a non-zero value please set it to zero first or\\n /// use `increaseBalanceAllowance` or `decreaseBalanceAllowance` for\\n /// an atomic update.\\n /// @dev If the `amount` is set to `type(uint256).max`,\\n /// `transferBalanceFrom` will not reduce an allowance.\\n /// @param spender The address that will be allowed to spend the balance.\\n /// @param amount The amount the spender is allowed to spend.\\n function approveBalance(address spender, uint256 amount) external {\\n require(\\n amount == 0 || allowance[msg.sender][spender] == 0,\\n \\\"Non-atomic allowance change not allowed\\\"\\n );\\n _approveBalance(msg.sender, spender, amount);\\n }\\n\\n /// @notice Sets the `amount` as an allowance of a smart contract `spender`\\n /// over the caller's balance and calls the `spender` via\\n /// `receiveBalanceApproval`.\\n /// @dev If the `amount` is set to `type(uint256).max`, the potential\\n /// `transferBalanceFrom` executed in `receiveBalanceApproval` of\\n /// `spender` will not reduce an allowance. Beware that changing an\\n /// allowance with this function brings the risk that `spender` may use\\n /// both the old and the new allowance by unfortunate transaction\\n /// ordering. Please use `increaseBalanceAllowance` and\\n /// `decreaseBalanceAllowance` to eliminate the risk.\\n /// @param spender The smart contract that will be allowed to spend the\\n /// balance.\\n /// @param amount The amount the spender contract is allowed to spend.\\n /// @param extraData Extra data passed to the `spender` contract via\\n /// `receiveBalanceApproval` call.\\n function approveBalanceAndCall(\\n address spender,\\n uint256 amount,\\n bytes calldata extraData\\n ) external {\\n _approveBalance(msg.sender, spender, amount);\\n IReceiveBalanceApproval(spender).receiveBalanceApproval(\\n msg.sender,\\n amount,\\n extraData\\n );\\n }\\n\\n /// @notice Atomically increases the caller's balance allowance granted to\\n /// `spender` by the given `addedValue`.\\n /// @param spender The spender address for which the allowance is increased.\\n /// @param addedValue The amount by which the allowance is increased.\\n function increaseBalanceAllowance(address spender, uint256 addedValue)\\n external\\n {\\n _approveBalance(\\n msg.sender,\\n spender,\\n allowance[msg.sender][spender] + addedValue\\n );\\n }\\n\\n /// @notice Atomically decreases the caller's balance allowance granted to\\n /// `spender` by the given `subtractedValue`.\\n /// @dev Requirements:\\n /// - `spender` must not be the zero address,\\n /// - the current allowance for `spender` must not be lower than\\n /// the `subtractedValue`.\\n /// @param spender The spender address for which the allowance is decreased.\\n /// @param subtractedValue The amount by which the allowance is decreased.\\n function decreaseBalanceAllowance(address spender, uint256 subtractedValue)\\n external\\n {\\n uint256 currentAllowance = allowance[msg.sender][spender];\\n require(\\n currentAllowance >= subtractedValue,\\n \\\"Can not decrease balance allowance below zero\\\"\\n );\\n unchecked {\\n _approveBalance(\\n msg.sender,\\n spender,\\n currentAllowance - subtractedValue\\n );\\n }\\n }\\n\\n /// @notice Moves `amount` of balance 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 /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have an allowance for `spender`'s balance of at\\n /// least `amount`.\\n /// @param spender The address from which the balance is transferred.\\n /// @param recipient The address to which the balance is transferred.\\n /// @param amount The amount of balance that is transferred.\\n function transferBalanceFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external {\\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 unchecked {\\n _approveBalance(spender, msg.sender, currentAllowance - amount);\\n }\\n }\\n _transferBalance(spender, recipient, amount);\\n }\\n\\n /// @notice An EIP2612 approval made with secp256k1 signature. Users can\\n /// authorize a transfer of their balance with a signature\\n /// conforming to the EIP712 standard, rather than an on-chain\\n /// transaction from their address. Anyone can submit this signature\\n /// on the user's behalf by calling the `permit` function, paying\\n /// gas fees, and possibly performing other actions in the same\\n /// 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 `transferBalanceFrom` will not\\n /// reduce an allowance. Beware that changing an allowance with this\\n /// function brings the risk that someone may use both the old and the\\n /// new allowance by unfortunate transaction ordering. Please use\\n /// `increaseBalanceAllowance` and `decreaseBalanceAllowance` to\\n /// eliminate the risk.\\n /// @param owner The balance owner who signed the permission.\\n /// @param spender The address that will be allowed to spend the balance.\\n /// @param amount The amount the spender is allowed to spend.\\n /// @param deadline The UNIX time until which the permit is valid.\\n /// @param v V part of the permit signature.\\n /// @param r R part of the permit signature.\\n /// @param s S part of the permit signature.\\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 /* 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 nonces[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 _approveBalance(owner, spender, amount);\\n }\\n\\n /// @notice Increases balances of the provided `recipients` by the provided\\n /// `amounts`. Can only be called by the Bridge.\\n /// @dev Requirements:\\n /// - length of `recipients` and `amounts` must be the same,\\n /// - none of `recipients` addresses must point to the Bank.\\n /// @param recipients Balance increase recipients.\\n /// @param amounts Amounts by which balances are increased.\\n function increaseBalances(\\n address[] calldata recipients,\\n uint256[] calldata amounts\\n ) external onlyBridge {\\n require(\\n recipients.length == amounts.length,\\n \\\"Arrays must have the same length\\\"\\n );\\n for (uint256 i = 0; i < recipients.length; i++) {\\n _increaseBalance(recipients[i], amounts[i]);\\n }\\n }\\n\\n /// @notice Increases balance of the provided `recipient` by the provided\\n /// `amount`. Can only be called by the Bridge.\\n /// @dev Requirements:\\n /// - `recipient` address must not point to the Bank.\\n /// @param recipient Balance increase recipient.\\n /// @param amount Amount by which the balance is increased.\\n function increaseBalance(address recipient, uint256 amount)\\n external\\n onlyBridge\\n {\\n _increaseBalance(recipient, amount);\\n }\\n\\n /// @notice Increases the given smart contract `vault`'s balance and\\n /// notifies the `vault` contract about it.\\n /// Can be called only by the Bridge.\\n /// @dev Requirements:\\n /// - `vault` must implement `IVault` interface,\\n /// - length of `recipients` and `amounts` must be the same.\\n /// @param vault Address of `IVault` recipient contract.\\n /// @param recipients Balance increase recipients.\\n /// @param amounts Amounts by which balances are increased.\\n function increaseBalanceAndCall(\\n address vault,\\n address[] calldata recipients,\\n uint256[] calldata amounts\\n ) external onlyBridge {\\n require(\\n recipients.length == amounts.length,\\n \\\"Arrays must have the same length\\\"\\n );\\n uint256 totalAmount = 0;\\n for (uint256 i = 0; i < amounts.length; i++) {\\n totalAmount += amounts[i];\\n }\\n _increaseBalance(vault, totalAmount);\\n IVault(vault).receiveBalanceIncrease(recipients, amounts);\\n }\\n\\n /// @notice Decreases caller's balance by the provided `amount`. There is no\\n /// way to restore the balance so do not call this function unless\\n /// you really know what you are doing!\\n /// @dev Requirements:\\n /// - The caller must have a balance of at least `amount`.\\n /// @param amount The amount by which the balance is decreased.\\n function decreaseBalance(uint256 amount) external {\\n balanceOf[msg.sender] -= amount;\\n emit BalanceDecreased(msg.sender, amount);\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with `TBTC Bank` as\\n /// a signing domain and Bank contract as a verifying contract.\\n /// Used to construct an EIP2612 signature provided to the `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view 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 function _increaseBalance(address recipient, uint256 amount) internal {\\n require(\\n recipient != address(this),\\n \\\"Can not increase balance for Bank\\\"\\n );\\n balanceOf[recipient] += amount;\\n emit BalanceIncreased(recipient, amount);\\n }\\n\\n function _transferBalance(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(\\n recipient != address(0),\\n \\\"Can not transfer to the zero address\\\"\\n );\\n require(\\n recipient != address(this),\\n \\\"Can not transfer to the Bank address\\\"\\n );\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n unchecked {\\n balanceOf[spender] = spenderBalance - amount;\\n }\\n balanceOf[recipient] += amount;\\n emit BalanceTransferred(spender, recipient, amount);\\n }\\n\\n function _approveBalance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Can not approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit BalanceApproved(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(\\\"TBTC Bank\\\")),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x318005485bc8fb8a8fb6091bc4a3ca0e304693d8b372b61835bed2f1f735faf7\",\"license\":\"GPL-3.0-only\"},\"contracts/bank/IReceiveBalanceApproval.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\n/// @title IReceiveBalanceApproval\\n/// @notice `IReceiveBalanceApproval` is an interface for a smart contract\\n/// consuming Bank balances approved to them in the same transaction by\\n/// other contracts or externally owned accounts (EOA).\\ninterface IReceiveBalanceApproval {\\n /// @notice Called by the Bank in `approveBalanceAndCall` function after\\n /// the balance `owner` approved `amount` of their balance in the\\n /// Bank for the contract. This way, the depositor can approve\\n /// balance and call the contract to use the approved balance in\\n /// a single transaction.\\n /// @param owner Address of the Bank balance owner who approved their\\n /// balance to be used by the contract.\\n /// @param amount The amount of the Bank balance approved by the owner\\n /// to be used by the contract.\\n /// @param extraData The `extraData` passed to `Bank.approveBalanceAndCall`.\\n /// @dev The implementation must ensure this function can only be called\\n /// by the Bank. The Bank does _not_ guarantee that the `amount`\\n /// approved by the `owner` currently exists on their balance. That is,\\n /// the `owner` could approve more balance than they currently have.\\n /// This works the same as `Bank.approve` function. The contract must\\n /// ensure the actual balance is checked before performing any action\\n /// based on it.\\n function receiveBalanceApproval(\\n address owner,\\n uint256 amount,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x864f29d54d9d672348520b1f46bbce786994e07d86032987e4374a267a345c2b\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/BitcoinTx.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\nimport {ValidateSPV} from \\\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\\\";\\n\\nimport \\\"./BridgeState.sol\\\";\\n\\n/// @title Bitcoin transaction\\n/// @notice Allows to reference Bitcoin raw transaction in Solidity.\\n/// @dev See https://developer.bitcoin.org/reference/transactions.html#raw-transaction-format\\n///\\n/// Raw Bitcoin transaction data:\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|--------------|------------------------|---------------------------|\\n/// | 4 | version | int32_t (LE) | TX version number |\\n/// | varies | tx_in_count | compactSize uint (LE) | Number of TX inputs |\\n/// | varies | tx_in | txIn[] | TX inputs |\\n/// | varies | tx_out_count | compactSize uint (LE) | Number of TX outputs |\\n/// | varies | tx_out | txOut[] | TX outputs |\\n/// | 4 | lock_time | uint32_t (LE) | Unix time or block number |\\n///\\n//\\n/// Non-coinbase transaction input (txIn):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|------------------|------------------------|---------------------------------------------|\\n/// | 36 | previous_output | outpoint | The previous outpoint being spent |\\n/// | varies | script_bytes | compactSize uint (LE) | The number of bytes in the signature script |\\n/// | varies | signature_script | char[] | The signature script, empty for P2WSH |\\n/// | 4 | sequence | uint32_t (LE) | Sequence number |\\n///\\n///\\n/// The reference to transaction being spent (outpoint):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |-------|-------|---------------|------------------------------------------|\\n/// | 32 | hash | char[32] | Hash of the transaction to spend |\\n/// | 4 | index | uint32_t (LE) | Index of the specific output from the TX |\\n///\\n///\\n/// Transaction output (txOut):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|-----------------|-----------------------|--------------------------------------|\\n/// | 8 | value | int64_t (LE) | Number of satoshis to spend |\\n/// | 1+ | pk_script_bytes | compactSize uint (LE) | Number of bytes in the pubkey script |\\n/// | varies | pk_script | char[] | Pubkey script |\\n///\\n/// compactSize uint format:\\n///\\n/// | Value | Bytes | Format |\\n/// |-----------------------------------------|-------|----------------------------------------------|\\n/// | >= 0 && <= 252 | 1 | uint8_t |\\n/// | >= 253 && <= 0xffff | 3 | 0xfd followed by the number as uint16_t (LE) |\\n/// | >= 0x10000 && <= 0xffffffff | 5 | 0xfe followed by the number as uint32_t (LE) |\\n/// | >= 0x100000000 && <= 0xffffffffffffffff | 9 | 0xff followed by the number as uint64_t (LE) |\\n///\\n/// (*) compactSize uint is often references as VarInt)\\n///\\n/// Coinbase transaction input (txIn):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|------------------|------------------------|---------------------------------------------|\\n/// | 32 | hash | char[32] | A 32-byte 0x0 null (no previous_outpoint) |\\n/// | 4 | index | uint32_t (LE) | 0xffffffff (no previous_outpoint) |\\n/// | varies | script_bytes | compactSize uint (LE) | The number of bytes in the coinbase script |\\n/// | varies | height | char[] | The block height of this block (BIP34) (*) |\\n/// | varies | coinbase_script | none | Arbitrary data, max 100 bytes |\\n/// | 4 | sequence | uint32_t (LE) | Sequence number\\n///\\n/// (*) Uses script language: starts with a data-pushing opcode that indicates how many bytes to push to\\n/// the stack followed by the block height as a little-endian unsigned integer. This script must be as\\n/// short as possible, otherwise it may be rejected. The data-pushing opcode will be 0x03 and the total\\n/// size four bytes until block 16,777,216 about 300 years from now.\\nlibrary BitcoinTx {\\n using BTCUtils for bytes;\\n using BTCUtils for uint256;\\n using BytesLib for bytes;\\n using ValidateSPV for bytes;\\n using ValidateSPV for bytes32;\\n\\n /// @notice Represents Bitcoin transaction data.\\n struct Info {\\n /// @notice Bitcoin transaction version.\\n /// @dev `version` from raw Bitcoin transaction data.\\n /// Encoded as 4-bytes signed integer, little endian.\\n bytes4 version;\\n /// @notice All Bitcoin transaction inputs, prepended by the number of\\n /// transaction inputs.\\n /// @dev `tx_in_count | tx_in` from raw Bitcoin transaction data.\\n ///\\n /// The number of transaction inputs encoded as compactSize\\n /// unsigned integer, little-endian.\\n ///\\n /// Note that some popular block explorers reverse the order of\\n /// bytes from `outpoint`'s `hash` and display it as big-endian.\\n /// Solidity code of Bridge expects hashes in little-endian, just\\n /// like they are represented in a raw Bitcoin transaction.\\n bytes inputVector;\\n /// @notice All Bitcoin transaction outputs prepended by the number of\\n /// transaction outputs.\\n /// @dev `tx_out_count | tx_out` from raw Bitcoin transaction data.\\n ///\\n /// The number of transaction outputs encoded as a compactSize\\n /// unsigned integer, little-endian.\\n bytes outputVector;\\n /// @notice Bitcoin transaction locktime.\\n ///\\n /// @dev `lock_time` from raw Bitcoin transaction data.\\n /// Encoded as 4-bytes unsigned integer, little endian.\\n bytes4 locktime;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents data needed to perform a Bitcoin SPV proof.\\n struct Proof {\\n /// @notice The merkle proof of transaction inclusion in a block.\\n bytes merkleProof;\\n /// @notice Transaction index in the block (0-indexed).\\n uint256 txIndexInBlock;\\n /// @notice Single byte-string of 80-byte bitcoin headers,\\n /// lowest height first.\\n bytes bitcoinHeaders;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents info about an unspent transaction output.\\n struct UTXO {\\n /// @notice Hash of the transaction the output belongs to.\\n /// @dev Byte order corresponds to the Bitcoin internal byte order.\\n bytes32 txHash;\\n /// @notice Index of the transaction output (0-indexed).\\n uint32 txOutputIndex;\\n /// @notice Value of the transaction output.\\n uint64 txOutputValue;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents Bitcoin signature in the R/S/V format.\\n struct RSVSignature {\\n /// @notice Signature r value.\\n bytes32 r;\\n /// @notice Signature s value.\\n bytes32 s;\\n /// @notice Signature recovery value.\\n uint8 v;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Validates the SPV proof of the Bitcoin transaction.\\n /// Reverts in case the validation or proof verification fail.\\n /// @param txInfo Bitcoin transaction data.\\n /// @param proof Bitcoin proof data.\\n /// @return txHash Proven 32-byte transaction hash.\\n function validateProof(\\n BridgeState.Storage storage self,\\n Info calldata txInfo,\\n Proof calldata proof\\n ) internal view returns (bytes32 txHash) {\\n require(\\n txInfo.inputVector.validateVin(),\\n \\\"Invalid input vector provided\\\"\\n );\\n require(\\n txInfo.outputVector.validateVout(),\\n \\\"Invalid output vector provided\\\"\\n );\\n\\n txHash = abi\\n .encodePacked(\\n txInfo.version,\\n txInfo.inputVector,\\n txInfo.outputVector,\\n txInfo.locktime\\n )\\n .hash256View();\\n\\n require(\\n txHash.prove(\\n proof.bitcoinHeaders.extractMerkleRootLE(),\\n proof.merkleProof,\\n proof.txIndexInBlock\\n ),\\n \\\"Tx merkle proof is not valid for provided header and tx hash\\\"\\n );\\n\\n evaluateProofDifficulty(self, proof.bitcoinHeaders);\\n\\n return txHash;\\n }\\n\\n /// @notice Evaluates the given Bitcoin proof difficulty against the actual\\n /// Bitcoin chain difficulty provided by the relay oracle.\\n /// Reverts in case the evaluation fails.\\n /// @param bitcoinHeaders Bitcoin headers chain being part of the SPV\\n /// proof. Used to extract the observed proof difficulty.\\n function evaluateProofDifficulty(\\n BridgeState.Storage storage self,\\n bytes memory bitcoinHeaders\\n ) internal view {\\n IRelay relay = self.relay;\\n uint256 currentEpochDifficulty = relay.getCurrentEpochDifficulty();\\n uint256 previousEpochDifficulty = relay.getPrevEpochDifficulty();\\n\\n uint256 requestedDiff = 0;\\n uint256 firstHeaderDiff = bitcoinHeaders\\n .extractTarget()\\n .calculateDifficulty();\\n\\n if (firstHeaderDiff == currentEpochDifficulty) {\\n requestedDiff = currentEpochDifficulty;\\n } else if (firstHeaderDiff == previousEpochDifficulty) {\\n requestedDiff = previousEpochDifficulty;\\n } else {\\n revert(\\\"Not at current or previous difficulty\\\");\\n }\\n\\n uint256 observedDiff = bitcoinHeaders.validateHeaderChain();\\n\\n require(\\n observedDiff != ValidateSPV.getErrBadLength(),\\n \\\"Invalid length of the headers chain\\\"\\n );\\n require(\\n observedDiff != ValidateSPV.getErrInvalidChain(),\\n \\\"Invalid headers chain\\\"\\n );\\n require(\\n observedDiff != ValidateSPV.getErrLowWork(),\\n \\\"Insufficient work in a header\\\"\\n );\\n\\n require(\\n observedDiff >= requestedDiff * self.txProofDifficultyFactor,\\n \\\"Insufficient accumulated difficulty in header chain\\\"\\n );\\n }\\n\\n /// @notice Extracts public key hash from the provided P2PKH or P2WPKH output.\\n /// Reverts if the validation fails.\\n /// @param output The transaction output.\\n /// @return pubKeyHash 20-byte public key hash the output locks funds on.\\n /// @dev Requirements:\\n /// - The output must be of P2PKH or P2WPKH type and lock the funds\\n /// on a 20-byte public key hash.\\n function extractPubKeyHash(BridgeState.Storage storage, bytes memory output)\\n internal\\n pure\\n returns (bytes20 pubKeyHash)\\n {\\n bytes memory pubKeyHashBytes = output.extractHash();\\n\\n require(\\n pubKeyHashBytes.length == 20,\\n \\\"Output's public key hash must have 20 bytes\\\"\\n );\\n\\n pubKeyHash = pubKeyHashBytes.slice20(0);\\n\\n // The output consists of an 8-byte value and a variable length script.\\n // To extract just the script, we ignore the first 8 bytes.\\n uint256 scriptLen = output.length - 8;\\n\\n // The P2PKH script is 26 bytes long.\\n // The P2WPKH script is 23 bytes long.\\n // A valid script must have one of these lengths,\\n // and we can identify the expected script type by the length.\\n require(\\n scriptLen == 26 || scriptLen == 23,\\n \\\"Output must be P2PKH or P2WPKH\\\"\\n );\\n\\n if (scriptLen == 26) {\\n // Compare to the expected P2PKH script.\\n bytes26 script = bytes26(output.slice32(8));\\n\\n require(\\n script == makeP2PKHScript(pubKeyHash),\\n \\\"Invalid P2PKH script\\\"\\n );\\n }\\n\\n if (scriptLen == 23) {\\n // Compare to the expected P2WPKH script.\\n bytes23 script = bytes23(output.slice32(8));\\n\\n require(\\n script == makeP2WPKHScript(pubKeyHash),\\n \\\"Invalid P2WPKH script\\\"\\n );\\n }\\n\\n return pubKeyHash;\\n }\\n\\n /// @notice Build the P2PKH script from the given public key hash.\\n /// @param pubKeyHash The 20-byte public key hash.\\n /// @return The P2PKH script.\\n /// @dev The P2PKH script has the following byte format:\\n /// <0x1976a914> <20-byte PKH> <0x88ac>. According to\\n /// https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n /// - 0x19: Byte length of the entire script\\n /// - 0x76: OP_DUP\\n /// - 0xa9: OP_HASH160\\n /// - 0x14: Byte length of the public key hash\\n /// - 0x88: OP_EQUALVERIFY\\n /// - 0xac: OP_CHECKSIG\\n /// which matches the P2PKH structure as per:\\n /// https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash\\n function makeP2PKHScript(bytes20 pubKeyHash)\\n internal\\n pure\\n returns (bytes26)\\n {\\n bytes26 P2PKHScriptMask = hex\\\"1976a914000000000000000000000000000000000000000088ac\\\";\\n\\n return ((bytes26(pubKeyHash) >> 32) | P2PKHScriptMask);\\n }\\n\\n /// @notice Build the P2WPKH script from the given public key hash.\\n /// @param pubKeyHash The 20-byte public key hash.\\n /// @return The P2WPKH script.\\n /// @dev The P2WPKH script has the following format:\\n /// <0x160014> <20-byte PKH>. According to\\n /// https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n /// - 0x16: Byte length of the entire script\\n /// - 0x00: OP_0\\n /// - 0x14: Byte length of the public key hash\\n /// which matches the P2WPKH structure as per:\\n /// https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH\\n function makeP2WPKHScript(bytes20 pubKeyHash)\\n internal\\n pure\\n returns (bytes23)\\n {\\n bytes23 P2WPKHScriptMask = hex\\\"1600140000000000000000000000000000000000000000\\\";\\n\\n return ((bytes23(pubKeyHash) >> 24) | P2WPKHScriptMask);\\n }\\n}\\n\",\"keccak256\":\"0xb087cb5b364bcdcca63772a442c630e858c90555fc691521a212c068b89120a5\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Bridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport \\\"@keep-network/random-beacon/contracts/Governable.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\\\";\\nimport {IWalletOwner as EcdsaWalletOwner} from \\\"@keep-network/ecdsa/contracts/api/IWalletOwner.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\nimport \\\"./IRelay.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Deposit.sol\\\";\\nimport \\\"./DepositSweep.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\nimport \\\"./Fraud.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\n\\nimport \\\"../bank/IReceiveBalanceApproval.sol\\\";\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @title Bitcoin Bridge\\n/// @notice Bridge manages BTC deposit and redemption flow and is increasing and\\n/// decreasing balances in the Bank as a result of BTC deposit and\\n/// redemption operations performed by depositors and redeemers.\\n///\\n/// Depositors send BTC funds to the most recently created off-chain\\n/// ECDSA wallet of the bridge using pay-to-script-hash (P2SH) or\\n/// pay-to-witness-script-hash (P2WSH) containing hashed information\\n/// about the depositor\\u2019s Ethereum address. Then, the depositor reveals\\n/// their Ethereum address along with their deposit blinding factor,\\n/// refund public key hash and refund locktime to the Bridge on Ethereum\\n/// chain. The off-chain ECDSA wallet listens for these sorts of\\n/// messages and when it gets one, it checks the Bitcoin network to make\\n/// sure the deposit lines up. If it does, the off-chain ECDSA wallet\\n/// may decide to pick the deposit transaction for sweeping, and when\\n/// the sweep operation is confirmed on the Bitcoin network, the ECDSA\\n/// wallet informs the Bridge about the sweep increasing appropriate\\n/// balances in the Bank.\\n/// @dev Bridge is an upgradeable component of the Bank. The order of\\n/// functionalities in this contract is: deposit, sweep, redemption,\\n/// moving funds, wallet lifecycle, frauds, parameters.\\ncontract Bridge is\\n Governable,\\n EcdsaWalletOwner,\\n Initializable,\\n IReceiveBalanceApproval\\n{\\n using BridgeState for BridgeState.Storage;\\n using Deposit for BridgeState.Storage;\\n using DepositSweep for BridgeState.Storage;\\n using Redemption for BridgeState.Storage;\\n using MovingFunds for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using Fraud for BridgeState.Storage;\\n\\n BridgeState.Storage internal self;\\n\\n event DepositRevealed(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex,\\n address indexed depositor,\\n uint64 amount,\\n bytes8 blindingFactor,\\n bytes20 indexed walletPubKeyHash,\\n bytes20 refundPubKeyHash,\\n bytes4 refundLocktime,\\n address vault\\n );\\n\\n event DepositsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);\\n\\n event RedemptionRequested(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript,\\n address indexed redeemer,\\n uint64 requestedAmount,\\n uint64 treasuryFee,\\n uint64 txMaxFee\\n );\\n\\n event RedemptionsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 redemptionTxHash\\n );\\n\\n event RedemptionTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript\\n );\\n\\n event WalletMovingFunds(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event MovingFundsCommitmentSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes20[] targetWallets,\\n address submitter\\n );\\n\\n event MovingFundsTimeoutReset(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash\\n );\\n\\n event MovingFundsTimedOut(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsBelowDustReported(bytes20 indexed walletPubKeyHash);\\n\\n event MovedFundsSwept(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sweepTxHash\\n );\\n\\n event MovedFundsSweepTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex\\n );\\n\\n event NewWalletRequested();\\n\\n event NewWalletRegistered(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosing(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosed(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletTerminated(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event FraudChallengeSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n );\\n\\n event FraudChallengeDefeated(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event FraudChallengeDefeatTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event VaultStatusUpdated(address indexed vault, bool isTrusted);\\n\\n event SpvMaintainerStatusUpdated(\\n address indexed spvMaintainer,\\n bool isTrusted\\n );\\n\\n event DepositParametersUpdated(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n\\n event RedemptionParametersUpdated(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n );\\n\\n event MovingFundsParametersUpdated(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n\\n event WalletParametersUpdated(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n );\\n\\n event FraudParametersUpdated(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n );\\n\\n event TreasuryUpdated(address treasury);\\n\\n modifier onlySpvMaintainer() {\\n require(\\n self.isSpvMaintainer[msg.sender],\\n \\\"Caller is not SPV maintainer\\\"\\n );\\n _;\\n }\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /// @dev Initializes upgradable contract on deployment.\\n /// @param _bank Address of the Bank the Bridge belongs to.\\n /// @param _relay Address of the Bitcoin relay providing the current Bitcoin\\n /// network difficulty.\\n /// @param _treasury Address where the deposit and redemption treasury fees\\n /// will be sent to.\\n /// @param _ecdsaWalletRegistry Address of the ECDSA Wallet Registry contract.\\n /// @param _reimbursementPool Address of the Reimbursement Pool contract.\\n /// @param _txProofDifficultyFactor The number of confirmations on the Bitcoin\\n /// chain required to successfully evaluate an SPV proof.\\n function initialize(\\n address _bank,\\n address _relay,\\n address _treasury,\\n address _ecdsaWalletRegistry,\\n address payable _reimbursementPool,\\n uint96 _txProofDifficultyFactor\\n ) external initializer {\\n require(_bank != address(0), \\\"Bank address cannot be zero\\\");\\n self.bank = Bank(_bank);\\n\\n require(_relay != address(0), \\\"Relay address cannot be zero\\\");\\n self.relay = IRelay(_relay);\\n\\n require(\\n _ecdsaWalletRegistry != address(0),\\n \\\"ECDSA Wallet Registry address cannot be zero\\\"\\n );\\n self.ecdsaWalletRegistry = EcdsaWalletRegistry(_ecdsaWalletRegistry);\\n\\n require(\\n _reimbursementPool != address(0),\\n \\\"Reimbursement Pool address cannot be zero\\\"\\n );\\n self.reimbursementPool = ReimbursementPool(_reimbursementPool);\\n\\n require(_treasury != address(0), \\\"Treasury address cannot be zero\\\");\\n self.treasury = _treasury;\\n\\n self.txProofDifficultyFactor = _txProofDifficultyFactor;\\n\\n //\\n // All parameters set in the constructor are initial ones, used at the\\n // moment contracts were deployed for the first time. Parameters are\\n // governable and values assigned in the constructor do not need to\\n // reflect the current ones. Keep in mind the initial parameters are\\n // pretty forgiving and valid only for the early stage of the network.\\n //\\n\\n self.depositDustThreshold = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.depositTxMaxFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.depositRevealAheadPeriod = 15 days;\\n self.depositTreasuryFeeDivisor = 2000; // 1/2000 == 5bps == 0.05% == 0.0005\\n self.redemptionDustThreshold = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.redemptionTreasuryFeeDivisor = 2000; // 1/2000 == 5bps == 0.05% == 0.0005\\n self.redemptionTxMaxFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.redemptionTxMaxTotalFee = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.redemptionTimeout = 5 days;\\n self.redemptionTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.redemptionTimeoutNotifierRewardMultiplier = 100; // 100%\\n self.movingFundsTxMaxTotalFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.movingFundsDustThreshold = 200000; // 200000 satoshi = 0.002 BTC\\n self.movingFundsTimeoutResetDelay = 6 days;\\n self.movingFundsTimeout = 7 days;\\n self.movingFundsTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.movingFundsTimeoutNotifierRewardMultiplier = 100; //100%\\n self.movingFundsCommitmentGasOffset = 15000;\\n self.movedFundsSweepTxMaxTotalFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.movedFundsSweepTimeout = 7 days;\\n self.movedFundsSweepTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.movedFundsSweepTimeoutNotifierRewardMultiplier = 100; //100%\\n self.fraudChallengeDepositAmount = 5 ether;\\n self.fraudChallengeDefeatTimeout = 7 days;\\n self.fraudSlashingAmount = 100 * 1e18; // 100 T\\n self.fraudNotifierRewardMultiplier = 100; // 100%\\n self.walletCreationPeriod = 1 weeks;\\n self.walletCreationMinBtcBalance = 1e8; // 1 BTC\\n self.walletCreationMaxBtcBalance = 100e8; // 100 BTC\\n self.walletClosureMinBtcBalance = 5 * 1e7; // 0.5 BTC\\n self.walletMaxAge = 26 weeks; // ~6 months\\n self.walletMaxBtcTransfer = 10e8; // 10 BTC\\n self.walletClosingPeriod = 40 days;\\n\\n _transferGovernance(msg.sender);\\n }\\n\\n /// @notice Used by the depositor to reveal information about their P2(W)SH\\n /// Bitcoin deposit to the Bridge on Ethereum chain. The off-chain\\n /// wallet listens for revealed deposit events and may decide to\\n /// include the revealed deposit in the next executed sweep.\\n /// Information about the Bitcoin deposit can be revealed before or\\n /// after the Bitcoin transaction with P2(W)SH deposit is mined on\\n /// the Bitcoin chain. Worth noting, the gas cost of this function\\n /// scales with the number of P2(W)SH transaction inputs and\\n /// outputs. The deposit may be routed to one of the trusted vaults.\\n /// When a deposit is routed to a vault, vault gets notified when\\n /// the deposit gets swept and it may execute the appropriate action.\\n /// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.\\n /// @param reveal Deposit reveal data, see `RevealInfo struct.\\n /// @dev Requirements:\\n /// - This function must be called by the same Ethereum address as the\\n /// one used in the P2(W)SH BTC deposit transaction as a depositor,\\n /// - `reveal.walletPubKeyHash` must identify a `Live` wallet,\\n /// - `reveal.vault` must be 0x0 or point to a trusted vault,\\n /// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH\\n /// output of the BTC deposit transaction,\\n /// - `reveal.blindingFactor` must be the blinding factor used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - `reveal.walletPubKeyHash` must be the wallet pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundPubKeyHash` must be the refund pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundLocktime` must be the refund locktime used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n ///\\n /// If any of these requirements is not met, the wallet _must_ refuse\\n /// to sweep the deposit and the depositor has to wait until the\\n /// deposit script unlocks to receive their BTC back.\\n function revealDeposit(\\n BitcoinTx.Info calldata fundingTx,\\n Deposit.DepositRevealInfo calldata reveal\\n ) external {\\n self.revealDeposit(fundingTx, reveal);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC deposit sweep transaction\\n /// and to update Bank balances accordingly. Sweep is only accepted\\n /// if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by first\\n /// computing the Bitcoin fee for the sweep transaction. The fee is\\n /// divided evenly between all swept deposits. Each depositor\\n /// receives a balance in the bank equal to the amount inferred\\n /// during the reveal transaction, minus their fee share.\\n ///\\n /// It is possible to prove the given sweep only one time.\\n /// @param sweepTx Bitcoin sweep transaction data.\\n /// @param sweepProof Bitcoin sweep proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @param vault Optional address of the vault where all swept deposits\\n /// should be routed to. All deposits swept as part of the transaction\\n /// must have their `vault` parameters set to the same address.\\n /// If this parameter is set to an address of a trusted vault, swept\\n /// deposits are routed to that vault.\\n /// If this parameter is set to the zero address or to an address\\n /// of a non-trusted vault, swept deposits are not routed to a\\n /// vault but depositors' balances are increased in the Bank\\n /// individually.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with 1..n\\n /// inputs. If the wallet has no main UTXO, all n inputs should\\n /// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has\\n /// an existing main UTXO, one of the n inputs must point to that\\n /// main UTXO and remaining n-1 inputs should correspond to P2(W)SH\\n /// revealed deposits UTXOs. That transaction must have only\\n /// one P2(W)PKH output locking funds on the 20-byte wallet public\\n /// key hash,\\n /// - All revealed deposits that are swept by `sweepTx` must have\\n /// their `vault` parameters set to the same address as the address\\n /// passed in the `vault` function parameter,\\n /// - `sweepProof` components must match the expected structure. See\\n /// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored.\\n function submitDepositSweepProof(\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address vault\\n ) external onlySpvMaintainer {\\n self.submitDepositSweepProof(sweepTx, sweepProof, mainUtxo, vault);\\n }\\n\\n function mock__submitDepositSweepProof(\\n bytes20 walletPubKeyHash,\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external {\\n self.mock__submitDepositSweepProof(\\n walletPubKeyHash,\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Handles the\\n /// simplest case in which the redeemer's balance is decreased in\\n /// the Bank.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to process the request,\\n /// - Redeemer must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes calldata redeemerOutputScript,\\n uint64 amount\\n ) external {\\n self.requestRedemption(\\n walletPubKeyHash,\\n mainUtxo,\\n msg.sender,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Used by\\n /// `Bank.approveBalanceAndCall`. Can handle more complex cases\\n /// where balance owner may be someone else than the redeemer.\\n /// For example, vault redeeming its balance for some depositor.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @param redemptionData ABI-encoded redemption data:\\n /// [\\n /// address redeemer,\\n /// bytes20 walletPubKeyHash,\\n /// bytes32 mainUtxoTxHash,\\n /// uint32 mainUtxoTxOutputIndex,\\n /// uint64 mainUtxoTxOutputValue,\\n /// bytes redeemerOutputScript\\n /// ]\\n ///\\n /// - redeemer: The Ethereum address of the redeemer who will be able\\n /// to claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their balance\\n /// from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to,\\n /// - walletPubKeyHash: The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key),\\n /// - mainUtxoTxHash: Data of the wallet's main UTXO TX hash, as\\n /// currently known on the Ethereum chain,\\n /// - mainUtxoTxOutputIndex: Data of the wallet's main UTXO output\\n /// index, as currently known on Ethereum chain,\\n /// - mainUtxoTxOutputValue: Data of the wallet's main UTXO output\\n /// value, as currently known on Ethereum chain,\\n /// - redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @dev Requirements:\\n /// - The caller must be the Bank,\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to process the request.\\n ///\\n /// Note on upgradeability:\\n /// Bridge is an upgradeable contract deployed behind\\n /// a TransparentUpgradeableProxy. Accepting redemption data as bytes\\n /// provides great flexibility. The Bridge is just like any other\\n /// contract with a balance approved in the Bank and can be upgraded\\n /// to another version without being bound to a particular interface\\n /// forever. This flexibility comes with the cost - developers\\n /// integrating their vaults and dApps with `Bridge` using\\n /// `approveBalanceAndCall` need to pay extra attention to\\n /// `redemptionData` and adjust the code in case the expected structure\\n /// of `redemptionData` changes.\\n function receiveBalanceApproval(\\n address balanceOwner,\\n uint256 amount,\\n bytes calldata redemptionData\\n ) external override {\\n require(msg.sender == address(self.bank), \\\"Caller is not the bank\\\");\\n\\n self.requestRedemption(\\n balanceOwner,\\n SafeCastUpgradeable.toUint64(amount),\\n redemptionData\\n );\\n }\\n\\n /// @notice Used by the wallet to prove the BTC redemption transaction\\n /// and to make the necessary bookkeeping. Redemption is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by burning\\n /// the total redeemed Bitcoin amount from Bridge balance and\\n /// transferring the treasury fee sum to the treasury address.\\n ///\\n /// It is possible to prove the given redemption only one time.\\n /// @param redemptionTx Bitcoin redemption transaction data.\\n /// @param redemptionProof Bitcoin redemption proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @dev Requirements:\\n /// - `redemptionTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `redemptionTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs handling existing pending\\n /// redemption requests or pointing to reported timed out requests.\\n /// There can be also 1 optional output representing the\\n /// change and pointing back to the 20-byte wallet public key hash.\\n /// The change should be always present if the redeemed value sum\\n /// is lower than the total wallet's BTC balance,\\n /// - `redemptionProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input.\\n /// Other remarks:\\n /// - Putting the change output as the first transaction output can\\n /// save some gas because the output processing loop begins each\\n /// iteration by checking whether the given output is the change\\n /// thus uses some gas for making the comparison. Once the change\\n /// is identified, that check is omitted in further iterations.\\n function submitRedemptionProof(\\n BitcoinTx.Info calldata redemptionTx,\\n BitcoinTx.Proof calldata redemptionProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external onlySpvMaintainer {\\n self.submitRedemptionProof(\\n redemptionTx,\\n redemptionProof,\\n mainUtxo,\\n walletPubKeyHash\\n );\\n }\\n\\n function mock__submitRedemptionProof(\\n bytes20 walletPubKeyHash,\\n bytes calldata redeemerOutputScript,\\n bytes32 redemptionTxHash\\n ) external {\\n self.mock__submitRedemptionProof(\\n walletPubKeyHash,\\n redeemerOutputScript,\\n redemptionTxHash\\n );\\n }\\n\\n /// @notice Notifies that there is a pending redemption request associated\\n /// with the given wallet, that has timed out. The redemption\\n /// request is identified by the key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The results of calling this function:\\n /// - The pending redemptions value for the wallet will be decreased\\n /// by the requested amount (minus treasury fee),\\n /// - The tokens taken from the redeemer on redemption request will\\n /// be returned to the redeemer,\\n /// - The request will be moved from pending redemptions to\\n /// timed-out redemptions,\\n /// - If the state of the wallet is `Live` or `MovingFunds`, the\\n /// wallet operators will be slashed and the notifier will be\\n /// rewarded,\\n /// - If the state of wallet is `Live`, the wallet will be closed or\\n /// marked as `MovingFunds` (depending on the presence or absence\\n /// of the wallet's main UTXO) and the wallet will no longer be\\n /// marked as the active wallet (if it was marked as such).\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH).\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Terminated state,\\n /// - The redemption request identified by `walletPubKeyHash` and\\n /// `redeemerOutputScript` must exist,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time defined by `redemptionTimeout` must have\\n /// passed since the redemption was requested (the request must be\\n /// timed-out).\\n function notifyRedemptionTimeout(\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n bytes calldata redeemerOutputScript\\n ) external {\\n self.notifyRedemptionTimeout(\\n walletPubKeyHash,\\n walletMembersIDs,\\n redeemerOutputScript\\n );\\n }\\n\\n /// @notice Submits the moving funds target wallets commitment.\\n /// Once all requirements are met, that function registers the\\n /// target wallets commitment and opens the way for moving funds\\n /// proof submission.\\n /// The caller is reimbursed for the transaction costs.\\n /// @param walletPubKeyHash 20-byte public key hash of the source wallet.\\n /// @param walletMainUtxo Data of the source wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletMembersIDs Identifiers of the source wallet signing group\\n /// members.\\n /// @param walletMemberIndex Position of the caller in the source wallet\\n /// signing group members list.\\n /// @param targetWallets List of 20-byte public key hashes of the target\\n /// wallets that the source wallet commits to move the funds to.\\n /// @dev Requirements:\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The source wallet must not have pending redemption requests,\\n /// - The source wallet must not have pending moved funds sweep requests,\\n /// - The source wallet must not have submitted its commitment already,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given source wallet in the ECDSA registry. Those IDs are\\n /// not directly stored in the contract for gas efficiency purposes\\n /// but they can be read from appropriate `DkgResultSubmitted`\\n /// and `DkgResultApproved` events,\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],\\n /// - The caller must be the member of the source wallet signing group\\n /// at the position indicated by `walletMemberIndex` parameter,\\n /// - The `walletMainUtxo` components must point to the recent main\\n /// UTXO of the source wallet, as currently known on the Ethereum\\n /// chain,\\n /// - Source wallet BTC balance must be greater than zero,\\n /// - At least one Live wallet must exist in the system,\\n /// - Submitted target wallets count must match the expected count\\n /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`\\n /// where `N > 0`,\\n /// - Each target wallet must be not equal to the source wallet,\\n /// - Each target wallet must follow the expected order i.e. all\\n /// target wallets 20-byte public key hashes represented as numbers\\n /// must form a strictly increasing sequence without duplicates,\\n /// - Each target wallet must be in Live state.\\n function submitMovingFundsCommitment(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo,\\n uint32[] calldata walletMembersIDs,\\n uint256 walletMemberIndex,\\n bytes20[] calldata targetWallets\\n ) external {\\n uint256 gasStart = gasleft();\\n\\n self.submitMovingFundsCommitment(\\n walletPubKeyHash,\\n walletMainUtxo,\\n walletMembersIDs,\\n walletMemberIndex,\\n targetWallets\\n );\\n\\n self.reimbursementPool.refund(\\n (gasStart - gasleft()) + self.movingFundsCommitmentGasOffset,\\n msg.sender\\n );\\n }\\n\\n /// @notice Resets the moving funds timeout for the given wallet if the\\n /// target wallet commitment cannot be submitted due to a lack\\n /// of live wallets in the system.\\n /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must not be already submitted for\\n /// the given moving funds wallet,\\n /// - Live wallets count must be zero,\\n /// - The moving funds timeout reset delay must be elapsed.\\n function resetMovingFundsTimeout(bytes20 walletPubKeyHash) external {\\n self.resetMovingFundsTimeout(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moving funds transaction\\n /// and to make the necessary state changes. Moving funds is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the moving funds transaction structure\\n /// by checking if it actually spends the main UTXO of the declared\\n /// wallet and locks the value on the pre-committed target wallets\\n /// using a reasonable transaction fee. If all preconditions are\\n /// met, this functions closes the source wallet.\\n ///\\n /// It is possible to prove the given moving funds transaction only\\n /// one time.\\n /// @param movingFundsTx Bitcoin moving funds transaction data.\\n /// @param movingFundsProof Bitcoin moving funds proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet\\n /// which performed the moving funds transaction.\\n /// @dev Requirements:\\n /// - `movingFundsTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `movingFundsTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs corresponding to the\\n /// pre-committed target wallets. Outputs must be ordered in the\\n /// same way as their corresponding target wallets are ordered\\n /// within the target wallets commitment,\\n /// - `movingFundsProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input,\\n /// - The wallet that `walletPubKeyHash` points to must be in the\\n /// MovingFunds state,\\n /// - The target wallets commitment must be submitted by the wallet\\n /// that `walletPubKeyHash` points to,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movingFundsTxMaxTotalFee` governable parameter.\\n function submitMovingFundsProof(\\n BitcoinTx.Info calldata movingFundsTx,\\n BitcoinTx.Proof calldata movingFundsProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external onlySpvMaintainer {\\n self.submitMovingFundsProof(\\n movingFundsTx,\\n movingFundsProof,\\n mainUtxo,\\n walletPubKeyHash\\n );\\n }\\n\\n /// @notice Notifies about a timed out moving funds process. Terminates\\n /// the wallet and slashes signing group members as a result.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The moving funds timeout must be actually exceeded,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovingFundsTimeout(\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n self.notifyMovingFundsTimeout(walletPubKeyHash, walletMembersIDs);\\n }\\n\\n /// @notice Notifies about a moving funds wallet whose BTC balance is\\n /// below the moving funds dust threshold. Ends the moving funds\\n /// process and begins wallet closing immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known\\n /// on the Ethereum chain.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored,\\n /// - The wallet BTC balance must be below the moving funds threshold.\\n function notifyMovingFundsBelowDust(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n self.notifyMovingFundsBelowDust(walletPubKeyHash, mainUtxo);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moved funds sweep\\n /// transaction and to make the necessary state changes. Moved\\n /// funds sweep is only accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the sweep transaction structure by\\n /// checking if it actually spends the moved funds UTXO and the\\n /// sweeping wallet's main UTXO (optionally), and if it locks the\\n /// value on the sweeping wallet's 20-byte public key hash using a\\n /// reasonable transaction fee. If all preconditions are\\n /// met, this function updates the sweeping wallet main UTXO, thus\\n /// their BTC balance.\\n ///\\n /// It is possible to prove the given sweep transaction only\\n /// one time.\\n /// @param sweepTx Bitcoin sweep funds transaction data.\\n /// @param sweepProof Bitcoin sweep funds proof data.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with\\n /// the first input pointing to a moved funds sweep request targeted\\n /// to the wallet, and optionally, the second input pointing to the\\n /// wallet's main UTXO, if the sweeping wallet has a main UTXO set.\\n /// There should be only one output locking funds on the sweeping\\n /// wallet 20-byte public key hash,\\n /// - `sweepProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the sweeping wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored,\\n /// - The sweeping wallet must be in the Live or MovingFunds state,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movedFundsSweepTxMaxTotalFee` governable parameter.\\n function submitMovedFundsSweepProof(\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external onlySpvMaintainer {\\n self.submitMovedFundsSweepProof(sweepTx, sweepProof, mainUtxo);\\n }\\n\\n /// @notice Notifies about a timed out moved funds sweep process. If the\\n /// wallet is not terminated yet, that function terminates\\n /// the wallet and slashes signing group members as a result.\\n /// Marks the given sweep request as TimedOut.\\n /// @param movingFundsTxHash 32-byte hash of the moving funds transaction\\n /// that caused the sweep request to be created.\\n /// @param movingFundsTxOutputIndex Index of the moving funds transaction\\n /// output that is subject of the sweep request.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The moved funds sweep request must be in the Pending state,\\n /// - The moved funds sweep timeout must be actually exceeded,\\n /// - The wallet must be either in the Live or MovingFunds or\\n /// Terminated state,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovedFundsSweepTimeout(\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n self.notifyMovedFundsSweepTimeout(\\n movingFundsTxHash,\\n movingFundsTxOutputIndex,\\n walletMembersIDs\\n );\\n }\\n\\n /// @notice Requests creation of a new wallet. This function just\\n /// forms a request and the creation process is performed\\n /// asynchronously. Once a wallet is created, the ECDSA Wallet\\n /// Registry will notify this contract by calling the\\n /// `__ecdsaWalletCreatedCallback` function.\\n /// @param activeWalletMainUtxo Data of the active wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `activeWalletMainUtxo` components must point to the recent main\\n /// UTXO of the given active wallet, as currently known on the\\n /// Ethereum chain. If there is no active wallet at the moment, or\\n /// the active wallet has no main UTXO, this parameter can be\\n /// empty as it is ignored,\\n /// - Wallet creation must not be in progress,\\n /// - If the active wallet is set, one of the following\\n /// conditions must be true:\\n /// - The active wallet BTC balance is above the minimum threshold\\n /// and the active wallet is old enough, i.e. the creation period\\n /// was elapsed since its creation time,\\n /// - The active wallet BTC balance is above the maximum threshold.\\n function requestNewWallet(BitcoinTx.UTXO calldata activeWalletMainUtxo)\\n external\\n {\\n self.requestNewWallet(activeWalletMainUtxo);\\n }\\n\\n /// @notice A callback function that is called by the ECDSA Wallet Registry\\n /// once a new ECDSA wallet is created.\\n /// @param ecdsaWalletID Wallet's unique identifier.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Given wallet data must not belong to an already registered wallet.\\n function __ecdsaWalletCreatedCallback(\\n bytes32 ecdsaWalletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external override {\\n self.registerNewWallet(ecdsaWalletID, publicKeyX, publicKeyY);\\n }\\n\\n function mock__registerEcdsaWallet(\\n bytes32 ecdsaWalletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) external {\\n self.mock__registerEcdsaWallet(\\n ecdsaWalletID,\\n publicKeyX,\\n publicKeyY,\\n walletMainUtxo\\n );\\n }\\n\\n /// @notice A callback function that is called by the ECDSA Wallet Registry\\n /// once a wallet heartbeat failure is detected.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Wallet must be in Live state.\\n function __ecdsaWalletHeartbeatFailedCallback(\\n bytes32,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external override {\\n self.notifyWalletHeartbeatFailed(publicKeyX, publicKeyY);\\n }\\n\\n /// @notice Notifies that the wallet is either old enough or has too few\\n /// satoshi left and qualifies to be closed.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - Wallet must not be set as the current active wallet,\\n /// - Wallet must exceed the wallet maximum age OR the wallet BTC\\n /// balance must be lesser than the minimum threshold. If the latter\\n /// case is true, the `walletMainUtxo` components must point to the\\n /// recent main UTXO of the given wallet, as currently known on the\\n /// Ethereum chain. If the wallet has no main UTXO, this parameter\\n /// can be empty as it is ignored since the wallet balance is\\n /// assumed to be zero,\\n /// - Wallet must be in Live state.\\n function notifyWalletCloseable(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) external {\\n self.notifyWalletCloseable(walletPubKeyHash, walletMainUtxo);\\n }\\n\\n /// @notice Notifies about the end of the closing period for the given wallet.\\n /// Closes the wallet ultimately and notifies the ECDSA registry\\n /// about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the Closing state,\\n /// - The wallet closing period must have elapsed.\\n function notifyWalletClosingPeriodElapsed(bytes20 walletPubKeyHash)\\n external\\n {\\n self.notifyWalletClosingPeriodElapsed(walletPubKeyHash);\\n }\\n\\n /// @notice Submits a fraud challenge indicating that a UTXO being under\\n /// wallet control was unlocked by the wallet but was not used\\n /// according to the protocol rules. That means the wallet signed\\n /// a transaction input pointing to that UTXO and there is a unique\\n /// sighash and signature pair associated with that input. This\\n /// function uses those parameters to create a fraud accusation that\\n /// proves a given transaction input unlocking the given UTXO was\\n /// actually signed by the wallet. This function cannot determine\\n /// whether the transaction was actually broadcast and the input was\\n /// consumed in a fraudulent way so it just opens a challenge period\\n /// during which the wallet can defeat the challenge by submitting\\n /// proof of a transaction that consumes the given input according\\n /// to protocol rules. To prevent spurious allegations, the caller\\n /// must deposit ETH that is returned back upon justified fraud\\n /// challenge or confiscated otherwise.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @param signature Bitcoin signature in the R/S/V format.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPublicKey` must be in Live or MovingFunds\\n /// or Closing state,\\n /// - The challenger must send appropriate amount of ETH used as\\n /// fraud challenge deposit,\\n /// - The signature (represented by r, s and v) must be generated by\\n /// the wallet behind `walletPubKey` during signing of `sighash`\\n /// which was calculated from `preimageSha256`,\\n /// - Wallet can be challenged for the given signature only once.\\n function submitFraudChallenge(\\n bytes calldata walletPublicKey,\\n bytes memory preimageSha256,\\n BitcoinTx.RSVSignature calldata signature\\n ) external payable {\\n self.submitFraudChallenge(walletPublicKey, preimageSha256, signature);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet if\\n /// the transaction that spends the UTXO follows the protocol rules.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during input signing.\\n /// The fraud challenge defeat attempt will only succeed if the\\n /// inputs in the preimage are considered honestly spent by the\\n /// wallet. Therefore the transaction spending the UTXO must be\\n /// proven in the Bridge before a challenge defeat is called.\\n /// If successfully defeated, the fraud challenge is marked as\\n /// resolved and the amount of ether deposited by the challenger is\\n /// sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @param witness Flag indicating whether the preimage was produced for a\\n /// witness input. True for witness, false for non-witness input.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`\\n /// must identify an open fraud challenge,\\n /// - the preimage must be a valid preimage of a transaction generated\\n /// according to the protocol rules and already proved in the Bridge,\\n /// - before a defeat attempt is made the transaction that spends the\\n /// given UTXO must be proven in the Bridge.\\n function defeatFraudChallenge(\\n bytes calldata walletPublicKey,\\n bytes calldata preimage,\\n bool witness\\n ) external {\\n self.defeatFraudChallenge(walletPublicKey, preimage, witness);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet by\\n /// proving the sighash and signature were produced for an off-chain\\n /// wallet heartbeat message following a strict format.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during heartbeat message\\n /// signing. The fraud challenge defeat attempt will only succeed if\\n /// the signed message follows a strict format required for\\n /// heartbeat messages. If successfully defeated, the fraud\\n /// challenge is marked as resolved and the amount of ether\\n /// deposited by the challenger is sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat\\n /// message format requirements which produces sighash used to\\n /// generate the ECDSA signature that is the subject of the fraud\\n /// claim.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as\\n /// `hash256(heartbeatMessage)` must identify an open fraud challenge,\\n /// - `heartbeatMessage` must follow a strict format of heartbeat\\n /// messages.\\n function defeatFraudChallengeWithHeartbeat(\\n bytes calldata walletPublicKey,\\n bytes calldata heartbeatMessage\\n ) external {\\n self.defeatFraudChallengeWithHeartbeat(\\n walletPublicKey,\\n heartbeatMessage\\n );\\n }\\n\\n /// @notice Notifies about defeat timeout for the given fraud challenge.\\n /// Can be called only if there was a fraud challenge identified by\\n /// the provided `walletPublicKey` and `sighash` and it was not\\n /// defeated on time. The amount of time that needs to pass after\\n /// a fraud challenge is reported is indicated by the\\n /// `challengeDefeatTimeout`. After a successful fraud challenge\\n /// defeat timeout notification the fraud challenge is marked as\\n /// resolved, the stake of each operator is slashed, the ether\\n /// deposited is returned to the challenger and the challenger is\\n /// rewarded.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Closing or\\n /// Terminated state,\\n /// - The `walletPublicKey` and `sighash` calculated from\\n /// `preimageSha256` must identify an open fraud challenge,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time indicated by `challengeDefeatTimeout` must pass\\n /// after the challenge was reported.\\n function notifyFraudChallengeDefeatTimeout(\\n bytes calldata walletPublicKey,\\n uint32[] calldata walletMembersIDs,\\n bytes memory preimageSha256\\n ) external {\\n self.notifyFraudChallengeDefeatTimeout(\\n walletPublicKey,\\n walletMembersIDs,\\n preimageSha256\\n );\\n }\\n\\n /// @notice Allows the Governance to mark the given vault address as trusted\\n /// or no longer trusted. Vaults are not trusted by default.\\n /// Trusted vault must meet the following criteria:\\n /// - `IVault.receiveBalanceIncrease` must have a known, low gas\\n /// cost,\\n /// - `IVault.receiveBalanceIncrease` must never revert.\\n /// @dev Without restricting reveal only to trusted vaults, malicious\\n /// vaults not meeting the criteria would be able to nuke sweep proof\\n /// transactions executed by ECDSA wallet with deposits routed to\\n /// them.\\n /// @param vault The address of the vault.\\n /// @param isTrusted flag indicating whether the vault is trusted or not.\\n /// @dev Can only be called by the Governance.\\n function setVaultStatus(address vault, bool isTrusted)\\n external\\n onlyGovernance\\n {\\n self.isVaultTrusted[vault] = isTrusted;\\n emit VaultStatusUpdated(vault, isTrusted);\\n }\\n\\n /// @notice Allows the Governance to mark the given address as trusted\\n /// or no longer trusted SPV maintainer. Addresses are not trusted\\n /// as SPV maintainers by default.\\n /// @dev The SPV proof does not check whether the transaction is a part of\\n /// the Bitcoin mainnet, it only checks whether the transaction has been\\n /// mined performing the required amount of work as on Bitcoin mainnet.\\n /// The possibility of submitting SPV proofs is limited to trusted SPV\\n /// maintainers. The system expects transaction confirmations with the\\n /// required work accumulated, so trusted SPV maintainers can not prove\\n /// the transaction without providing the required Bitcoin proof of work.\\n /// Trusted maintainers address the issue of an economic game between\\n /// tBTC and Bitcoin mainnet where large Bitcoin mining pools can decide\\n /// to use their hash power to mine fake Bitcoin blocks to prove them in\\n /// tBTC instead of receiving Bitcoin miner rewards.\\n /// @param spvMaintainer The address of the SPV maintainer.\\n /// @param isTrusted flag indicating whether the address is trusted or not.\\n /// @dev Can only be called by the Governance.\\n function setSpvMaintainerStatus(address spvMaintainer, bool isTrusted)\\n external\\n onlyGovernance\\n {\\n self.isSpvMaintainer[spvMaintainer] = isTrusted;\\n emit SpvMaintainerStatusUpdated(spvMaintainer, isTrusted);\\n }\\n\\n /// @notice Updates parameters of deposits.\\n /// @param depositDustThreshold New value of the deposit dust threshold in\\n /// satoshis. It is the minimal amount that can be requested to\\n //// deposit. Value of this parameter must take into account the value\\n /// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters\\n /// in order to make requests that can incur the treasury and\\n /// transaction fee and still satisfy the depositor.\\n /// @param depositTreasuryFeeDivisor New value of the treasury fee divisor.\\n /// It is the divisor used to compute the treasury fee taken from\\n /// each deposit and transferred to the treasury upon sweep proof\\n /// submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @param depositTxMaxFee New value of the deposit tx max fee in satoshis.\\n /// It is the maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @param depositRevealAheadPeriod New value of the deposit reveal ahead\\n /// period parameter in seconds. It defines the length of the period\\n /// that must be preserved between the deposit reveal time and the\\n /// deposit refund locktime.\\n /// @dev Requirements:\\n /// - Deposit dust threshold must be greater than zero,\\n /// - Deposit dust threshold must be greater than deposit TX max fee,\\n /// - Deposit transaction max fee must be greater than zero.\\n function updateDepositParameters(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n ) external onlyGovernance {\\n self.updateDepositParameters(\\n depositDustThreshold,\\n depositTreasuryFeeDivisor,\\n depositTxMaxFee,\\n depositRevealAheadPeriod\\n );\\n }\\n\\n /// @notice Updates parameters of redemptions.\\n /// @param redemptionDustThreshold New value of the redemption dust\\n /// threshold in satoshis. It is the minimal amount that can be\\n /// requested for redemption. Value of this parameter must take into\\n /// account the value of `redemptionTreasuryFeeDivisor` and\\n /// `redemptionTxMaxFee` parameters in order to make requests that\\n /// can incur the treasury and transaction fee and still satisfy the\\n /// redeemer.\\n /// @param redemptionTreasuryFeeDivisor New value of the redemption\\n /// treasury fee divisor. It is the divisor used to compute the\\n /// treasury fee taken from each redemption request and transferred\\n /// to the treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @param redemptionTxMaxFee New value of the redemption transaction max\\n /// fee in satoshis. It is the maximum amount of BTC transaction fee\\n /// that can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction fee\\n /// is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @param redemptionTxMaxTotalFee New value of the redemption transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @param redemptionTimeout New value of the redemption timeout in seconds.\\n /// It is the time after which the redemption request can be reported\\n /// as timed out. It is counted from the moment when the redemption\\n /// request was created via `requestRedemption` call. Reported timed\\n /// out requests are cancelled and locked balance is returned to the\\n /// redeemer in full amount.\\n /// @param redemptionTimeoutSlashingAmount New value of the redemption\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for redemption timeout.\\n /// @param redemptionTimeoutNotifierRewardMultiplier New value of the\\n /// redemption timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a redemption timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Redemption dust threshold must be greater than moving funds dust\\n /// threshold,\\n /// - Redemption dust threshold must be greater than the redemption TX\\n /// max fee,\\n /// - Redemption transaction max fee must be greater than zero,\\n /// - Redemption transaction max total fee must be greater than or\\n /// equal to the redemption transaction per-request max fee,\\n /// - Redemption timeout must be greater than zero,\\n /// - Redemption timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateRedemptionParameters(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateRedemptionParameters(\\n redemptionDustThreshold,\\n redemptionTreasuryFeeDivisor,\\n redemptionTxMaxFee,\\n redemptionTxMaxTotalFee,\\n redemptionTimeout,\\n redemptionTimeoutSlashingAmount,\\n redemptionTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of moving funds.\\n /// @param movingFundsTxMaxTotalFee New value of the moving funds transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @param movingFundsDustThreshold New value of the moving funds dust\\n /// threshold. It is the minimal satoshi amount that makes sense to\\n /// be transferred during the moving funds process. Moving funds\\n /// wallets having their BTC balance below that value can begin\\n /// closing immediately as transferring such a low value may not be\\n /// possible due to BTC network fees.\\n /// @param movingFundsTimeoutResetDelay New value of the moving funds\\n /// timeout reset delay in seconds. It is the time after which the\\n /// moving funds timeout can be reset in case the target wallet\\n /// commitment cannot be submitted due to a lack of live wallets\\n /// in the system. It is counted from the moment when the wallet\\n /// was requested to move their funds and switched to the MovingFunds\\n /// state or from the moment the timeout was reset the last time.\\n /// @param movingFundsTimeout New value of the moving funds timeout in\\n /// seconds. It is the time after which the moving funds process can\\n /// be reported as timed out. It is counted from the moment when the\\n /// wallet was requested to move their funds and switched to the\\n /// MovingFunds state.\\n /// @param movingFundsTimeoutSlashingAmount New value of the moving funds\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for moving funds timeout.\\n /// @param movingFundsTimeoutNotifierRewardMultiplier New value of the\\n /// moving funds timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a moving funds timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @param movingFundsCommitmentGasOffset New value of the gas offset for\\n /// moving funds target wallet commitment transaction gas costs\\n /// reimbursement.\\n /// @param movedFundsSweepTxMaxTotalFee New value of the moved funds sweep\\n /// transaction max total fee in satoshis. It is the maximum amount\\n /// of the total BTC transaction fee that is acceptable in a single\\n /// moved funds sweep transaction. This is a _total_ max fee for the\\n /// entire moved funds sweep transaction.\\n /// @param movedFundsSweepTimeout New value of the moved funds sweep\\n /// timeout in seconds. It is the time after which the moved funds\\n /// sweep process can be reported as timed out. It is counted from\\n /// the moment when the wallet was requested to sweep the received\\n /// funds.\\n /// @param movedFundsSweepTimeoutSlashingAmount New value of the moved\\n /// funds sweep timeout slashing amount in T, it is the amount\\n /// slashed from each wallet member for moved funds sweep timeout.\\n /// @param movedFundsSweepTimeoutNotifierRewardMultiplier New value of\\n /// the moved funds sweep timeout notifier reward multiplier as\\n /// percentage, it determines the percentage of the notifier reward\\n /// from the staking contact the notifier of a moved funds sweep\\n /// timeout receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Moving funds transaction max total fee must be greater than zero,\\n /// - Moving funds dust threshold must be greater than zero and lower\\n /// than the redemption dust threshold,\\n /// - Moving funds timeout reset delay must be greater than zero,\\n /// - Moving funds timeout must be greater than the moving funds\\n /// timeout reset delay,\\n /// - Moving funds timeout notifier reward multiplier must be in the\\n /// range [0, 100],\\n /// - Moved funds sweep transaction max total fee must be greater than zero,\\n /// - Moved funds sweep timeout must be greater than zero,\\n /// - Moved funds sweep timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateMovingFundsParameters(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateMovingFundsParameters(\\n movingFundsTxMaxTotalFee,\\n movingFundsDustThreshold,\\n movingFundsTimeoutResetDelay,\\n movingFundsTimeout,\\n movingFundsTimeoutSlashingAmount,\\n movingFundsTimeoutNotifierRewardMultiplier,\\n movingFundsCommitmentGasOffset,\\n movedFundsSweepTxMaxTotalFee,\\n movedFundsSweepTimeout,\\n movedFundsSweepTimeoutSlashingAmount,\\n movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of wallets.\\n /// @param walletCreationPeriod New value of the wallet creation period in\\n /// seconds, determines how frequently a new wallet creation can be\\n /// requested.\\n /// @param walletCreationMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param walletCreationMaxBtcBalance New value of the wallet maximum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param walletClosureMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet closure.\\n /// @param walletMaxAge New value of the wallet maximum age in seconds,\\n /// indicates the maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @param walletMaxBtcTransfer New value of the wallet maximum BTC transfer\\n /// in satoshi, determines the maximum amount that can be transferred\\n // to a single target wallet during the moving funds process.\\n /// @param walletClosingPeriod New value of the wallet closing period in\\n /// seconds, determines the length of the wallet closing period,\\n // i.e. the period when the wallet remains in the Closing state\\n // and can be subject of deposit fraud challenges.\\n /// @dev Requirements:\\n /// - Wallet maximum BTC balance must be greater than the wallet\\n /// minimum BTC balance,\\n /// - Wallet maximum BTC transfer must be greater than zero,\\n /// - Wallet closing period must be greater than zero.\\n function updateWalletParameters(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n ) external onlyGovernance {\\n self.updateWalletParameters(\\n walletCreationPeriod,\\n walletCreationMinBtcBalance,\\n walletCreationMaxBtcBalance,\\n walletClosureMinBtcBalance,\\n walletMaxAge,\\n walletMaxBtcTransfer,\\n walletClosingPeriod\\n );\\n }\\n\\n /// @notice Updates parameters related to frauds.\\n /// @param fraudChallengeDepositAmount New value of the fraud challenge\\n /// deposit amount in wei, it is the amount of ETH the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @param fraudChallengeDefeatTimeout New value of the challenge defeat\\n /// timeout in seconds, it is the amount of time the wallet has to\\n /// defeat a fraud challenge. The value must be greater than zero.\\n /// @param fraudSlashingAmount New value of the fraud slashing amount in T,\\n /// it is the amount slashed from each wallet member for committing\\n /// a fraud.\\n /// @param fraudNotifierRewardMultiplier New value of the fraud notifier\\n /// reward multiplier as percentage, it determines the percentage of\\n /// the notifier reward from the staking contact the notifier of\\n /// a fraud receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Fraud challenge defeat timeout must be greater than 0,\\n /// - Fraud notifier reward multiplier must be in the range [0, 100].\\n function updateFraudParameters(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateFraudParameters(\\n fraudChallengeDepositAmount,\\n fraudChallengeDefeatTimeout,\\n fraudSlashingAmount,\\n fraudNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates treasury address. The treasury receives the system fees.\\n /// @param treasury New value of the treasury address.\\n /// @dev The treasury address must not be 0x0.\\n // slither-disable-next-line shadowing-local\\n function updateTreasury(address treasury) external onlyGovernance {\\n self.updateTreasury(treasury);\\n }\\n\\n /// @notice Collection of all revealed deposits indexed by\\n /// keccak256(fundingTxHash | fundingOutputIndex).\\n /// The fundingTxHash is bytes32 (ordered as in Bitcoin internally)\\n /// and fundingOutputIndex an uint32. This mapping may contain valid\\n /// and invalid deposits and the wallet is responsible for\\n /// validating them before attempting to execute a sweep.\\n function deposits(uint256 depositKey)\\n external\\n view\\n returns (Deposit.DepositRequest memory)\\n {\\n return self.deposits[depositKey];\\n }\\n\\n /// @notice Collection of all pending redemption requests indexed by\\n /// redemption key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The walletPubKeyHash is the 20-byte wallet's public key hash\\n /// (computed using Bitcoin HASH160 over the compressed ECDSA\\n /// public key) and `redeemerOutputScript` is a Bitcoin script\\n /// (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC as requested by the redeemer. Requests are added\\n /// to this mapping by the `requestRedemption` method (duplicates\\n /// not allowed) and are removed by one of the following methods:\\n /// - `submitRedemptionProof` in case the request was handled\\n /// successfully,\\n /// - `notifyRedemptionTimeout` in case the request was reported\\n /// to be timed out.\\n function pendingRedemptions(uint256 redemptionKey)\\n external\\n view\\n returns (Redemption.RedemptionRequest memory)\\n {\\n return self.pendingRedemptions[redemptionKey];\\n }\\n\\n /// @notice Collection of all timed out redemptions requests indexed by\\n /// redemption key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The walletPubKeyHash is the 20-byte wallet's public key hash\\n /// (computed using Bitcoin HASH160 over the compressed ECDSA\\n /// public key) and `redeemerOutputScript` is the Bitcoin script\\n /// (P2PKH, P2WPKH, P2SH or P2WSH) that is involved in the timed\\n /// out request.\\n /// Only one method can add to this mapping:\\n /// - `notifyRedemptionTimeout` which puts the redemption key\\n /// to this mapping based on a timed out request stored\\n /// previously in `pendingRedemptions` mapping.\\n /// Only one method can remove entries from this mapping:\\n /// - `submitRedemptionProof` in case the timed out redemption\\n /// request was a part of the proven transaction.\\n function timedOutRedemptions(uint256 redemptionKey)\\n external\\n view\\n returns (Redemption.RedemptionRequest memory)\\n {\\n return self.timedOutRedemptions[redemptionKey];\\n }\\n\\n /// @notice Collection of main UTXOs that are honestly spent indexed by\\n /// keccak256(fundingTxHash | fundingOutputIndex). The fundingTxHash\\n /// is bytes32 (ordered as in Bitcoin internally) and\\n /// fundingOutputIndex an uint32. A main UTXO is considered honestly\\n /// spent if it was used as an input of a transaction that have been\\n /// proven in the Bridge.\\n function spentMainUTXOs(uint256 utxoKey) external view returns (bool) {\\n return self.spentMainUTXOs[utxoKey];\\n }\\n\\n /// @notice Gets details about a registered wallet.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @return Wallet details.\\n function wallets(bytes20 walletPubKeyHash)\\n external\\n view\\n returns (Wallets.Wallet memory)\\n {\\n return self.registeredWallets[walletPubKeyHash];\\n }\\n\\n /// @notice Gets the public key hash of the active wallet.\\n /// @return The 20-byte public key hash (computed using Bitcoin HASH160\\n /// over the compressed ECDSA public key) of the active wallet.\\n /// Returns bytes20(0) if there is no active wallet at the moment.\\n function activeWalletPubKeyHash() external view returns (bytes20) {\\n return self.activeWalletPubKeyHash;\\n }\\n\\n /// @notice Gets the live wallets count.\\n /// @return The current count of wallets being in the Live state.\\n function liveWalletsCount() external view returns (uint32) {\\n return self.liveWalletsCount;\\n }\\n\\n /// @notice Returns the fraud challenge identified by the given key built\\n /// as keccak256(walletPublicKey|sighash).\\n function fraudChallenges(uint256 challengeKey)\\n external\\n view\\n returns (Fraud.FraudChallenge memory)\\n {\\n return self.fraudChallenges[challengeKey];\\n }\\n\\n /// @notice Collection of all moved funds sweep requests indexed by\\n /// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n /// The `movingFundsTxHash` is `bytes32` (ordered as in Bitcoin\\n /// internally) and `movingFundsOutputIndex` an `uint32`. Each entry\\n /// is actually an UTXO representing the moved funds and is supposed\\n /// to be swept with the current main UTXO of the recipient wallet.\\n /// @param requestKey Request key built as\\n /// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n /// @return Details of the moved funds sweep request.\\n function movedFundsSweepRequests(uint256 requestKey)\\n external\\n view\\n returns (MovingFunds.MovedFundsSweepRequest memory)\\n {\\n return self.movedFundsSweepRequests[requestKey];\\n }\\n\\n /// @notice Indicates if the vault with the given address is trusted or not.\\n /// Depositors can route their revealed deposits only to trusted\\n /// vaults and have trusted vaults notified about new deposits as\\n /// soon as these deposits get swept. Vaults not trusted by the\\n /// Bridge can still be used by Bank balance owners on their own\\n /// responsibility - anyone can approve their Bank balance to any\\n /// address.\\n function isVaultTrusted(address vault) external view returns (bool) {\\n return self.isVaultTrusted[vault];\\n }\\n\\n /// @notice Returns the current values of Bridge deposit parameters.\\n /// @return depositDustThreshold The minimal amount that can be requested\\n /// to deposit. Value of this parameter must take into account the\\n /// value of `depositTreasuryFeeDivisor` and `depositTxMaxFee`\\n /// parameters in order to make requests that can incur the\\n /// treasury and transaction fee and still satisfy the depositor.\\n /// @return depositTreasuryFeeDivisor Divisor used to compute the treasury\\n /// fee taken from each deposit and transferred to the treasury upon\\n /// sweep proof submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @return depositTxMaxFee Maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @return depositRevealAheadPeriod Defines the length of the period that\\n /// must be preserved between the deposit reveal time and the\\n /// deposit refund locktime. For example, if the deposit become\\n /// refundable on August 1st, and the ahead period is 7 days, the\\n /// latest moment for deposit reveal is July 25th. Value in seconds.\\n function depositParameters()\\n external\\n view\\n returns (\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n )\\n {\\n depositDustThreshold = self.depositDustThreshold;\\n depositTreasuryFeeDivisor = self.depositTreasuryFeeDivisor;\\n depositTxMaxFee = self.depositTxMaxFee;\\n depositRevealAheadPeriod = self.depositRevealAheadPeriod;\\n }\\n\\n /// @notice Returns the current values of Bridge redemption parameters.\\n /// @return redemptionDustThreshold The minimal amount that can be requested\\n /// for redemption. Value of this parameter must take into account\\n /// the value of `redemptionTreasuryFeeDivisor` and `redemptionTxMaxFee`\\n /// parameters in order to make requests that can incur the\\n /// treasury and transaction fee and still satisfy the redeemer.\\n /// @return redemptionTreasuryFeeDivisor Divisor used to compute the treasury\\n /// fee taken from each redemption request and transferred to the\\n /// treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @return redemptionTxMaxFee Maximum amount of BTC transaction fee that\\n /// can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction\\n /// fee is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @return redemptionTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @return redemptionTimeout Time after which the redemption request can be\\n /// reported as timed out. It is counted from the moment when the\\n /// redemption request was created via `requestRedemption` call.\\n /// Reported timed out requests are cancelled and locked balance is\\n /// returned to the redeemer in full amount.\\n /// @return redemptionTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a redemption timeout.\\n /// @return redemptionTimeoutNotifierRewardMultiplier The percentage of the\\n /// notifier reward from the staking contract the notifier of a\\n /// redemption timeout receives. The value is in the range [0, 100].\\n function redemptionParameters()\\n external\\n view\\n returns (\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n )\\n {\\n redemptionDustThreshold = self.redemptionDustThreshold;\\n redemptionTreasuryFeeDivisor = self.redemptionTreasuryFeeDivisor;\\n redemptionTxMaxFee = self.redemptionTxMaxFee;\\n redemptionTxMaxTotalFee = self.redemptionTxMaxTotalFee;\\n redemptionTimeout = self.redemptionTimeout;\\n redemptionTimeoutSlashingAmount = self.redemptionTimeoutSlashingAmount;\\n redemptionTimeoutNotifierRewardMultiplier = self\\n .redemptionTimeoutNotifierRewardMultiplier;\\n }\\n\\n /// @notice Returns the current values of Bridge moving funds between\\n /// wallets parameters.\\n /// @return movingFundsTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @return movingFundsDustThreshold The minimal satoshi amount that makes\\n /// sense to be transferred during the moving funds process. Moving\\n /// funds wallets having their BTC balance below that value can\\n /// begin closing immediately as transferring such a low value may\\n /// not be possible due to BTC network fees.\\n /// @return movingFundsTimeoutResetDelay Time after which the moving funds\\n /// timeout can be reset in case the target wallet commitment\\n /// cannot be submitted due to a lack of live wallets in the system.\\n /// It is counted from the moment when the wallet was requested to\\n /// move their funds and switched to the MovingFunds state or from\\n /// the moment the timeout was reset the last time. Value in seconds\\n /// This value should be lower than the value of the\\n /// `movingFundsTimeout`.\\n /// @return movingFundsTimeout Time after which the moving funds process\\n /// can be reported as timed out. It is counted from the moment\\n /// when the wallet was requested to move their funds and switched\\n /// to the MovingFunds state. Value in seconds.\\n /// @return movingFundsTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a moving funds timeout.\\n /// @return movingFundsTimeoutNotifierRewardMultiplier The percentage of the\\n /// notifier reward from the staking contract the notifier of a\\n /// moving funds timeout receives. The value is in the range [0, 100].\\n /// @return movingFundsCommitmentGasOffset The gas offset used for the\\n /// moving funds target wallet commitment transaction cost\\n /// reimbursement.\\n /// @return movedFundsSweepTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single moved funds\\n /// sweep transaction. This is a _total_ max fee for the entire\\n /// moved funds sweep transaction.\\n /// @return movedFundsSweepTimeout Time after which the moved funds sweep\\n /// process can be reported as timed out. It is counted from the\\n /// moment when the wallet was requested to sweep the received funds.\\n /// Value in seconds.\\n /// @return movedFundsSweepTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a moved funds sweep timeout.\\n /// @return movedFundsSweepTimeoutNotifierRewardMultiplier The percentage\\n /// of the notifier reward from the staking contract the notifier\\n /// of a moved funds sweep timeout receives. The value is in the\\n /// range [0, 100].\\n function movingFundsParameters()\\n external\\n view\\n returns (\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n )\\n {\\n movingFundsTxMaxTotalFee = self.movingFundsTxMaxTotalFee;\\n movingFundsDustThreshold = self.movingFundsDustThreshold;\\n movingFundsTimeoutResetDelay = self.movingFundsTimeoutResetDelay;\\n movingFundsTimeout = self.movingFundsTimeout;\\n movingFundsTimeoutSlashingAmount = self\\n .movingFundsTimeoutSlashingAmount;\\n movingFundsTimeoutNotifierRewardMultiplier = self\\n .movingFundsTimeoutNotifierRewardMultiplier;\\n movingFundsCommitmentGasOffset = self.movingFundsCommitmentGasOffset;\\n movedFundsSweepTxMaxTotalFee = self.movedFundsSweepTxMaxTotalFee;\\n movedFundsSweepTimeout = self.movedFundsSweepTimeout;\\n movedFundsSweepTimeoutSlashingAmount = self\\n .movedFundsSweepTimeoutSlashingAmount;\\n movedFundsSweepTimeoutNotifierRewardMultiplier = self\\n .movedFundsSweepTimeoutNotifierRewardMultiplier;\\n }\\n\\n /// @return walletCreationPeriod Determines how frequently a new wallet\\n /// creation can be requested. Value in seconds.\\n /// @return walletCreationMinBtcBalance The minimum BTC threshold in satoshi\\n /// that is used to decide about wallet creation.\\n /// @return walletCreationMaxBtcBalance The maximum BTC threshold in satoshi\\n /// that is used to decide about wallet creation.\\n /// @return walletClosureMinBtcBalance The minimum BTC threshold in satoshi\\n /// that is used to decide about wallet closure.\\n /// @return walletMaxAge The maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @return walletMaxBtcTransfer The maximum BTC amount in satoshi than\\n /// can be transferred to a single target wallet during the moving\\n /// funds process.\\n /// @return walletClosingPeriod Determines the length of the wallet closing\\n /// period, i.e. the period when the wallet remains in the Closing\\n /// state and can be subject of deposit fraud challenges. Value\\n /// in seconds.\\n function walletParameters()\\n external\\n view\\n returns (\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n )\\n {\\n walletCreationPeriod = self.walletCreationPeriod;\\n walletCreationMinBtcBalance = self.walletCreationMinBtcBalance;\\n walletCreationMaxBtcBalance = self.walletCreationMaxBtcBalance;\\n walletClosureMinBtcBalance = self.walletClosureMinBtcBalance;\\n walletMaxAge = self.walletMaxAge;\\n walletMaxBtcTransfer = self.walletMaxBtcTransfer;\\n walletClosingPeriod = self.walletClosingPeriod;\\n }\\n\\n /// @notice Returns the current values of Bridge fraud parameters.\\n /// @return fraudChallengeDepositAmount The amount of ETH in wei the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @return fraudChallengeDefeatTimeout The amount of time the wallet has to\\n /// defeat a fraud challenge.\\n /// @return fraudSlashingAmount The amount slashed from each wallet member\\n /// for committing a fraud.\\n /// @return fraudNotifierRewardMultiplier The percentage of the notifier\\n /// reward from the staking contract the notifier of a fraud\\n /// receives. The value is in the range [0, 100].\\n function fraudParameters()\\n external\\n view\\n returns (\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n )\\n {\\n fraudChallengeDepositAmount = self.fraudChallengeDepositAmount;\\n fraudChallengeDefeatTimeout = self.fraudChallengeDefeatTimeout;\\n fraudSlashingAmount = self.fraudSlashingAmount;\\n fraudNotifierRewardMultiplier = self.fraudNotifierRewardMultiplier;\\n }\\n\\n /// @notice Returns the addresses of contracts Bridge is interacting with.\\n /// @return bank Address of the Bank the Bridge belongs to.\\n /// @return relay Address of the Bitcoin relay providing the current Bitcoin\\n /// network difficulty.\\n /// @return ecdsaWalletRegistry Address of the ECDSA Wallet Registry.\\n /// @return reimbursementPool Address of the Reimbursement Pool.\\n function contractReferences()\\n external\\n view\\n returns (\\n Bank bank,\\n IRelay relay,\\n EcdsaWalletRegistry ecdsaWalletRegistry,\\n ReimbursementPool reimbursementPool\\n )\\n {\\n bank = self.bank;\\n relay = self.relay;\\n ecdsaWalletRegistry = self.ecdsaWalletRegistry;\\n reimbursementPool = self.reimbursementPool;\\n }\\n\\n /// @notice Address where the deposit treasury fees will be sent to.\\n /// Treasury takes part in the operators rewarding process.\\n function treasury() external view returns (address) {\\n return self.treasury;\\n }\\n\\n /// @notice The number of confirmations on the Bitcoin chain required to\\n /// successfully evaluate an SPV proof.\\n function txProofDifficultyFactor() external view returns (uint256) {\\n return self.txProofDifficultyFactor;\\n }\\n}\\n\",\"keccak256\":\"0x93e84a966cd330eb075d708cb65018e21aed9a19bddc96c6e4e18ef8dc1dfc56\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/BridgeState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {IWalletRegistry as EcdsaWalletRegistry} from \\\"@keep-network/ecdsa/contracts/api/IWalletRegistry.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\\\";\\n\\nimport \\\"./IRelay.sol\\\";\\nimport \\\"./Deposit.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./Fraud.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\nlibrary BridgeState {\\n struct Storage {\\n // Address of the Bank the Bridge belongs to.\\n Bank bank;\\n // Bitcoin relay providing the current Bitcoin network difficulty.\\n IRelay relay;\\n // The number of confirmations on the Bitcoin chain required to\\n // successfully evaluate an SPV proof.\\n uint96 txProofDifficultyFactor;\\n // ECDSA Wallet Registry contract handle.\\n EcdsaWalletRegistry ecdsaWalletRegistry;\\n // Reimbursement Pool contract handle.\\n ReimbursementPool reimbursementPool;\\n // Address where the deposit and redemption treasury fees will be sent\\n // to. Treasury takes part in the operators rewarding process.\\n address treasury;\\n // Move depositDustThreshold to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __treasuryAlignmentGap;\\n // The minimal amount that can be requested to deposit.\\n // Value of this parameter must take into account the value of\\n // `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters in order\\n // to make requests that can incur the treasury and transaction fee and\\n // still satisfy the depositor.\\n uint64 depositDustThreshold;\\n // Divisor used to compute the treasury fee taken from each deposit and\\n // transferred to the treasury upon sweep proof submission. That fee is\\n // computed as follows:\\n // `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n // For example, if the treasury fee needs to be 2% of each deposit,\\n // the `depositTreasuryFeeDivisor` should be set to `50` because\\n // `1/50 = 0.02 = 2%`.\\n uint64 depositTreasuryFeeDivisor;\\n // Maximum amount of BTC transaction fee that can be incurred by each\\n // swept deposit being part of the given sweep transaction. If the\\n // maximum BTC transaction fee is exceeded, such transaction is\\n // considered a fraud.\\n //\\n // This is a per-deposit input max fee for the sweep transaction.\\n uint64 depositTxMaxFee;\\n // Defines the length of the period that must be preserved between\\n // the deposit reveal time and the deposit refund locktime. For example,\\n // if the deposit become refundable on August 1st, and the ahead period\\n // is 7 days, the latest moment for deposit reveal is July 25th.\\n // Value in seconds. The value equal to zero disables the validation\\n // of this parameter.\\n uint32 depositRevealAheadPeriod;\\n // Move movingFundsTxMaxTotalFee to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __depositAlignmentGap;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single moving funds transaction.\\n //\\n // This is a TOTAL max fee for the moving funds transaction. Note\\n // that `depositTxMaxFee` is per single deposit and `redemptionTxMaxFee`\\n // is per single redemption. `movingFundsTxMaxTotalFee` is a total\\n // fee for the entire transaction.\\n uint64 movingFundsTxMaxTotalFee;\\n // The minimal satoshi amount that makes sense to be transferred during\\n // the moving funds process. Moving funds wallets having their BTC\\n // balance below that value can begin closing immediately as\\n // transferring such a low value may not be possible due to\\n // BTC network fees. The value of this parameter must always be lower\\n // than `redemptionDustThreshold` in order to prevent redemption requests\\n // with values lower or equal to `movingFundsDustThreshold`.\\n uint64 movingFundsDustThreshold;\\n // Time after which the moving funds timeout can be reset in case the\\n // target wallet commitment cannot be submitted due to a lack of live\\n // wallets in the system. It is counted from the moment when the wallet\\n // was requested to move their funds and switched to the MovingFunds\\n // state or from the moment the timeout was reset the last time.\\n // Value in seconds. This value should be lower than the value\\n // of the `movingFundsTimeout`.\\n uint32 movingFundsTimeoutResetDelay;\\n // Time after which the moving funds process can be reported as\\n // timed out. It is counted from the moment when the wallet\\n // was requested to move their funds and switched to the MovingFunds\\n // state. Value in seconds.\\n uint32 movingFundsTimeout;\\n // The amount of stake slashed from each member of a wallet for a moving\\n // funds timeout.\\n uint96 movingFundsTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a moving funds timeout receives. The value is in the\\n // range [0, 100].\\n uint32 movingFundsTimeoutNotifierRewardMultiplier;\\n // The gas offset used for the target wallet commitment transaction cost\\n // reimbursement.\\n uint16 movingFundsCommitmentGasOffset;\\n // Move movedFundsSweepTxMaxTotalFee to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __movingFundsAlignmentGap;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single moved funds sweep transaction.\\n //\\n // This is a TOTAL max fee for the moved funds sweep transaction. Note\\n // that `depositTxMaxFee` is per single deposit and `redemptionTxMaxFee`\\n // is per single redemption. `movedFundsSweepTxMaxTotalFee` is a total\\n // fee for the entire transaction.\\n uint64 movedFundsSweepTxMaxTotalFee;\\n // Time after which the moved funds sweep process can be reported as\\n // timed out. It is counted from the moment when the recipient wallet\\n // was requested to sweep the received funds. Value in seconds.\\n uint32 movedFundsSweepTimeout;\\n // The amount of stake slashed from each member of a wallet for a moved\\n // funds sweep timeout.\\n uint96 movedFundsSweepTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a moved funds sweep timeout receives. The value is\\n // in the range [0, 100].\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier;\\n // The minimal amount that can be requested for redemption.\\n // Value of this parameter must take into account the value of\\n // `redemptionTreasuryFeeDivisor` and `redemptionTxMaxFee`\\n // parameters in order to make requests that can incur the\\n // treasury and transaction fee and still satisfy the redeemer.\\n // Additionally, the value of this parameter must always be greater\\n // than `movingFundsDustThreshold` in order to prevent redemption\\n // requests with values lower or equal to `movingFundsDustThreshold`.\\n uint64 redemptionDustThreshold;\\n // Divisor used to compute the treasury fee taken from each\\n // redemption request and transferred to the treasury upon\\n // successful request finalization. That fee is computed as follows:\\n // `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n // For example, if the treasury fee needs to be 2% of each\\n // redemption request, the `redemptionTreasuryFeeDivisor` should\\n // be set to `50` because `1/50 = 0.02 = 2%`.\\n uint64 redemptionTreasuryFeeDivisor;\\n // Maximum amount of BTC transaction fee that can be incurred by\\n // each redemption request being part of the given redemption\\n // transaction. If the maximum BTC transaction fee is exceeded, such\\n // transaction is considered a fraud.\\n //\\n // This is a per-redemption output max fee for the redemption\\n // transaction.\\n uint64 redemptionTxMaxFee;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single redemption transaction.\\n //\\n // This is a TOTAL max fee for the redemption transaction. Note\\n // that the `redemptionTxMaxFee` is per single redemption.\\n // `redemptionTxMaxTotalFee` is a total fee for the entire transaction.\\n uint64 redemptionTxMaxTotalFee;\\n // Move redemptionTimeout to the next storage slot for a more efficient\\n // variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __redemptionAlignmentGap;\\n // Time after which the redemption request can be reported as\\n // timed out. It is counted from the moment when the redemption\\n // request was created via `requestRedemption` call. Reported\\n // timed out requests are cancelled and locked TBTC is returned\\n // to the redeemer in full amount.\\n uint32 redemptionTimeout;\\n // The amount of stake slashed from each member of a wallet for a\\n // redemption timeout.\\n uint96 redemptionTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a redemption timeout receives. The value is in the\\n // range [0, 100].\\n uint32 redemptionTimeoutNotifierRewardMultiplier;\\n // The amount of ETH in wei the party challenging the wallet for fraud\\n // needs to deposit.\\n uint96 fraudChallengeDepositAmount;\\n // The amount of time the wallet has to defeat a fraud challenge.\\n uint32 fraudChallengeDefeatTimeout;\\n // The amount of stake slashed from each member of a wallet for a fraud.\\n uint96 fraudSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a fraud receives. The value is in the range [0, 100].\\n uint32 fraudNotifierRewardMultiplier;\\n // Determines how frequently a new wallet creation can be requested.\\n // Value in seconds.\\n uint32 walletCreationPeriod;\\n // The minimum BTC threshold in satoshi that is used to decide about\\n // wallet creation. Specifically, we allow for the creation of a new\\n // wallet if the active wallet is old enough and their amount of BTC\\n // is greater than or equal this threshold.\\n uint64 walletCreationMinBtcBalance;\\n // The maximum BTC threshold in satoshi that is used to decide about\\n // wallet creation. Specifically, we allow for the creation of a new\\n // wallet if the active wallet's amount of BTC is greater than or equal\\n // this threshold, regardless of the active wallet's age.\\n uint64 walletCreationMaxBtcBalance;\\n // The minimum BTC threshold in satoshi that is used to decide about\\n // wallet closing. Specifically, we allow for the closure of the given\\n // wallet if their amount of BTC is lesser than this threshold,\\n // regardless of the wallet's age.\\n uint64 walletClosureMinBtcBalance;\\n // The maximum age of a wallet in seconds, after which the wallet\\n // moving funds process can be requested.\\n uint32 walletMaxAge;\\n // 20-byte wallet public key hash being reference to the currently\\n // active wallet. Can be unset to the zero value under certain\\n // circumstances.\\n bytes20 activeWalletPubKeyHash;\\n // The current number of wallets in the Live state.\\n uint32 liveWalletsCount;\\n // The maximum BTC amount in satoshi than can be transferred to a single\\n // target wallet during the moving funds process.\\n uint64 walletMaxBtcTransfer;\\n // Determines the length of the wallet closing period, i.e. the period\\n // when the wallet remains in the Closing state and can be subject\\n // of deposit fraud challenges. This value is in seconds and should be\\n // greater than the deposit refund time plus some time margin.\\n uint32 walletClosingPeriod;\\n // Collection of all revealed deposits indexed by\\n // `keccak256(fundingTxHash | fundingOutputIndex)`.\\n // The `fundingTxHash` is `bytes32` (ordered as in Bitcoin internally)\\n // and `fundingOutputIndex` an `uint32`. This mapping may contain valid\\n // and invalid deposits and the wallet is responsible for validating\\n // them before attempting to execute a sweep.\\n mapping(uint256 => Deposit.DepositRequest) deposits;\\n // Indicates if the vault with the given address is trusted.\\n // Depositors can route their revealed deposits only to trusted vaults\\n // and have trusted vaults notified about new deposits as soon as these\\n // deposits get swept. Vaults not trusted by the Bridge can still be\\n // used by Bank balance owners on their own responsibility - anyone can\\n // approve their Bank balance to any address.\\n mapping(address => bool) isVaultTrusted;\\n // Indicates if the address is a trusted SPV maintainer.\\n // The SPV proof does not check whether the transaction is a part of the\\n // Bitcoin mainnet, it only checks whether the transaction has been\\n // mined performing the required amount of work as on Bitcoin mainnet.\\n // The possibility of submitting SPV proofs is limited to trusted SPV\\n // maintainers. The system expects transaction confirmations with the\\n // required work accumulated, so trusted SPV maintainers can not prove\\n // the transaction without providing the required Bitcoin proof of work.\\n // Trusted maintainers address the issue of an economic game between\\n // tBTC and Bitcoin mainnet where large Bitcoin mining pools can decide\\n // to use their hash power to mine fake Bitcoin blocks to prove them in\\n // tBTC instead of receiving Bitcoin miner rewards.\\n mapping(address => bool) isSpvMaintainer;\\n // Collection of all moved funds sweep requests indexed by\\n // `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n // The `movingFundsTxHash` is `bytes32` (ordered as in Bitcoin\\n // internally) and `movingFundsOutputIndex` an `uint32`. Each entry\\n // is actually an UTXO representing the moved funds and is supposed\\n // to be swept with the current main UTXO of the recipient wallet.\\n mapping(uint256 => MovingFunds.MovedFundsSweepRequest) movedFundsSweepRequests;\\n // Collection of all pending redemption requests indexed by\\n // redemption key built as\\n // `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n // The `walletPubKeyHash` is the 20-byte wallet's public key hash\\n // (computed using Bitcoin HASH160 over the compressed ECDSA\\n // public key) and `redeemerOutputScript` is a Bitcoin script\\n // (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n // redeemed BTC as requested by the redeemer. Requests are added\\n // to this mapping by the `requestRedemption` method (duplicates\\n // not allowed) and are removed by one of the following methods:\\n // - `submitRedemptionProof` in case the request was handled\\n // successfully,\\n // - `notifyRedemptionTimeout` in case the request was reported\\n // to be timed out.\\n mapping(uint256 => Redemption.RedemptionRequest) pendingRedemptions;\\n // Collection of all timed out redemptions requests indexed by\\n // redemption key built as\\n // `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n // The `walletPubKeyHash` is the 20-byte wallet's public key hash\\n // (computed using Bitcoin HASH160 over the compressed ECDSA\\n // public key) and `redeemerOutputScript` is the Bitcoin script\\n // (P2PKH, P2WPKH, P2SH or P2WSH) that is involved in the timed\\n // out request.\\n // Only one method can add to this mapping:\\n // - `notifyRedemptionTimeout` which puts the redemption key to this\\n // mapping based on a timed out request stored previously in\\n // `pendingRedemptions` mapping.\\n // Only one method can remove entries from this mapping:\\n // - `submitRedemptionProof` in case the timed out redemption request\\n // was a part of the proven transaction.\\n mapping(uint256 => Redemption.RedemptionRequest) timedOutRedemptions;\\n // Collection of all submitted fraud challenges indexed by challenge\\n // key built as `keccak256(walletPublicKey|sighash)`.\\n mapping(uint256 => Fraud.FraudChallenge) fraudChallenges;\\n // Collection of main UTXOs that are honestly spent indexed by\\n // `keccak256(fundingTxHash | fundingOutputIndex)`. The `fundingTxHash`\\n // is `bytes32` (ordered as in Bitcoin internally) and\\n // `fundingOutputIndex` an `uint32`. A main UTXO is considered honestly\\n // spent if it was used as an input of a transaction that have been\\n // proven in the Bridge.\\n mapping(uint256 => bool) spentMainUTXOs;\\n // Maps the 20-byte wallet public key hash (computed using Bitcoin\\n // HASH160 over the compressed ECDSA public key) to the basic wallet\\n // information like state and pending redemptions value.\\n mapping(bytes20 => Wallets.Wallet) registeredWallets;\\n // Reserved storage space in case we need to add more variables.\\n // The convention from OpenZeppelin suggests the storage space should\\n // add up to 50 slots. Here we want to have more slots as there are\\n // planned upgrades of the Bridge contract. If more entires are added to\\n // the struct in the upcoming versions we need to reduce the array size.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[50] __gap;\\n }\\n\\n event DepositParametersUpdated(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n\\n event RedemptionParametersUpdated(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n );\\n\\n event MovingFundsParametersUpdated(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n\\n event WalletParametersUpdated(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n );\\n\\n event FraudParametersUpdated(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n );\\n\\n event TreasuryUpdated(address treasury);\\n\\n /// @notice Updates parameters of deposits.\\n /// @param _depositDustThreshold New value of the deposit dust threshold in\\n /// satoshis. It is the minimal amount that can be requested to\\n //// deposit. Value of this parameter must take into account the value\\n /// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters\\n /// in order to make requests that can incur the treasury and\\n /// transaction fee and still satisfy the depositor.\\n /// @param _depositTreasuryFeeDivisor New value of the treasury fee divisor.\\n /// It is the divisor used to compute the treasury fee taken from\\n /// each deposit and transferred to the treasury upon sweep proof\\n /// submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @param _depositTxMaxFee New value of the deposit tx max fee in satoshis.\\n /// It is the maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @param _depositRevealAheadPeriod New value of the deposit reveal ahead\\n /// period parameter in seconds. It defines the length of the period\\n /// that must be preserved between the deposit reveal time and the\\n /// deposit refund locktime.\\n /// @dev Requirements:\\n /// - Deposit dust threshold must be greater than zero,\\n /// - Deposit dust threshold must be greater than deposit TX max fee,\\n /// - Deposit transaction max fee must be greater than zero.\\n function updateDepositParameters(\\n Storage storage self,\\n uint64 _depositDustThreshold,\\n uint64 _depositTreasuryFeeDivisor,\\n uint64 _depositTxMaxFee,\\n uint32 _depositRevealAheadPeriod\\n ) internal {\\n require(\\n _depositDustThreshold > 0,\\n \\\"Deposit dust threshold must be greater than zero\\\"\\n );\\n\\n require(\\n _depositDustThreshold > _depositTxMaxFee,\\n \\\"Deposit dust threshold must be greater than deposit TX max fee\\\"\\n );\\n\\n require(\\n _depositTxMaxFee > 0,\\n \\\"Deposit transaction max fee must be greater than zero\\\"\\n );\\n\\n self.depositDustThreshold = _depositDustThreshold;\\n self.depositTreasuryFeeDivisor = _depositTreasuryFeeDivisor;\\n self.depositTxMaxFee = _depositTxMaxFee;\\n self.depositRevealAheadPeriod = _depositRevealAheadPeriod;\\n\\n emit DepositParametersUpdated(\\n _depositDustThreshold,\\n _depositTreasuryFeeDivisor,\\n _depositTxMaxFee,\\n _depositRevealAheadPeriod\\n );\\n }\\n\\n /// @notice Updates parameters of redemptions.\\n /// @param _redemptionDustThreshold New value of the redemption dust\\n /// threshold in satoshis. It is the minimal amount that can be\\n /// requested for redemption. Value of this parameter must take into\\n /// account the value of `redemptionTreasuryFeeDivisor` and\\n /// `redemptionTxMaxFee` parameters in order to make requests that\\n /// can incur the treasury and transaction fee and still satisfy the\\n /// redeemer.\\n /// @param _redemptionTreasuryFeeDivisor New value of the redemption\\n /// treasury fee divisor. It is the divisor used to compute the\\n /// treasury fee taken from each redemption request and transferred\\n /// to the treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @param _redemptionTxMaxFee New value of the redemption transaction max\\n /// fee in satoshis. It is the maximum amount of BTC transaction fee\\n /// that can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction fee\\n /// is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @param _redemptionTxMaxTotalFee New value of the redemption transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @param _redemptionTimeout New value of the redemption timeout in seconds.\\n /// It is the time after which the redemption request can be reported\\n /// as timed out. It is counted from the moment when the redemption\\n /// request was created via `requestRedemption` call. Reported timed\\n /// out requests are cancelled and locked TBTC is returned to the\\n /// redeemer in full amount.\\n /// @param _redemptionTimeoutSlashingAmount New value of the redemption\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for redemption timeout.\\n /// @param _redemptionTimeoutNotifierRewardMultiplier New value of the\\n /// redemption timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a redemption timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Redemption dust threshold must be greater than moving funds dust\\n /// threshold,\\n /// - Redemption dust threshold must be greater than the redemption TX\\n /// max fee,\\n /// - Redemption transaction max fee must be greater than zero,\\n /// - Redemption transaction max total fee must be greater than or\\n /// equal to the redemption transaction per-request max fee,\\n /// - Redemption timeout must be greater than zero,\\n /// - Redemption timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateRedemptionParameters(\\n Storage storage self,\\n uint64 _redemptionDustThreshold,\\n uint64 _redemptionTreasuryFeeDivisor,\\n uint64 _redemptionTxMaxFee,\\n uint64 _redemptionTxMaxTotalFee,\\n uint32 _redemptionTimeout,\\n uint96 _redemptionTimeoutSlashingAmount,\\n uint32 _redemptionTimeoutNotifierRewardMultiplier\\n ) internal {\\n require(\\n _redemptionDustThreshold > self.movingFundsDustThreshold,\\n \\\"Redemption dust threshold must be greater than moving funds dust threshold\\\"\\n );\\n\\n require(\\n _redemptionDustThreshold > _redemptionTxMaxFee,\\n \\\"Redemption dust threshold must be greater than redemption TX max fee\\\"\\n );\\n\\n require(\\n _redemptionTxMaxFee > 0,\\n \\\"Redemption transaction max fee must be greater than zero\\\"\\n );\\n\\n require(\\n _redemptionTxMaxTotalFee >= _redemptionTxMaxFee,\\n \\\"Redemption transaction max total fee must be greater than or equal to the redemption transaction per-request max fee\\\"\\n );\\n\\n require(\\n _redemptionTimeout > 0,\\n \\\"Redemption timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _redemptionTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Redemption timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.redemptionDustThreshold = _redemptionDustThreshold;\\n self.redemptionTreasuryFeeDivisor = _redemptionTreasuryFeeDivisor;\\n self.redemptionTxMaxFee = _redemptionTxMaxFee;\\n self.redemptionTxMaxTotalFee = _redemptionTxMaxTotalFee;\\n self.redemptionTimeout = _redemptionTimeout;\\n self.redemptionTimeoutSlashingAmount = _redemptionTimeoutSlashingAmount;\\n self\\n .redemptionTimeoutNotifierRewardMultiplier = _redemptionTimeoutNotifierRewardMultiplier;\\n\\n emit RedemptionParametersUpdated(\\n _redemptionDustThreshold,\\n _redemptionTreasuryFeeDivisor,\\n _redemptionTxMaxFee,\\n _redemptionTxMaxTotalFee,\\n _redemptionTimeout,\\n _redemptionTimeoutSlashingAmount,\\n _redemptionTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of moving funds.\\n /// @param _movingFundsTxMaxTotalFee New value of the moving funds transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @param _movingFundsDustThreshold New value of the moving funds dust\\n /// threshold. It is the minimal satoshi amount that makes sense to\\n /// be transferred during the moving funds process. Moving funds\\n /// wallets having their BTC balance below that value can begin\\n /// closing immediately as transferring such a low value may not be\\n /// possible due to BTC network fees.\\n /// @param _movingFundsTimeoutResetDelay New value of the moving funds\\n /// timeout reset delay in seconds. It is the time after which the\\n /// moving funds timeout can be reset in case the target wallet\\n /// commitment cannot be submitted due to a lack of live wallets\\n /// in the system. It is counted from the moment when the wallet\\n /// was requested to move their funds and switched to the MovingFunds\\n /// state or from the moment the timeout was reset the last time.\\n /// @param _movingFundsTimeout New value of the moving funds timeout in\\n /// seconds. It is the time after which the moving funds process can\\n /// be reported as timed out. It is counted from the moment when the\\n /// wallet was requested to move their funds and switched to the\\n /// MovingFunds state.\\n /// @param _movingFundsTimeoutSlashingAmount New value of the moving funds\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for moving funds timeout.\\n /// @param _movingFundsTimeoutNotifierRewardMultiplier New value of the\\n /// moving funds timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a moving funds timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @param _movingFundsCommitmentGasOffset New value of the gas offset for\\n /// moving funds target wallet commitment transaction gas costs\\n /// reimbursement.\\n /// @param _movedFundsSweepTxMaxTotalFee New value of the moved funds sweep\\n /// transaction max total fee in satoshis. It is the maximum amount\\n /// of the total BTC transaction fee that is acceptable in a single\\n /// moved funds sweep transaction. This is a _total_ max fee for the\\n /// entire moved funds sweep transaction.\\n /// @param _movedFundsSweepTimeout New value of the moved funds sweep\\n /// timeout in seconds. It is the time after which the moved funds\\n /// sweep process can be reported as timed out. It is counted from\\n /// the moment when the wallet was requested to sweep the received\\n /// funds.\\n /// @param _movedFundsSweepTimeoutSlashingAmount New value of the moved\\n /// funds sweep timeout slashing amount in T, it is the amount\\n /// slashed from each wallet member for moved funds sweep timeout.\\n /// @param _movedFundsSweepTimeoutNotifierRewardMultiplier New value of\\n /// the moved funds sweep timeout notifier reward multiplier as\\n /// percentage, it determines the percentage of the notifier reward\\n /// from the staking contact the notifier of a moved funds sweep\\n /// timeout receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Moving funds transaction max total fee must be greater than zero,\\n /// - Moving funds dust threshold must be greater than zero and lower\\n /// than the redemption dust threshold,\\n /// - Moving funds timeout reset delay must be greater than zero,\\n /// - Moving funds timeout must be greater than the moving funds\\n /// timeout reset delay,\\n /// - Moving funds timeout notifier reward multiplier must be in the\\n /// range [0, 100],\\n /// - Moved funds sweep transaction max total fee must be greater than zero,\\n /// - Moved funds sweep timeout must be greater than zero,\\n /// - Moved funds sweep timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateMovingFundsParameters(\\n Storage storage self,\\n uint64 _movingFundsTxMaxTotalFee,\\n uint64 _movingFundsDustThreshold,\\n uint32 _movingFundsTimeoutResetDelay,\\n uint32 _movingFundsTimeout,\\n uint96 _movingFundsTimeoutSlashingAmount,\\n uint32 _movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 _movingFundsCommitmentGasOffset,\\n uint64 _movedFundsSweepTxMaxTotalFee,\\n uint32 _movedFundsSweepTimeout,\\n uint96 _movedFundsSweepTimeoutSlashingAmount,\\n uint32 _movedFundsSweepTimeoutNotifierRewardMultiplier\\n ) internal {\\n require(\\n _movingFundsTxMaxTotalFee > 0,\\n \\\"Moving funds transaction max total fee must be greater than zero\\\"\\n );\\n\\n require(\\n _movingFundsDustThreshold > 0 &&\\n _movingFundsDustThreshold < self.redemptionDustThreshold,\\n \\\"Moving funds dust threshold must be greater than zero and lower than redemption dust threshold\\\"\\n );\\n\\n require(\\n _movingFundsTimeoutResetDelay > 0,\\n \\\"Moving funds timeout reset delay must be greater than zero\\\"\\n );\\n\\n require(\\n _movingFundsTimeout > _movingFundsTimeoutResetDelay,\\n \\\"Moving funds timeout must be greater than its reset delay\\\"\\n );\\n\\n require(\\n _movingFundsTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Moving funds timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n require(\\n _movedFundsSweepTxMaxTotalFee > 0,\\n \\\"Moved funds sweep transaction max total fee must be greater than zero\\\"\\n );\\n\\n require(\\n _movedFundsSweepTimeout > 0,\\n \\\"Moved funds sweep timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _movedFundsSweepTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Moved funds sweep timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.movingFundsTxMaxTotalFee = _movingFundsTxMaxTotalFee;\\n self.movingFundsDustThreshold = _movingFundsDustThreshold;\\n self.movingFundsTimeoutResetDelay = _movingFundsTimeoutResetDelay;\\n self.movingFundsTimeout = _movingFundsTimeout;\\n self\\n .movingFundsTimeoutSlashingAmount = _movingFundsTimeoutSlashingAmount;\\n self\\n .movingFundsTimeoutNotifierRewardMultiplier = _movingFundsTimeoutNotifierRewardMultiplier;\\n self.movingFundsCommitmentGasOffset = _movingFundsCommitmentGasOffset;\\n self.movedFundsSweepTxMaxTotalFee = _movedFundsSweepTxMaxTotalFee;\\n self.movedFundsSweepTimeout = _movedFundsSweepTimeout;\\n self\\n .movedFundsSweepTimeoutSlashingAmount = _movedFundsSweepTimeoutSlashingAmount;\\n self\\n .movedFundsSweepTimeoutNotifierRewardMultiplier = _movedFundsSweepTimeoutNotifierRewardMultiplier;\\n\\n emit MovingFundsParametersUpdated(\\n _movingFundsTxMaxTotalFee,\\n _movingFundsDustThreshold,\\n _movingFundsTimeoutResetDelay,\\n _movingFundsTimeout,\\n _movingFundsTimeoutSlashingAmount,\\n _movingFundsTimeoutNotifierRewardMultiplier,\\n _movingFundsCommitmentGasOffset,\\n _movedFundsSweepTxMaxTotalFee,\\n _movedFundsSweepTimeout,\\n _movedFundsSweepTimeoutSlashingAmount,\\n _movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of wallets.\\n /// @param _walletCreationPeriod New value of the wallet creation period in\\n /// seconds, determines how frequently a new wallet creation can be\\n /// requested.\\n /// @param _walletCreationMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param _walletCreationMaxBtcBalance New value of the wallet maximum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param _walletClosureMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet closure.\\n /// @param _walletMaxAge New value of the wallet maximum age in seconds,\\n /// indicates the maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @param _walletMaxBtcTransfer New value of the wallet maximum BTC transfer\\n /// in satoshi, determines the maximum amount that can be transferred\\n /// to a single target wallet during the moving funds process.\\n /// @param _walletClosingPeriod New value of the wallet closing period in\\n /// seconds, determines the length of the wallet closing period,\\n // i.e. the period when the wallet remains in the Closing state\\n // and can be subject of deposit fraud challenges.\\n /// @dev Requirements:\\n /// - Wallet maximum BTC balance must be greater than the wallet\\n /// minimum BTC balance,\\n /// - Wallet maximum BTC transfer must be greater than zero,\\n /// - Wallet closing period must be greater than zero.\\n function updateWalletParameters(\\n Storage storage self,\\n uint32 _walletCreationPeriod,\\n uint64 _walletCreationMinBtcBalance,\\n uint64 _walletCreationMaxBtcBalance,\\n uint64 _walletClosureMinBtcBalance,\\n uint32 _walletMaxAge,\\n uint64 _walletMaxBtcTransfer,\\n uint32 _walletClosingPeriod\\n ) internal {\\n require(\\n _walletCreationMaxBtcBalance > _walletCreationMinBtcBalance,\\n \\\"Wallet creation maximum BTC balance must be greater than the creation minimum BTC balance\\\"\\n );\\n require(\\n _walletMaxBtcTransfer > 0,\\n \\\"Wallet maximum BTC transfer must be greater than zero\\\"\\n );\\n require(\\n _walletClosingPeriod > 0,\\n \\\"Wallet closing period must be greater than zero\\\"\\n );\\n\\n self.walletCreationPeriod = _walletCreationPeriod;\\n self.walletCreationMinBtcBalance = _walletCreationMinBtcBalance;\\n self.walletCreationMaxBtcBalance = _walletCreationMaxBtcBalance;\\n self.walletClosureMinBtcBalance = _walletClosureMinBtcBalance;\\n self.walletMaxAge = _walletMaxAge;\\n self.walletMaxBtcTransfer = _walletMaxBtcTransfer;\\n self.walletClosingPeriod = _walletClosingPeriod;\\n\\n emit WalletParametersUpdated(\\n _walletCreationPeriod,\\n _walletCreationMinBtcBalance,\\n _walletCreationMaxBtcBalance,\\n _walletClosureMinBtcBalance,\\n _walletMaxAge,\\n _walletMaxBtcTransfer,\\n _walletClosingPeriod\\n );\\n }\\n\\n /// @notice Updates parameters related to frauds.\\n /// @param _fraudChallengeDepositAmount New value of the fraud challenge\\n /// deposit amount in wei, it is the amount of ETH the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @param _fraudChallengeDefeatTimeout New value of the challenge defeat\\n /// timeout in seconds, it is the amount of time the wallet has to\\n /// defeat a fraud challenge. The value must be greater than zero.\\n /// @param _fraudSlashingAmount New value of the fraud slashing amount in T,\\n /// it is the amount slashed from each wallet member for committing\\n /// a fraud.\\n /// @param _fraudNotifierRewardMultiplier New value of the fraud notifier\\n /// reward multiplier as percentage, it determines the percentage of\\n /// the notifier reward from the staking contact the notifier of\\n /// a fraud receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Fraud challenge defeat timeout must be greater than 0,\\n /// - Fraud notifier reward multiplier must be in the range [0, 100].\\n function updateFraudParameters(\\n Storage storage self,\\n uint96 _fraudChallengeDepositAmount,\\n uint32 _fraudChallengeDefeatTimeout,\\n uint96 _fraudSlashingAmount,\\n uint32 _fraudNotifierRewardMultiplier\\n ) internal {\\n require(\\n _fraudChallengeDefeatTimeout > 0,\\n \\\"Fraud challenge defeat timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _fraudNotifierRewardMultiplier <= 100,\\n \\\"Fraud notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.fraudChallengeDepositAmount = _fraudChallengeDepositAmount;\\n self.fraudChallengeDefeatTimeout = _fraudChallengeDefeatTimeout;\\n self.fraudSlashingAmount = _fraudSlashingAmount;\\n self.fraudNotifierRewardMultiplier = _fraudNotifierRewardMultiplier;\\n\\n emit FraudParametersUpdated(\\n _fraudChallengeDepositAmount,\\n _fraudChallengeDefeatTimeout,\\n _fraudSlashingAmount,\\n _fraudNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates treasury address. The treasury receives the system fees.\\n /// @param _treasury New value of the treasury address.\\n /// @dev The treasury address must not be 0x0.\\n function updateTreasury(Storage storage self, address _treasury) internal {\\n require(_treasury != address(0), \\\"Treasury address must not be 0x0\\\");\\n\\n self.treasury = _treasury;\\n emit TreasuryUpdated(_treasury);\\n }\\n}\\n\",\"keccak256\":\"0x0fe63c47a08ff0e56bd3bf4d2c9db4b09df717ac77ba5b18ab382a1e0bbb11c7\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Deposit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Bridge deposit\\n/// @notice The library handles the logic for revealing Bitcoin deposits to\\n/// the Bridge.\\n/// @dev The depositor puts together a P2SH or P2WSH address to deposit the\\n/// funds. This script is unique to each depositor and looks like this:\\n///\\n/// ```\\n/// DROP\\n/// DROP\\n/// DUP HASH160 EQUAL\\n/// IF\\n/// CHECKSIG\\n/// ELSE\\n/// DUP HASH160 EQUALVERIFY\\n/// CHECKLOCKTIMEVERIFY DROP\\n/// CHECKSIG\\n/// ENDIF\\n/// ```\\n///\\n/// Since each depositor has their own Ethereum address and their own\\n/// blinding factor, each depositor\\u2019s script is unique, and the hash\\n/// of each depositor\\u2019s script is unique.\\nlibrary Deposit {\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents data which must be revealed by the depositor during\\n /// deposit reveal.\\n struct DepositRevealInfo {\\n // Index of the funding output belonging to the funding transaction.\\n uint32 fundingOutputIndex;\\n // The blinding factor as 8 bytes. Byte endianness doesn't matter\\n // as this factor is not interpreted as uint. The blinding factor allows\\n // to distinguish deposits from the same depositor.\\n bytes8 blindingFactor;\\n // The compressed Bitcoin public key (33 bytes and 02 or 03 prefix)\\n // of the deposit's wallet hashed in the HASH160 Bitcoin opcode style.\\n bytes20 walletPubKeyHash;\\n // The compressed Bitcoin public key (33 bytes and 02 or 03 prefix)\\n // that can be used to make the deposit refund after the refund\\n // locktime passes. Hashed in the HASH160 Bitcoin opcode style.\\n bytes20 refundPubKeyHash;\\n // The refund locktime (4-byte LE). Interpreted according to locktime\\n // parsing rules described in:\\n // https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number\\n // and used with OP_CHECKLOCKTIMEVERIFY opcode as described in:\\n // https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki\\n bytes4 refundLocktime;\\n // Address of the Bank vault to which the deposit is routed to.\\n // Optional, can be 0x0. The vault must be trusted by the Bridge.\\n address vault;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents tBTC deposit request data.\\n struct DepositRequest {\\n // Ethereum depositor address.\\n address depositor;\\n // Deposit amount in satoshi.\\n uint64 amount;\\n // UNIX timestamp the deposit was revealed at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 revealedAt;\\n // Address of the Bank vault the deposit is routed to.\\n // Optional, can be 0x0.\\n address vault;\\n // Treasury TBTC fee in satoshi at the moment of deposit reveal.\\n uint64 treasuryFee;\\n // UNIX timestamp the deposit was swept at. Note this is not the\\n // time when the deposit was swept on the Bitcoin chain but actually\\n // the time when the sweep proof was delivered to the Ethereum chain.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 sweptAt;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event DepositRevealed(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex,\\n address indexed depositor,\\n uint64 amount,\\n bytes8 blindingFactor,\\n bytes20 indexed walletPubKeyHash,\\n bytes20 refundPubKeyHash,\\n bytes4 refundLocktime,\\n address vault\\n );\\n\\n /// @notice Used by the depositor to reveal information about their P2(W)SH\\n /// Bitcoin deposit to the Bridge on Ethereum chain. The off-chain\\n /// wallet listens for revealed deposit events and may decide to\\n /// include the revealed deposit in the next executed sweep.\\n /// Information about the Bitcoin deposit can be revealed before or\\n /// after the Bitcoin transaction with P2(W)SH deposit is mined on\\n /// the Bitcoin chain. Worth noting, the gas cost of this function\\n /// scales with the number of P2(W)SH transaction inputs and\\n /// outputs. The deposit may be routed to one of the trusted vaults.\\n /// When a deposit is routed to a vault, vault gets notified when\\n /// the deposit gets swept and it may execute the appropriate action.\\n /// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.\\n /// @param reveal Deposit reveal data, see `RevealInfo struct.\\n /// @dev Requirements:\\n /// - This function must be called by the same Ethereum address as the\\n /// one used in the P2(W)SH BTC deposit transaction as a depositor,\\n /// - `reveal.walletPubKeyHash` must identify a `Live` wallet,\\n /// - `reveal.vault` must be 0x0 or point to a trusted vault,\\n /// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH\\n /// output of the BTC deposit transaction,\\n /// - `reveal.blindingFactor` must be the blinding factor used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - `reveal.walletPubKeyHash` must be the wallet pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundPubKeyHash` must be the refund pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundLocktime` must be the refund locktime used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n ///\\n /// If any of these requirements is not met, the wallet _must_ refuse\\n /// to sweep the deposit and the depositor has to wait until the\\n /// deposit script unlocks to receive their BTC back.\\n function revealDeposit(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata fundingTx,\\n DepositRevealInfo calldata reveal\\n ) external {\\n require(\\n self.registeredWallets[reveal.walletPubKeyHash].state ==\\n Wallets.WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n require(\\n reveal.vault == address(0) || self.isVaultTrusted[reveal.vault],\\n \\\"Vault is not trusted\\\"\\n );\\n\\n if (self.depositRevealAheadPeriod > 0) {\\n validateDepositRefundLocktime(self, reveal.refundLocktime);\\n }\\n\\n bytes memory expectedScript = abi.encodePacked(\\n hex\\\"14\\\", // Byte length of depositor Ethereum address.\\n msg.sender,\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"08\\\", // Byte length of blinding factor value.\\n reveal.blindingFactor,\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"76\\\", // OP_DUP\\n hex\\\"a9\\\", // OP_HASH160\\n hex\\\"14\\\", // Byte length of a compressed Bitcoin public key hash.\\n reveal.walletPubKeyHash,\\n hex\\\"87\\\", // OP_EQUAL\\n hex\\\"63\\\", // OP_IF\\n hex\\\"ac\\\", // OP_CHECKSIG\\n hex\\\"67\\\", // OP_ELSE\\n hex\\\"76\\\", // OP_DUP\\n hex\\\"a9\\\", // OP_HASH160\\n hex\\\"14\\\", // Byte length of a compressed Bitcoin public key hash.\\n reveal.refundPubKeyHash,\\n hex\\\"88\\\", // OP_EQUALVERIFY\\n hex\\\"04\\\", // Byte length of refund locktime value.\\n reveal.refundLocktime,\\n hex\\\"b1\\\", // OP_CHECKLOCKTIMEVERIFY\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"ac\\\", // OP_CHECKSIG\\n hex\\\"68\\\" // OP_ENDIF\\n );\\n\\n bytes memory fundingOutput = fundingTx\\n .outputVector\\n .extractOutputAtIndex(reveal.fundingOutputIndex);\\n bytes memory fundingOutputHash = fundingOutput.extractHash();\\n\\n if (fundingOutputHash.length == 20) {\\n // A 20-byte output hash is used by P2SH. That hash is constructed\\n // by applying OP_HASH160 on the locking script. A 20-byte output\\n // hash is used as well by P2PKH and P2WPKH (OP_HASH160 on the\\n // public key). However, since we compare the actual output hash\\n // with an expected locking script hash, this check will succeed only\\n // for P2SH transaction type with expected script hash value. For\\n // P2PKH and P2WPKH, it will fail on the output hash comparison with\\n // the expected locking script hash.\\n require(\\n fundingOutputHash.slice20(0) == expectedScript.hash160View(),\\n \\\"Wrong 20-byte script hash\\\"\\n );\\n } else if (fundingOutputHash.length == 32) {\\n // A 32-byte output hash is used by P2WSH. That hash is constructed\\n // by applying OP_SHA256 on the locking script.\\n require(\\n fundingOutputHash.toBytes32() == sha256(expectedScript),\\n \\\"Wrong 32-byte script hash\\\"\\n );\\n } else {\\n revert(\\\"Wrong script hash length\\\");\\n }\\n\\n // Resulting TX hash is in native Bitcoin little-endian format.\\n bytes32 fundingTxHash = abi\\n .encodePacked(\\n fundingTx.version,\\n fundingTx.inputVector,\\n fundingTx.outputVector,\\n fundingTx.locktime\\n )\\n .hash256View();\\n\\n DepositRequest storage deposit = self.deposits[\\n uint256(\\n keccak256(\\n abi.encodePacked(fundingTxHash, reveal.fundingOutputIndex)\\n )\\n )\\n ];\\n require(deposit.revealedAt == 0, \\\"Deposit already revealed\\\");\\n\\n uint64 fundingOutputAmount = fundingOutput.extractValue();\\n\\n require(\\n fundingOutputAmount >= self.depositDustThreshold,\\n \\\"Deposit amount too small\\\"\\n );\\n\\n deposit.amount = fundingOutputAmount;\\n deposit.depositor = msg.sender;\\n /* solhint-disable-next-line not-rely-on-time */\\n deposit.revealedAt = uint32(block.timestamp);\\n deposit.vault = reveal.vault;\\n deposit.treasuryFee = self.depositTreasuryFeeDivisor > 0\\n ? fundingOutputAmount / self.depositTreasuryFeeDivisor\\n : 0;\\n // slither-disable-next-line reentrancy-events\\n emit DepositRevealed(\\n fundingTxHash,\\n reveal.fundingOutputIndex,\\n msg.sender,\\n fundingOutputAmount,\\n reveal.blindingFactor,\\n reveal.walletPubKeyHash,\\n reveal.refundPubKeyHash,\\n reveal.refundLocktime,\\n reveal.vault\\n );\\n }\\n\\n /// @notice Validates the deposit refund locktime. The validation passes\\n /// successfully only if the deposit reveal is done respectively\\n /// earlier than the moment when the deposit refund locktime is\\n /// reached, i.e. the deposit become refundable. Reverts otherwise.\\n /// @param refundLocktime The deposit refund locktime as 4-byte LE.\\n /// @dev Requirements:\\n /// - `refundLocktime` as integer must be >= 500M\\n /// - `refundLocktime` must denote a timestamp that is at least\\n /// `depositRevealAheadPeriod` seconds later than the moment\\n /// of `block.timestamp`\\n function validateDepositRefundLocktime(\\n BridgeState.Storage storage self,\\n bytes4 refundLocktime\\n ) internal view {\\n // Convert the refund locktime byte array to a LE integer. This is\\n // the moment in time when the deposit become refundable.\\n uint32 depositRefundableTimestamp = BTCUtils.reverseUint32(\\n uint32(refundLocktime)\\n );\\n // According to https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number\\n // the locktime is parsed as a block number if less than 500M. We always\\n // want to parse the locktime as an Unix timestamp so we allow only for\\n // values bigger than or equal to 500M.\\n require(\\n depositRefundableTimestamp >= 500 * 1e6,\\n \\\"Refund locktime must be a value >= 500M\\\"\\n );\\n // The deposit must be revealed before it becomes refundable.\\n // This is because the sweeping wallet needs to have some time to\\n // sweep the deposit and avoid a potential competition with the\\n // depositor making the deposit refund.\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp + self.depositRevealAheadPeriod <=\\n depositRefundableTimestamp,\\n \\\"Deposit refund locktime is too close\\\"\\n );\\n }\\n}\\n\",\"keccak256\":\"0xc00d41ea9e98a6fa3d8d8701ad8554c459e0268c6bf413f0447bc1c68c6ab7e8\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/DepositSweep.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @title Bridge deposit sweep\\n/// @notice The library handles the logic for sweeping transactions revealed to\\n/// the Bridge\\n/// @dev Bridge active wallet periodically signs a transaction that unlocks all\\n/// of the valid, revealed deposits above the dust threshold, combines them\\n/// into a single UTXO with the existing main wallet UTXO, and relocks\\n/// those transactions without a 30-day refund clause to the same wallet.\\n/// This has two main effects: it consolidates the UTXO set and it disables\\n/// the refund. Balances of depositors in the Bank are increased when the\\n/// SPV sweep proof is submitted to the Bridge.\\nlibrary DepositSweep {\\n using BridgeState for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n\\n /// @notice Represents temporary information needed during the processing\\n /// of the deposit sweep Bitcoin transaction inputs. This structure\\n /// is an internal one and should not be exported outside of the\\n /// deposit sweep transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct DepositSweepTxInputsProcessingInfo {\\n // Input vector of the deposit sweep Bitcoin transaction. It is\\n // assumed the vector's structure is valid so it must be validated\\n // using e.g. `BTCUtils.validateVin` function before being used\\n // during the processing. The validation is usually done as part\\n // of the `BitcoinTx.validateProof` call that checks the SPV proof.\\n bytes sweepTxInputVector;\\n // Data of the wallet's main UTXO. If no main UTXO exists for the given\\n // sweeping wallet, this parameter's fields should be zeroed to bypass\\n // the main UTXO validation\\n BitcoinTx.UTXO mainUtxo;\\n // Address of the vault where all swept deposits should be routed to.\\n // It is used to validate whether all swept deposits have been revealed\\n // with the same `vault` parameter. It is an optional parameter.\\n // Set to zero address if deposits are not routed to a vault.\\n address vault;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents an outcome of the sweep Bitcoin transaction\\n /// inputs processing.\\n struct DepositSweepTxInputsInfo {\\n // Sum of all inputs values i.e. all deposits and main UTXO value,\\n // if present.\\n uint256 inputsTotalValue;\\n // Addresses of depositors who performed processed deposits. Ordered in\\n // the same order as deposits inputs in the input vector. Size of this\\n // array is either equal to the number of inputs (main UTXO doesn't\\n // exist) or less by one (main UTXO exists and is pointed by one of\\n // the inputs).\\n address[] depositors;\\n // Amounts of deposits corresponding to processed deposits. Ordered in\\n // the same order as deposits inputs in the input vector. Size of this\\n // array is either equal to the number of inputs (main UTXO doesn't\\n // exist) or less by one (main UTXO exists and is pointed by one of\\n // the inputs).\\n uint256[] depositedAmounts;\\n // Values of the treasury fee corresponding to processed deposits.\\n // Ordered in the same order as deposits inputs in the input vector.\\n // Size of this array is either equal to the number of inputs (main\\n // UTXO doesn't exist) or less by one (main UTXO exists and is pointed\\n // by one of the inputs).\\n uint256[] treasuryFees;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n event DepositsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);\\n\\n /// @notice Used by the wallet to prove the BTC deposit sweep transaction\\n /// and to update Bank balances accordingly. Sweep is only accepted\\n /// if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by first\\n /// computing the Bitcoin fee for the sweep transaction. The fee is\\n /// divided evenly between all swept deposits. Each depositor\\n /// receives a balance in the bank equal to the amount inferred\\n /// during the reveal transaction, minus their fee share.\\n ///\\n /// It is possible to prove the given sweep only one time.\\n /// @param sweepTx Bitcoin sweep transaction data.\\n /// @param sweepProof Bitcoin sweep proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @param vault Optional address of the vault where all swept deposits\\n /// should be routed to. All deposits swept as part of the transaction\\n /// must have their `vault` parameters set to the same address.\\n /// If this parameter is set to an address of a trusted vault, swept\\n /// deposits are routed to that vault.\\n /// If this parameter is set to the zero address or to an address\\n /// of a non-trusted vault, swept deposits are not routed to a\\n /// vault but depositors' balances are increased in the Bank\\n /// individually.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with 1..n\\n /// inputs. If the wallet has no main UTXO, all n inputs should\\n /// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has\\n /// an existing main UTXO, one of the n inputs must point to that\\n /// main UTXO and remaining n-1 inputs should correspond to P2(W)SH\\n /// revealed deposits UTXOs. That transaction must have only\\n /// one P2(W)PKH output locking funds on the 20-byte wallet public\\n /// key hash,\\n /// - All revealed deposits that are swept by `sweepTx` must have\\n /// their `vault` parameters set to the same address as the address\\n /// passed in the `vault` function parameter,\\n /// - `sweepProof` components must match the expected structure. See\\n /// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored.\\n function submitDepositSweepProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address vault\\n ) external {\\n // Wallet state validation is performed in the\\n // `resolveDepositSweepingWallet` function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 sweepTxHash = self.validateProof(sweepTx, sweepProof);\\n\\n // Process sweep transaction output and extract its target wallet\\n // public key hash and value.\\n (\\n bytes20 walletPubKeyHash,\\n uint64 sweepTxOutputValue\\n ) = processDepositSweepTxOutput(self, sweepTx.outputVector);\\n\\n (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n ) = resolveDepositSweepingWallet(self, walletPubKeyHash, mainUtxo);\\n\\n // Process sweep transaction inputs and extract all information needed\\n // to perform deposit bookkeeping.\\n DepositSweepTxInputsInfo\\n memory inputsInfo = processDepositSweepTxInputs(\\n self,\\n DepositSweepTxInputsProcessingInfo(\\n sweepTx.inputVector,\\n resolvedMainUtxo,\\n vault\\n )\\n );\\n\\n // Helper variable that will hold the sum of treasury fees paid by\\n // all deposits.\\n uint256 totalTreasuryFee = 0;\\n\\n // Determine the transaction fee that should be incurred by each deposit\\n // and the indivisible remainder that should be additionally incurred\\n // by the last deposit.\\n (\\n uint256 depositTxFee,\\n uint256 depositTxFeeRemainder\\n ) = depositSweepTxFeeDistribution(\\n inputsInfo.inputsTotalValue,\\n sweepTxOutputValue,\\n inputsInfo.depositedAmounts.length\\n );\\n\\n // Make sure the highest value of the deposit transaction fee does not\\n // exceed the maximum value limited by the governable parameter.\\n require(\\n depositTxFee + depositTxFeeRemainder <= self.depositTxMaxFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n // Reduce each deposit amount by treasury fee and transaction fee.\\n for (uint256 i = 0; i < inputsInfo.depositedAmounts.length; i++) {\\n // The last deposit should incur the deposit transaction fee\\n // remainder.\\n uint256 depositTxFeeIncurred = i ==\\n inputsInfo.depositedAmounts.length - 1\\n ? depositTxFee + depositTxFeeRemainder\\n : depositTxFee;\\n\\n // There is no need to check whether\\n // `inputsInfo.depositedAmounts[i] - inputsInfo.treasuryFees[i] - txFee > 0`\\n // since the `depositDustThreshold` should force that condition\\n // to be always true.\\n inputsInfo.depositedAmounts[i] =\\n inputsInfo.depositedAmounts[i] -\\n inputsInfo.treasuryFees[i] -\\n depositTxFeeIncurred;\\n totalTreasuryFee += inputsInfo.treasuryFees[i];\\n }\\n\\n // Record this sweep data and assign them to the wallet public key hash\\n // as new main UTXO. Transaction output index is always 0 as sweep\\n // transaction always contains only one output.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(sweepTxHash, uint32(0), sweepTxOutputValue)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit DepositsSwept(walletPubKeyHash, sweepTxHash);\\n\\n if (vault != address(0) && self.isVaultTrusted[vault]) {\\n // If the `vault` address is not zero and belongs to a trusted\\n // vault, route the deposits to that vault.\\n self.bank.increaseBalanceAndCall(\\n vault,\\n inputsInfo.depositors,\\n inputsInfo.depositedAmounts\\n );\\n } else {\\n // If the `vault` address is zero or belongs to a non-trusted\\n // vault, increase balances in the Bank individually for each\\n // depositor.\\n self.bank.increaseBalances(\\n inputsInfo.depositors,\\n inputsInfo.depositedAmounts\\n );\\n }\\n\\n // Pass the treasury fee to the treasury address.\\n if (totalTreasuryFee > 0) {\\n self.bank.increaseBalance(self.treasury, totalTreasuryFee);\\n }\\n }\\n\\n function mock__submitDepositSweepProof(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external {\\n Deposit.DepositRequest storage deposit = self.deposits[\\n uint256(\\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\\n )\\n ];\\n\\n require(deposit.sweptAt == 0, \\\"Deposit already swept\\\");\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n deposit.sweptAt = uint32(block.timestamp);\\n // Mokced deposit transaciton fee on the Bitcoin chain.\\n uint64 mockedDepositTxFeeIncurred = 400; // 0.000004 BTC.\\n uint64 depositedAmount = deposit.amount -\\n deposit.treasuryFee -\\n mockedDepositTxFeeIncurred;\\n\\n emit DepositsSwept(walletPubKeyHash, 0x0);\\n\\n address vault = deposit.vault;\\n address[] memory depositors = new address[](1);\\n depositors[0] = deposit.depositor;\\n uint256[] memory depositedAmounts = new uint256[](1);\\n depositedAmounts[0] = depositedAmount;\\n\\n if (vault != address(0) && self.isVaultTrusted[vault]) {\\n // If the `vault` address is not zero and belongs to a trusted\\n // vault, route the deposits to that vault.\\n self.bank.increaseBalanceAndCall(\\n vault,\\n depositors,\\n depositedAmounts\\n );\\n } else {\\n // If the `vault` address is zero or belongs to a non-trusted\\n // vault, increase balances in the Bank individually for each\\n // depositor.\\n self.bank.increaseBalances(depositors, depositedAmounts);\\n }\\n\\n uint256 totalTreasuryFee = deposit.treasuryFee;\\n // Pass the treasury fee to the treasury address.\\n self.bank.increaseBalance(self.treasury, totalTreasuryFee);\\n }\\n\\n /// @notice Resolves sweeping wallet based on the provided wallet public key\\n /// hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @return wallet Data of the sweeping wallet.\\n /// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet\\n /// resolved by cross-checking the `mainUtxo` parameter with\\n /// the chain state. If the validation went well, this is the\\n /// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - If the main UTXO of the sweeping wallet exists in the storage,\\n /// the passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveDepositSweepingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n )\\n internal\\n view\\n returns (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n )\\n {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n\\n // Check if the main UTXO for given wallet exists. If so, validate\\n // passed main UTXO data against the stored hash and use them for\\n // further processing. If no main UTXO exists, use empty data.\\n resolvedMainUtxo = BitcoinTx.UTXO(bytes32(0), 0, 0);\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n if (mainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n resolvedMainUtxo = mainUtxo;\\n }\\n }\\n\\n /// @notice Processes the Bitcoin sweep transaction output vector by\\n /// extracting the single output and using it to gain additional\\n /// information required for further processing (e.g. value and\\n /// wallet public key hash).\\n /// @param sweepTxOutputVector Bitcoin sweep transaction output vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVout` function before\\n /// it is passed here.\\n /// @return walletPubKeyHash 20-byte wallet public key hash.\\n /// @return value 8-byte sweep transaction output value.\\n function processDepositSweepTxOutput(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxOutputVector\\n ) internal view returns (bytes20 walletPubKeyHash, uint64 value) {\\n // To determine the total number of sweep transaction outputs, we need to\\n // parse the compactSize uint (VarInt) the output vector is prepended by.\\n // That compactSize uint encodes the number of vector elements using the\\n // format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVout` validation.\\n // See `BitcoinTx.outputVector` docs for more details.\\n (, uint256 outputsCount) = sweepTxOutputVector.parseVarInt();\\n require(\\n outputsCount == 1,\\n \\\"Sweep transaction must have a single output\\\"\\n );\\n\\n bytes memory output = sweepTxOutputVector.extractOutputAtIndex(0);\\n walletPubKeyHash = self.extractPubKeyHash(output);\\n value = output.extractValue();\\n\\n return (walletPubKeyHash, value);\\n }\\n\\n /// @notice Processes the Bitcoin sweep transaction input vector. It\\n /// extracts each input and tries to obtain associated deposit or\\n /// main UTXO data, depending on the input type. Reverts\\n /// if one of the inputs cannot be recognized as a pointer to a\\n /// revealed deposit or expected main UTXO.\\n /// This function also marks each processed deposit as swept.\\n /// @return resultInfo Outcomes of the processing.\\n function processDepositSweepTxInputs(\\n BridgeState.Storage storage self,\\n DepositSweepTxInputsProcessingInfo memory processInfo\\n ) internal returns (DepositSweepTxInputsInfo memory resultInfo) {\\n // If the passed `mainUtxo` parameter's values are zeroed, the main UTXO\\n // for the given wallet doesn't exist and it is not expected to be\\n // included in the sweep transaction input vector.\\n bool mainUtxoExpected = processInfo.mainUtxo.txHash != bytes32(0);\\n bool mainUtxoFound = false;\\n\\n // Determining the total number of sweep transaction inputs in the same\\n // way as for number of outputs. See `BitcoinTx.inputVector` docs for\\n // more details.\\n (uint256 inputsCompactSizeUintLength, uint256 inputsCount) = processInfo\\n .sweepTxInputVector\\n .parseVarInt();\\n\\n // To determine the first input starting index, we must jump over\\n // the compactSize uint which prepends the input vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 1 + inputsCompactSizeUintLength;\\n\\n // Determine the swept deposits count. If main UTXO is NOT expected,\\n // all inputs should be deposits. If main UTXO is expected, one input\\n // should point to that main UTXO.\\n resultInfo.depositors = new address[](\\n !mainUtxoExpected ? inputsCount : inputsCount - 1\\n );\\n resultInfo.depositedAmounts = new uint256[](\\n resultInfo.depositors.length\\n );\\n resultInfo.treasuryFees = new uint256[](resultInfo.depositors.length);\\n\\n // Initialize helper variables.\\n uint256 processedDepositsCount = 0;\\n\\n // Inputs processing loop.\\n for (uint256 i = 0; i < inputsCount; i++) {\\n (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n ) = parseDepositSweepTxInputAt(\\n processInfo.sweepTxInputVector,\\n inputStartingIndex\\n );\\n\\n Deposit.DepositRequest storage deposit = self.deposits[\\n uint256(\\n keccak256(abi.encodePacked(outpointTxHash, outpointIndex))\\n )\\n ];\\n\\n if (deposit.revealedAt != 0) {\\n // If we entered here, that means the input was identified as\\n // a revealed deposit.\\n require(deposit.sweptAt == 0, \\\"Deposit already swept\\\");\\n\\n require(\\n deposit.vault == processInfo.vault,\\n \\\"Deposit should be routed to another vault\\\"\\n );\\n\\n if (processedDepositsCount == resultInfo.depositors.length) {\\n // If this condition is true, that means a deposit input\\n // took place of an expected main UTXO input.\\n // In other words, there is no expected main UTXO\\n // input and all inputs come from valid, revealed deposits.\\n revert(\\n \\\"Expected main UTXO not present in sweep transaction inputs\\\"\\n );\\n }\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n deposit.sweptAt = uint32(block.timestamp);\\n\\n resultInfo.depositors[processedDepositsCount] = deposit\\n .depositor;\\n resultInfo.depositedAmounts[processedDepositsCount] = deposit\\n .amount;\\n resultInfo.inputsTotalValue += resultInfo.depositedAmounts[\\n processedDepositsCount\\n ];\\n resultInfo.treasuryFees[processedDepositsCount] = deposit\\n .treasuryFee;\\n\\n processedDepositsCount++;\\n } else if (\\n mainUtxoExpected != mainUtxoFound &&\\n processInfo.mainUtxo.txHash == outpointTxHash &&\\n processInfo.mainUtxo.txOutputIndex == outpointIndex\\n ) {\\n // If we entered here, that means the input was identified as\\n // the expected main UTXO.\\n resultInfo.inputsTotalValue += processInfo\\n .mainUtxo\\n .txOutputValue;\\n mainUtxoFound = true;\\n\\n // Main UTXO used as an input, mark it as spent.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(outpointTxHash, outpointIndex)\\n )\\n )\\n ] = true;\\n } else {\\n revert(\\\"Unknown input type\\\");\\n }\\n\\n // Make the `inputStartingIndex` pointing to the next input by\\n // increasing it by current input's length.\\n inputStartingIndex += inputLength;\\n }\\n\\n // Construction of the input processing loop guarantees that:\\n // `processedDepositsCount == resultInfo.depositors.length == resultInfo.depositedAmounts.length`\\n // is always true at this point. We just use the first variable\\n // to assert the total count of swept deposit is bigger than zero.\\n require(\\n processedDepositsCount > 0,\\n \\\"Sweep transaction must process at least one deposit\\\"\\n );\\n\\n // Assert the main UTXO was used as one of current sweep's inputs if\\n // it was actually expected.\\n require(\\n mainUtxoExpected == mainUtxoFound,\\n \\\"Expected main UTXO not present in sweep transaction inputs\\\"\\n );\\n\\n return resultInfo;\\n }\\n\\n /// @notice Parses a Bitcoin transaction input starting at the given index.\\n /// @param inputVector Bitcoin transaction input vector.\\n /// @param inputStartingIndex Index the given input starts at.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the given input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the given input's outpoint.\\n /// @return inputLength Byte length of the given input.\\n /// @dev This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before it\\n /// is passed here.\\n function parseDepositSweepTxInputAt(\\n bytes memory inputVector,\\n uint256 inputStartingIndex\\n )\\n internal\\n pure\\n returns (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n )\\n {\\n outpointTxHash = inputVector.extractInputTxIdLeAt(inputStartingIndex);\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(inputVector.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n inputLength = inputVector.determineInputLengthAt(inputStartingIndex);\\n\\n return (outpointTxHash, outpointIndex, inputLength);\\n }\\n\\n /// @notice Determines the distribution of the sweep transaction fee\\n /// over swept deposits.\\n /// @param sweepTxInputsTotalValue Total value of all sweep transaction inputs.\\n /// @param sweepTxOutputValue Value of the sweep transaction output.\\n /// @param depositsCount Count of the deposits swept by the sweep transaction.\\n /// @return depositTxFee Transaction fee per deposit determined by evenly\\n /// spreading the divisible part of the sweep transaction fee\\n /// over all deposits.\\n /// @return depositTxFeeRemainder The indivisible part of the sweep\\n /// transaction fee than cannot be distributed over all deposits.\\n /// @dev It is up to the caller to decide how the remainder should be\\n /// counted in. This function only computes its value.\\n function depositSweepTxFeeDistribution(\\n uint256 sweepTxInputsTotalValue,\\n uint256 sweepTxOutputValue,\\n uint256 depositsCount\\n )\\n internal\\n pure\\n returns (uint256 depositTxFee, uint256 depositTxFeeRemainder)\\n {\\n // The sweep transaction fee is just the difference between inputs\\n // amounts sum and the output amount.\\n uint256 sweepTxFee = sweepTxInputsTotalValue - sweepTxOutputValue;\\n // Compute the indivisible remainder that remains after dividing the\\n // sweep transaction fee over all deposits evenly.\\n depositTxFeeRemainder = sweepTxFee % depositsCount;\\n // Compute the transaction fee per deposit by dividing the sweep\\n // transaction fee (reduced by the remainder) by the number of deposits.\\n depositTxFee = (sweepTxFee - depositTxFeeRemainder) / depositsCount;\\n\\n return (depositTxFee, depositTxFeeRemainder);\\n }\\n}\\n\",\"keccak256\":\"0xb58c0665af5e76a0b04fd08199c4bc9dd34f8bb41e1e8d1eea44ef0153c1a6aa\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/EcdsaLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nlibrary EcdsaLib {\\n using BytesLib for bytes;\\n\\n /// @notice Converts public key X and Y coordinates (32-byte each) to a\\n /// compressed public key (33-byte). Compressed public key is X\\n /// coordinate prefixed with `02` or `03` based on the Y coordinate parity.\\n /// It is expected that the uncompressed public key is stripped\\n /// (i.e. it is not prefixed with `04`).\\n /// @param x Wallet's public key's X coordinate.\\n /// @param y Wallet's public key's Y coordinate.\\n /// @return Compressed public key (33-byte), prefixed with `02` or `03`.\\n function compressPublicKey(bytes32 x, bytes32 y)\\n internal\\n pure\\n returns (bytes memory)\\n {\\n bytes1 prefix;\\n if (uint256(y) % 2 == 0) {\\n prefix = hex\\\"02\\\";\\n } else {\\n prefix = hex\\\"03\\\";\\n }\\n\\n return bytes.concat(prefix, x);\\n }\\n}\\n\",\"keccak256\":\"0x670d0fbeb088f78abfe7ae7f844784d774ca515480383378a602af707cace7ff\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Fraud.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {CheckBitcoinSigs} from \\\"@keep-network/bitcoin-spv-sol/contracts/CheckBitcoinSigs.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Heartbeat.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Bridge fraud\\n/// @notice The library handles the logic for challenging Bridge wallets that\\n/// committed fraud.\\n/// @dev Anyone can submit a fraud challenge indicating that a UTXO being under\\n/// the wallet control was unlocked by the wallet but was not used\\n/// according to the protocol rules. That means the wallet signed\\n/// a transaction input pointing to that UTXO and there is a unique\\n/// sighash and signature pair associated with that input.\\n///\\n/// In order to defeat the challenge, the same wallet public key and\\n/// signature must be provided as were used to calculate the sighash during\\n/// the challenge. The wallet provides the preimage which produces sighash\\n/// used to generate the ECDSA signature that is the subject of the fraud\\n/// claim.\\n///\\n/// The fraud challenge defeat attempt will succeed if the inputs in the\\n/// preimage are considered honestly spent by the wallet. Therefore the\\n/// transaction spending the UTXO must be proven in the Bridge before\\n/// a challenge defeat is called.\\n///\\n/// Another option is when a malicious wallet member used a signed heartbeat\\n/// message periodically produced by the wallet off-chain to challenge the\\n/// wallet for a fraud. Anyone from the wallet can defeat the challenge by\\n/// proving the sighash and signature were produced for a heartbeat message\\n/// following a strict format.\\nlibrary Fraud {\\n using Wallets for BridgeState.Storage;\\n\\n using BytesLib for bytes;\\n using BTCUtils for bytes;\\n using BTCUtils for uint32;\\n using EcdsaLib for bytes;\\n\\n struct FraudChallenge {\\n // The address of the party challenging the wallet.\\n address challenger;\\n // The amount of ETH the challenger deposited.\\n uint256 depositAmount;\\n // The timestamp the challenge was submitted at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 reportedAt;\\n // The flag indicating whether the challenge has been resolved.\\n bool resolved;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event FraudChallengeSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n );\\n\\n event FraudChallengeDefeated(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event FraudChallengeDefeatTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n // Sighash calculated as a Bitcoin's hash256 (double sha2) of:\\n // - a preimage of a transaction spending UTXO according to the protocol\\n // rules OR\\n // - a valid heartbeat message produced by the wallet off-chain.\\n bytes32 sighash\\n );\\n\\n /// @notice Submits a fraud challenge indicating that a UTXO being under\\n /// wallet control was unlocked by the wallet but was not used\\n /// according to the protocol rules. That means the wallet signed\\n /// a transaction input pointing to that UTXO and there is a unique\\n /// sighash and signature pair associated with that input. This\\n /// function uses those parameters to create a fraud accusation that\\n /// proves a given transaction input unlocking the given UTXO was\\n /// actually signed by the wallet. This function cannot determine\\n /// whether the transaction was actually broadcast and the input was\\n /// consumed in a fraudulent way so it just opens a challenge period\\n /// during which the wallet can defeat the challenge by submitting\\n /// proof of a transaction that consumes the given input according\\n /// to protocol rules. To prevent spurious allegations, the caller\\n /// must deposit ETH that is returned back upon justified fraud\\n /// challenge or confiscated otherwise.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @param signature Bitcoin signature in the R/S/V format\\n /// @dev Requirements:\\n /// - Wallet behind `walletPublicKey` must be in Live or MovingFunds\\n /// or Closing state,\\n /// - The challenger must send appropriate amount of ETH used as\\n /// fraud challenge deposit,\\n /// - The signature (represented by r, s and v) must be generated by\\n /// the wallet behind `walletPubKey` during signing of `sighash`\\n /// which was calculated from `preimageSha256`,\\n /// - Wallet can be challenged for the given signature only once.\\n function submitFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes memory preimageSha256,\\n BitcoinTx.RSVSignature calldata signature\\n ) external {\\n require(\\n msg.value >= self.fraudChallengeDepositAmount,\\n \\\"The amount of ETH deposited is too low\\\"\\n );\\n\\n // To prevent ECDSA signature forgery `sighash` must be calculated\\n // inside the function and not passed as a function parameter.\\n // Signature forgery could result in a wrongful fraud accusation\\n // against a wallet.\\n bytes32 sighash = sha256(preimageSha256);\\n\\n require(\\n CheckBitcoinSigs.checkSig(\\n walletPublicKey,\\n sighash,\\n signature.v,\\n signature.r,\\n signature.s\\n ),\\n \\\"Signature verification failure\\\"\\n );\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.Live ||\\n wallet.state == Wallets.WalletState.MovingFunds ||\\n wallet.state == Wallets.WalletState.Closing,\\n \\\"Wallet must be in Live or MovingFunds or Closing state\\\"\\n );\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n require(challenge.reportedAt == 0, \\\"Fraud challenge already exists\\\");\\n\\n challenge.challenger = msg.sender;\\n challenge.depositAmount = msg.value;\\n /* solhint-disable-next-line not-rely-on-time */\\n challenge.reportedAt = uint32(block.timestamp);\\n challenge.resolved = false;\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeSubmitted(\\n walletPubKeyHash,\\n sighash,\\n signature.v,\\n signature.r,\\n signature.s\\n );\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet if\\n /// the transaction that spends the UTXO follows the protocol rules.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during input signing.\\n /// The fraud challenge defeat attempt will only succeed if the\\n /// inputs in the preimage are considered honestly spent by the\\n /// wallet. Therefore the transaction spending the UTXO must be\\n /// proven in the Bridge before a challenge defeat is called.\\n /// If successfully defeated, the fraud challenge is marked as\\n /// resolved and the amount of ether deposited by the challenger is\\n /// sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @param witness Flag indicating whether the preimage was produced for a\\n /// witness input. True for witness, false for non-witness input.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`\\n /// must identify an open fraud challenge,\\n /// - the preimage must be a valid preimage of a transaction generated\\n /// according to the protocol rules and already proved in the Bridge,\\n /// - before a defeat attempt is made the transaction that spends the\\n /// given UTXO must be proven in the Bridge.\\n function defeatFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes calldata preimage,\\n bool witness\\n ) external {\\n bytes32 sighash = preimage.hash256();\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n // Ensure SIGHASH_ALL type was used during signing, which is represented\\n // by type value `1`.\\n require(extractSighashType(preimage) == 1, \\\"Wrong sighash type\\\");\\n\\n uint256 utxoKey = witness\\n ? extractUtxoKeyFromWitnessPreimage(preimage)\\n : extractUtxoKeyFromNonWitnessPreimage(preimage);\\n\\n // Check that the UTXO key identifies a correctly spent UTXO.\\n require(\\n self.deposits[utxoKey].sweptAt > 0 ||\\n self.spentMainUTXOs[utxoKey] ||\\n self.movedFundsSweepRequests[utxoKey].state ==\\n MovingFunds.MovedFundsSweepRequestState.Processed,\\n \\\"Spent UTXO not found among correctly spent UTXOs\\\"\\n );\\n\\n resolveFraudChallenge(self, walletPublicKey, challenge, sighash);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet by\\n /// proving the sighash and signature were produced for an off-chain\\n /// wallet heartbeat message following a strict format.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during heartbeat message\\n /// signing. The fraud challenge defeat attempt will only succeed if\\n /// the signed message follows a strict format required for\\n /// heartbeat messages. If successfully defeated, the fraud\\n /// challenge is marked as resolved and the amount of ether\\n /// deposited by the challenger is sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes),\\n /// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat\\n /// message format requirements which produces sighash used to\\n /// generate the ECDSA signature that is the subject of the fraud\\n /// claim.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as\\n /// `hash256(heartbeatMessage)` must identify an open fraud challenge,\\n /// - `heartbeatMessage` must follow a strict format of heartbeat\\n /// messages.\\n function defeatFraudChallengeWithHeartbeat(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes calldata heartbeatMessage\\n ) external {\\n bytes32 sighash = heartbeatMessage.hash256();\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n require(\\n Heartbeat.isValidHeartbeatMessage(heartbeatMessage),\\n \\\"Not a valid heartbeat message\\\"\\n );\\n\\n resolveFraudChallenge(self, walletPublicKey, challenge, sighash);\\n }\\n\\n /// @notice Called only for successfully defeated fraud challenges.\\n /// The fraud challenge is marked as resolved and the amount of\\n /// ether deposited by the challenger is sent to the treasury.\\n /// @dev Requirements:\\n /// - Must be called only for successfully defeated fraud challenges.\\n function resolveFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n FraudChallenge storage challenge,\\n bytes32 sighash\\n ) internal {\\n // Mark the challenge as resolved as it was successfully defeated\\n challenge.resolved = true;\\n\\n // Send the ether deposited by the challenger to the treasury\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel,arbitrary-send\\n self.treasury.call{gas: 100000, value: challenge.depositAmount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeDefeated(walletPubKeyHash, sighash);\\n }\\n\\n /// @notice Notifies about defeat timeout for the given fraud challenge.\\n /// Can be called only if there was a fraud challenge identified by\\n /// the provided `walletPublicKey` and `sighash` and it was not\\n /// defeated on time. The amount of time that needs to pass after\\n /// a fraud challenge is reported is indicated by the\\n /// `challengeDefeatTimeout`. After a successful fraud challenge\\n /// defeat timeout notification the fraud challenge is marked as\\n /// resolved, the stake of each operator is slashed, the ether\\n /// deposited is returned to the challenger and the challenger is\\n /// rewarded.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Closing or\\n /// Terminated state,\\n /// - The `walletPublicKey` and `sighash` calculated from\\n /// `preimageSha256` must identify an open fraud challenge,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time indicated by `challengeDefeatTimeout` must pass\\n /// after the challenge was reported.\\n function notifyFraudChallengeDefeatTimeout(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n uint32[] calldata walletMembersIDs,\\n bytes memory preimageSha256\\n ) external {\\n // Wallet state is validated in `notifyWalletFraudChallengeDefeatTimeout`.\\n\\n bytes32 sighash = sha256(preimageSha256);\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >=\\n challenge.reportedAt + self.fraudChallengeDefeatTimeout,\\n \\\"Fraud challenge defeat period did not time out yet\\\"\\n );\\n\\n challenge.resolved = true;\\n // Return the ether deposited by the challenger\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel\\n challenge.challenger.call{gas: 100000, value: challenge.depositAmount}(\\n \\\"\\\"\\n );\\n /* solhint-enable avoid-low-level-calls */\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n self.notifyWalletFraudChallengeDefeatTimeout(\\n walletPubKeyHash,\\n walletMembersIDs,\\n challenge.challenger\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeDefeatTimedOut(walletPubKeyHash, sighash);\\n }\\n\\n /// @notice Extracts the UTXO keys from the given preimage used during\\n /// signing of a witness input.\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference\\n /// @return utxoKey UTXO key that identifies spent input.\\n function extractUtxoKeyFromWitnessPreimage(bytes calldata preimage)\\n internal\\n pure\\n returns (uint256 utxoKey)\\n {\\n // The expected structure of the preimage created during signing of a\\n // witness input:\\n // - transaction version (4 bytes)\\n // - hash of previous outpoints of all inputs (32 bytes)\\n // - hash of sequences of all inputs (32 bytes)\\n // - outpoint (hash + index) of the input being signed (36 bytes)\\n // - the unlocking script of the input (variable length)\\n // - value of the outpoint (8 bytes)\\n // - sequence of the input being signed (4 bytes)\\n // - hash of all outputs (32 bytes)\\n // - transaction locktime (4 bytes)\\n // - sighash type (4 bytes)\\n\\n // See Bitcoin's BIP-143 for reference:\\n // https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki.\\n\\n // The outpoint (hash and index) is located at the constant offset of\\n // 68 (4 + 32 + 32).\\n bytes32 outpointTxHash = preimage.extractInputTxIdLeAt(68);\\n uint32 outpointIndex = BTCUtils.reverseUint32(\\n uint32(preimage.extractTxIndexLeAt(68))\\n );\\n\\n return\\n uint256(keccak256(abi.encodePacked(outpointTxHash, outpointIndex)));\\n }\\n\\n /// @notice Extracts the UTXO key from the given preimage used during\\n /// signing of a non-witness input.\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @return utxoKey UTXO key that identifies spent input.\\n function extractUtxoKeyFromNonWitnessPreimage(bytes calldata preimage)\\n internal\\n pure\\n returns (uint256 utxoKey)\\n {\\n // The expected structure of the preimage created during signing of a\\n // non-witness input:\\n // - transaction version (4 bytes)\\n // - number of inputs written as compactSize uint (1 byte, 3 bytes,\\n // 5 bytes or 9 bytes)\\n // - for each input\\n // - outpoint (hash and index) (36 bytes)\\n // - unlocking script for the input being signed (variable length)\\n // or `00` for all other inputs (1 byte)\\n // - input sequence (4 bytes)\\n // - number of outputs written as compactSize uint (1 byte, 3 bytes,\\n // 5 bytes or 9 bytes)\\n // - outputs (variable length)\\n // - transaction locktime (4 bytes)\\n // - sighash type (4 bytes)\\n\\n // See example for reference:\\n // https://en.bitcoin.it/wiki/OP_CHECKSIG#Code_samples_and_raw_dumps.\\n\\n // The input data begins at the constant offset of 4 (the first 4 bytes\\n // are for the transaction version).\\n (uint256 inputsCompactSizeUintLength, uint256 inputsCount) = preimage\\n .parseVarIntAt(4);\\n\\n // To determine the first input starting index, we must jump 4 bytes\\n // over the transaction version length and the compactSize uint which\\n // prepends the input vector. One byte must be added because\\n // `BtcUtils.parseVarInt` does not include compactSize uint tag in the\\n // returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 4 + 1 + inputsCompactSizeUintLength;\\n\\n for (uint256 i = 0; i < inputsCount; i++) {\\n uint256 inputLength = preimage.determineInputLengthAt(\\n inputStartingIndex\\n );\\n\\n (, uint256 scriptSigLength) = preimage.extractScriptSigLenAt(\\n inputStartingIndex\\n );\\n\\n if (scriptSigLength > 0) {\\n // The input this preimage was generated for was found.\\n // All the other inputs in the preimage are marked with a null\\n // scriptSig (\\\"00\\\") which has length of 1.\\n bytes32 outpointTxHash = preimage.extractInputTxIdLeAt(\\n inputStartingIndex\\n );\\n uint32 outpointIndex = BTCUtils.reverseUint32(\\n uint32(preimage.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n utxoKey = uint256(\\n keccak256(abi.encodePacked(outpointTxHash, outpointIndex))\\n );\\n\\n break;\\n }\\n\\n inputStartingIndex += inputLength;\\n }\\n\\n return utxoKey;\\n }\\n\\n /// @notice Extracts the sighash type from the given preimage.\\n /// @param preimage Serialized subset of the transaction. See BIP-143 for\\n /// reference.\\n /// @dev Sighash type is stored as the last 4 bytes in the preimage (little\\n /// endian).\\n /// @return sighashType Sighash type as a 32-bit integer.\\n function extractSighashType(bytes calldata preimage)\\n internal\\n pure\\n returns (uint32 sighashType)\\n {\\n bytes4 sighashTypeBytes = preimage.slice4(preimage.length - 4);\\n uint32 sighashTypeLE = uint32(sighashTypeBytes);\\n return sighashTypeLE.reverseUint32();\\n }\\n}\\n\",\"keccak256\":\"0x5b976a45cbee8e5d8e65fc748820e36c692d8fb26a8532319a87e6a614733c58\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Heartbeat.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\n/// @title Bridge wallet heartbeat\\n/// @notice The library establishes expected format for heartbeat messages\\n/// signed by wallet ECDSA signing group. Heartbeat messages are\\n/// constructed in such a way that they can not be used as a Bitcoin\\n/// transaction preimages.\\n/// @dev The smallest Bitcoin non-coinbase transaction is a one spending an\\n/// OP_TRUE anyonecanspend output and creating 1 OP_TRUE anyonecanspend\\n/// output. Such a transaction has 61 bytes (see `BitcoinTx` documentation):\\n/// 4 bytes for version\\n/// 1 byte for tx_in_count\\n/// 36 bytes for tx_in.previous_output\\n/// 1 byte for tx_in.script_bytes (value: 0)\\n/// 0 bytes for tx_in.signature_script\\n/// 4 bytes for tx_in.sequence\\n/// 1 byte for tx_out_count\\n/// 8 bytes for tx_out.value\\n/// 1 byte for tx_out.pk_script_bytes\\n/// 1 byte for tx_out.pk_script\\n/// 4 bytes for lock_time\\n///\\n///\\n/// The smallest Bitcoin coinbase transaction is a one creating\\n/// 1 OP_TRUE anyonecanspend output and having an empty coinbase script.\\n/// Such a transaction has 65 bytes:\\n/// 4 bytes for version\\n/// 1 byte for tx_in_count\\n/// 32 bytes for tx_in.hash (all 0x00)\\n/// 4 bytes for tx_in.index (all 0xff)\\n/// 1 byte for tx_in.script_bytes (value: 0)\\n/// 4 bytes for tx_in.height\\n/// 0 byte for tx_in.coinbase_script\\n/// 4 bytes for tx_in.sequence\\n/// 1 byte for tx_out_count\\n/// 8 bytes for tx_out.value\\n/// 1 byte for tx_out.pk_script_bytes\\n/// 1 byte for tx_out.pk_script\\n/// 4 bytes for lock_time\\n///\\n///\\n/// A SIGHASH flag is used to indicate which part of the transaction is\\n/// signed by the ECDSA signature. There are currently 3 flags:\\n/// SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE, and different combinations\\n/// of these flags.\\n///\\n/// No matter the SIGHASH flag and no matter the combination, the following\\n/// fields from the transaction are always included in the constructed\\n/// preimage:\\n/// 4 bytes for version\\n/// 36 bytes for tx_in.previous_output (or tx_in.hash + tx_in.index for coinbase)\\n/// 4 bytes for lock_time\\n///\\n/// Additionally, the last 4 bytes of the preimage determines the SIGHASH\\n/// flag.\\n///\\n/// This is enough to say there is no way the preimage could be shorter\\n/// than 4 + 36 + 4 + 4 = 48 bytes.\\n///\\n/// For this reason, we construct the heartbeat message, as a 16-byte\\n/// message. The first 8 bytes are 0xffffffffffffffff. The last 8 bytes\\n/// are for an arbitrary uint64, being a signed heartbeat nonce (for\\n/// example, the last Ethereum block hash).\\n///\\n/// The message being signed by the wallet when executing the heartbeat\\n/// protocol should be Bitcoin's hash256 (double SHA-256) of the heartbeat\\n/// message:\\n/// heartbeat_sighash = hash256(heartbeat_message)\\nlibrary Heartbeat {\\n using BytesLib for bytes;\\n\\n /// @notice Determines if the signed byte array is a valid, non-fraudulent\\n /// heartbeat message.\\n /// @param message Message signed by the wallet. It is a potential heartbeat\\n /// message, Bitcoin transaction preimage, or an arbitrary signed\\n /// bytes.\\n /// @dev Wallet heartbeat message must be exactly 16 bytes long with the first\\n /// 8 bytes set to 0xffffffffffffffff.\\n /// @return True if valid heartbeat message, false otherwise.\\n function isValidHeartbeatMessage(bytes calldata message)\\n internal\\n pure\\n returns (bool)\\n {\\n if (message.length != 16) {\\n return false;\\n }\\n\\n if (message.slice8(0) != 0xffffffffffffffff) {\\n return false;\\n }\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0x2f3ad70beadc4dfb6414064fd7b3621b1edcd2713f186853b4a5fd36fb4502ba\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/IRelay.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\n/// @title Interface for the Bitcoin relay\\n/// @notice Contains only the methods needed by tBTC v2. The Bitcoin relay\\n/// provides the difficulty of the previous and current epoch. One\\n/// difficulty epoch spans 2016 blocks.\\ninterface IRelay {\\n /// @notice Returns the difficulty of the current epoch.\\n function getCurrentEpochDifficulty() external view returns (uint256);\\n\\n /// @notice Returns the difficulty of the previous epoch.\\n function getPrevEpochDifficulty() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xf70c723fc0a1824d92061b5dc76c65c38c22eff6b18ef6a2057f511183ce3c5b\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/MovingFunds.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Moving Bridge wallet funds\\n/// @notice The library handles the logic for moving Bitcoin between Bridge\\n/// wallets.\\n/// @dev A wallet that failed a heartbeat, did not process requested redemption\\n/// on time, or qualifies to be closed, begins the procedure of moving\\n/// funds to other wallets in the Bridge. The wallet needs to commit to\\n/// which other Live wallets it is moving the funds to and then, provide an\\n/// SPV proof of moving funds to the previously committed wallets.\\n/// Once the proof is submitted, all target wallets are supposed to\\n/// sweep the received UTXOs with their own main UTXOs in order to\\n/// update their BTC balances.\\nlibrary MovingFunds {\\n using BridgeState for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents temporary information needed during the processing\\n /// of the moving funds Bitcoin transaction outputs. This structure\\n /// is an internal one and should not be exported outside of the\\n /// moving funds transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct MovingFundsTxOutputsProcessingInfo {\\n // 32-byte hash of the moving funds Bitcoin transaction.\\n bytes32 movingFundsTxHash;\\n // Output vector of the moving funds Bitcoin transaction. It is\\n // assumed the vector's structure is valid so it must be validated\\n // using e.g. `BTCUtils.validateVout` function before being used\\n // during the processing. The validation is usually done as part\\n // of the `BitcoinTx.validateProof` call that checks the SPV proof.\\n bytes movingFundsTxOutputVector;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents moved funds sweep request state.\\n enum MovedFundsSweepRequestState {\\n /// @dev The request is unknown to the Bridge.\\n Unknown,\\n /// @dev Request is pending and can become either processed or timed out.\\n Pending,\\n /// @dev Request was processed by the target wallet.\\n Processed,\\n /// @dev Request was not processed in the given time window and\\n /// the timeout was reported.\\n TimedOut\\n }\\n\\n /// @notice Represents a moved funds sweep request. The request is\\n /// registered in `submitMovingFundsProof` where we know funds\\n /// have been moved to the target wallet and the only step left is\\n /// to have the target wallet sweep them.\\n struct MovedFundsSweepRequest {\\n // 20-byte public key hash of the wallet supposed to sweep the UTXO\\n // representing the received funds with their own main UTXO\\n bytes20 walletPubKeyHash;\\n // Value of the received funds.\\n uint64 value;\\n // UNIX timestamp the request was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 createdAt;\\n // The current state of the request.\\n MovedFundsSweepRequestState state;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event MovingFundsCommitmentSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes20[] targetWallets,\\n address submitter\\n );\\n\\n event MovingFundsTimeoutReset(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash\\n );\\n\\n event MovingFundsTimedOut(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsBelowDustReported(bytes20 indexed walletPubKeyHash);\\n\\n event MovedFundsSwept(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sweepTxHash\\n );\\n\\n event MovedFundsSweepTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex\\n );\\n\\n /// @notice Submits the moving funds target wallets commitment.\\n /// Once all requirements are met, that function registers the\\n /// target wallets commitment and opens the way for moving funds\\n /// proof submission.\\n /// @param walletPubKeyHash 20-byte public key hash of the source wallet.\\n /// @param walletMainUtxo Data of the source wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletMembersIDs Identifiers of the source wallet signing group\\n /// members.\\n /// @param walletMemberIndex Position of the caller in the source wallet\\n /// signing group members list.\\n /// @param targetWallets List of 20-byte public key hashes of the target\\n /// wallets that the source wallet commits to move the funds to.\\n /// @dev Requirements:\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The source wallet must not have pending redemption requests,\\n /// - The source wallet must not have pending moved funds sweep requests,\\n /// - The source wallet must not have submitted its commitment already,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given source wallet in the ECDSA registry. Those IDs are\\n /// not directly stored in the contract for gas efficiency purposes\\n /// but they can be read from appropriate `DkgResultSubmitted`\\n /// and `DkgResultApproved` events,\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],\\n /// - The caller must be the member of the source wallet signing group\\n /// at the position indicated by `walletMemberIndex` parameter,\\n /// - The `walletMainUtxo` components must point to the recent main\\n /// UTXO of the source wallet, as currently known on the Ethereum\\n /// chain,\\n /// - Source wallet BTC balance must be greater than zero,\\n /// - At least one Live wallet must exist in the system,\\n /// - Submitted target wallets count must match the expected count\\n /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`\\n /// where `N > 0`,\\n /// - Each target wallet must be not equal to the source wallet,\\n /// - Each target wallet must follow the expected order i.e. all\\n /// target wallets 20-byte public key hashes represented as numbers\\n /// must form a strictly increasing sequence without duplicates,\\n /// - Each target wallet must be in Live state.\\n function submitMovingFundsCommitment(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo,\\n uint32[] calldata walletMembersIDs,\\n uint256 walletMemberIndex,\\n bytes20[] calldata targetWallets\\n ) external {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Source wallet must be in MovingFunds state\\\"\\n );\\n\\n require(\\n wallet.pendingRedemptionsValue == 0,\\n \\\"Source wallet must handle all pending redemptions first\\\"\\n );\\n\\n require(\\n wallet.pendingMovedFundsSweepRequestsCount == 0,\\n \\\"Source wallet must handle all pending moved funds sweep requests first\\\"\\n );\\n\\n require(\\n wallet.movingFundsTargetWalletsCommitmentHash == bytes32(0),\\n \\\"Target wallets commitment already submitted\\\"\\n );\\n\\n require(\\n self.ecdsaWalletRegistry.isWalletMember(\\n wallet.ecdsaWalletID,\\n walletMembersIDs,\\n msg.sender,\\n walletMemberIndex\\n ),\\n \\\"Caller is not a member of the source wallet\\\"\\n );\\n\\n uint64 walletBtcBalance = self.getWalletBtcBalance(\\n walletPubKeyHash,\\n walletMainUtxo\\n );\\n\\n require(walletBtcBalance > 0, \\\"Wallet BTC balance is zero\\\");\\n\\n uint256 expectedTargetWalletsCount = Math.min(\\n self.liveWalletsCount,\\n Math.ceilDiv(walletBtcBalance, self.walletMaxBtcTransfer)\\n );\\n\\n // This requirement fails only when `liveWalletsCount` is zero. In\\n // that case, the system cannot accept the commitment and must provide\\n // new wallets first. However, the wallet supposed to submit the\\n // commitment can keep resetting the moving funds timeout until then.\\n require(expectedTargetWalletsCount > 0, \\\"No target wallets available\\\");\\n\\n require(\\n targetWallets.length == expectedTargetWalletsCount,\\n \\\"Submitted target wallets count is other than expected\\\"\\n );\\n\\n uint160 lastProcessedTargetWallet = 0;\\n\\n for (uint256 i = 0; i < targetWallets.length; i++) {\\n bytes20 targetWallet = targetWallets[i];\\n\\n require(\\n targetWallet != walletPubKeyHash,\\n \\\"Submitted target wallet cannot be equal to the source wallet\\\"\\n );\\n\\n require(\\n uint160(targetWallet) > lastProcessedTargetWallet,\\n \\\"Submitted target wallet breaks the expected order\\\"\\n );\\n\\n require(\\n self.registeredWallets[targetWallet].state ==\\n Wallets.WalletState.Live,\\n \\\"Submitted target wallet must be in Live state\\\"\\n );\\n\\n lastProcessedTargetWallet = uint160(targetWallet);\\n }\\n\\n wallet.movingFundsTargetWalletsCommitmentHash = keccak256(\\n abi.encodePacked(targetWallets)\\n );\\n\\n emit MovingFundsCommitmentSubmitted(\\n walletPubKeyHash,\\n targetWallets,\\n msg.sender\\n );\\n }\\n\\n /// @notice Resets the moving funds timeout for the given wallet if the\\n /// target wallet commitment cannot be submitted due to a lack\\n /// of live wallets in the system.\\n /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must not be already submitted for\\n /// the given moving funds wallet,\\n /// - Live wallets count must be zero,\\n /// - The moving funds timeout reset delay must be elapsed.\\n function resetMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) external {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n // If the moving funds wallet already submitted their target wallets\\n // commitment, there is no point to reset the timeout since the\\n // wallet can make the BTC transaction and submit the proof.\\n require(\\n wallet.movingFundsTargetWalletsCommitmentHash == bytes32(0),\\n \\\"Target wallets commitment already submitted\\\"\\n );\\n\\n require(self.liveWalletsCount == 0, \\\"Live wallets count must be zero\\\");\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n wallet.movingFundsRequestedAt +\\n self.movingFundsTimeoutResetDelay,\\n \\\"Moving funds timeout cannot be reset yet\\\"\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.movingFundsRequestedAt = uint32(block.timestamp);\\n\\n emit MovingFundsTimeoutReset(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moving funds transaction\\n /// and to make the necessary state changes. Moving funds is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the moving funds transaction structure\\n /// by checking if it actually spends the main UTXO of the declared\\n /// wallet and locks the value on the pre-committed target wallets\\n /// using a reasonable transaction fee. If all preconditions are\\n /// met, this functions closes the source wallet.\\n ///\\n /// It is possible to prove the given moving funds transaction only\\n /// one time.\\n /// @param movingFundsTx Bitcoin moving funds transaction data.\\n /// @param movingFundsProof Bitcoin moving funds proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet\\n /// which performed the moving funds transaction.\\n /// @dev Requirements:\\n /// - `movingFundsTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `movingFundsTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs corresponding to the\\n /// pre-committed target wallets. Outputs must be ordered in the\\n /// same way as their corresponding target wallets are ordered\\n /// within the target wallets commitment,\\n /// - `movingFundsProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input,\\n /// - The wallet that `walletPubKeyHash` points to must be in the\\n /// MovingFunds state,\\n /// - The target wallets commitment must be submitted by the wallet\\n /// that `walletPubKeyHash` points to,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movingFundsTxMaxTotalFee` governable parameter.\\n function submitMovingFundsProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata movingFundsTx,\\n BitcoinTx.Proof calldata movingFundsProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external {\\n // Wallet state is validated in `notifyWalletFundsMoved`.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 movingFundsTxHash = self.validateProof(\\n movingFundsTx,\\n movingFundsProof\\n );\\n\\n // Assert that main UTXO for passed wallet exists in storage.\\n bytes32 mainUtxoHash = self\\n .registeredWallets[walletPubKeyHash]\\n .mainUtxoHash;\\n require(mainUtxoHash != bytes32(0), \\\"No main UTXO for given wallet\\\");\\n\\n // Assert that passed main UTXO parameter is the same as in storage and\\n // can be used for further processing.\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n // Process the moving funds transaction input. Specifically, check if\\n // it refers to the expected wallet's main UTXO.\\n OutboundTx.processWalletOutboundTxInput(\\n self,\\n movingFundsTx.inputVector,\\n mainUtxo\\n );\\n\\n (\\n bytes32 targetWalletsHash,\\n uint256 outputsTotalValue\\n ) = processMovingFundsTxOutputs(\\n self,\\n MovingFundsTxOutputsProcessingInfo(\\n movingFundsTxHash,\\n movingFundsTx.outputVector\\n )\\n );\\n\\n require(\\n mainUtxo.txOutputValue - outputsTotalValue <=\\n self.movingFundsTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n self.notifyWalletFundsMoved(walletPubKeyHash, targetWalletsHash);\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsCompleted(walletPubKeyHash, movingFundsTxHash);\\n }\\n\\n /// @notice Processes the moving funds Bitcoin transaction output vector\\n /// and extracts information required for further processing.\\n /// @param processInfo Processing info containing the moving funds tx\\n /// hash and output vector.\\n /// @return targetWalletsHash keccak256 hash over the list of actual\\n /// target wallets used in the transaction.\\n /// @return outputsTotalValue Sum of all outputs values.\\n /// @dev Requirements:\\n /// - The `movingFundsTxOutputVector` must be parseable, i.e. must\\n /// be validated by the caller as stated in their parameter doc,\\n /// - Each output must refer to a 20-byte public key hash,\\n /// - The total outputs value must be evenly divided over all outputs.\\n function processMovingFundsTxOutputs(\\n BridgeState.Storage storage self,\\n MovingFundsTxOutputsProcessingInfo memory processInfo\\n ) internal returns (bytes32 targetWalletsHash, uint256 outputsTotalValue) {\\n // Determining the total number of Bitcoin transaction outputs in\\n // the same way as for number of inputs. See `BitcoinTx.outputVector`\\n // docs for more details.\\n (\\n uint256 outputsCompactSizeUintLength,\\n uint256 outputsCount\\n ) = processInfo.movingFundsTxOutputVector.parseVarInt();\\n\\n // To determine the first output starting index, we must jump over\\n // the compactSize uint which prepends the output vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 outputStartingIndex = 1 + outputsCompactSizeUintLength;\\n\\n bytes20[] memory targetWallets = new bytes20[](outputsCount);\\n uint64[] memory outputsValues = new uint64[](outputsCount);\\n\\n // Outputs processing loop. Note that the `outputIndex` must be\\n // `uint32` to build proper `movedFundsSweepRequests` keys.\\n for (\\n uint32 outputIndex = 0;\\n outputIndex < outputsCount;\\n outputIndex++\\n ) {\\n uint256 outputLength = processInfo\\n .movingFundsTxOutputVector\\n .determineOutputLengthAt(outputStartingIndex);\\n\\n bytes memory output = processInfo.movingFundsTxOutputVector.slice(\\n outputStartingIndex,\\n outputLength\\n );\\n\\n bytes20 targetWalletPubKeyHash = self.extractPubKeyHash(output);\\n\\n // Add the wallet public key hash to the list that will be used\\n // to build the result list hash. There is no need to check if\\n // given output is a change here because the actual target wallet\\n // list must be exactly the same as the pre-committed target wallet\\n // list which is guaranteed to be valid.\\n targetWallets[outputIndex] = targetWalletPubKeyHash;\\n\\n // Extract the value from given output.\\n outputsValues[outputIndex] = output.extractValue();\\n outputsTotalValue += outputsValues[outputIndex];\\n\\n // Register a moved funds sweep request that must be handled\\n // by the target wallet. The target wallet must sweep the\\n // received funds with their own main UTXO in order to update\\n // their BTC balance. Worth noting there is no need to check\\n // if the sweep request already exists in the system because\\n // the moving funds wallet is moved to the Closing state after\\n // submitting the moving funds proof so there is no possibility\\n // to submit the proof again and register the sweep request twice.\\n self.movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n processInfo.movingFundsTxHash,\\n outputIndex\\n )\\n )\\n )\\n ] = MovedFundsSweepRequest(\\n targetWalletPubKeyHash,\\n outputsValues[outputIndex],\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp),\\n MovedFundsSweepRequestState.Pending\\n );\\n // We added a new moved funds sweep request for the target wallet\\n // so we must increment their request counter.\\n self\\n .registeredWallets[targetWalletPubKeyHash]\\n .pendingMovedFundsSweepRequestsCount++;\\n\\n // Make the `outputStartingIndex` pointing to the next output by\\n // increasing it by current output's length.\\n outputStartingIndex += outputLength;\\n }\\n\\n // Compute the indivisible remainder that remains after dividing the\\n // outputs total value over all outputs evenly.\\n uint256 outputsTotalValueRemainder = outputsTotalValue % outputsCount;\\n // Compute the minimum allowed output value by dividing the outputs\\n // total value (reduced by the remainder) by the number of outputs.\\n uint256 minOutputValue = (outputsTotalValue -\\n outputsTotalValueRemainder) / outputsCount;\\n // Maximum possible value is the minimum value with the remainder included.\\n uint256 maxOutputValue = minOutputValue + outputsTotalValueRemainder;\\n\\n for (uint256 i = 0; i < outputsCount; i++) {\\n require(\\n minOutputValue <= outputsValues[i] &&\\n outputsValues[i] <= maxOutputValue,\\n \\\"Transaction amount is not distributed evenly\\\"\\n );\\n }\\n\\n targetWalletsHash = keccak256(abi.encodePacked(targetWallets));\\n\\n return (targetWalletsHash, outputsTotalValue);\\n }\\n\\n /// @notice Notifies about a timed out moving funds process. Terminates\\n /// the wallet and slashes signing group members as a result.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The moving funds timeout must be actually exceeded,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n // Wallet state is validated in `notifyWalletMovingFundsTimeout`.\\n\\n uint32 movingFundsRequestedAt = self\\n .registeredWallets[walletPubKeyHash]\\n .movingFundsRequestedAt;\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp > movingFundsRequestedAt + self.movingFundsTimeout,\\n \\\"Moving funds has not timed out yet\\\"\\n );\\n\\n self.notifyWalletMovingFundsTimeout(walletPubKeyHash, walletMembersIDs);\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsTimedOut(walletPubKeyHash);\\n }\\n\\n /// @notice Notifies about a moving funds wallet whose BTC balance is\\n /// below the moving funds dust threshold. Ends the moving funds\\n /// process and begins wallet closing immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known\\n /// on the Ethereum chain.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored,\\n /// - The wallet BTC balance must be below the moving funds threshold.\\n function notifyMovingFundsBelowDust(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n // Wallet state is validated in `notifyWalletMovingFundsBelowDust`.\\n\\n uint64 walletBtcBalance = self.getWalletBtcBalance(\\n walletPubKeyHash,\\n mainUtxo\\n );\\n\\n require(\\n walletBtcBalance < self.movingFundsDustThreshold,\\n \\\"Wallet BTC balance must be below the moving funds dust threshold\\\"\\n );\\n\\n self.notifyWalletMovingFundsBelowDust(walletPubKeyHash);\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsBelowDustReported(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moved funds sweep\\n /// transaction and to make the necessary state changes. Moved\\n /// funds sweep is only accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the sweep transaction structure by\\n /// checking if it actually spends the moved funds UTXO and the\\n /// sweeping wallet's main UTXO (optionally), and if it locks the\\n /// value on the sweeping wallet's 20-byte public key hash using a\\n /// reasonable transaction fee. If all preconditions are\\n /// met, this function updates the sweeping wallet main UTXO, thus\\n /// their BTC balance.\\n ///\\n /// It is possible to prove the given sweep transaction only\\n /// one time.\\n /// @param sweepTx Bitcoin sweep funds transaction data.\\n /// @param sweepProof Bitcoin sweep funds proof data.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with\\n /// the first input pointing to a wallet's sweep Pending request and,\\n /// optionally, the second input pointing to the wallet's main UTXO,\\n /// if the sweeping wallet has a main UTXO set. There should be only\\n /// one output locking funds on the sweeping wallet 20-byte public\\n /// key hash,\\n /// - `sweepProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the sweeping wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored,\\n /// - The sweeping wallet must be in the Live or MovingFunds state,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movedFundsSweepTxMaxTotalFee` governable parameter.\\n function submitMovedFundsSweepProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n // Wallet state validation is performed in the\\n // `resolveMovedFundsSweepingWallet` function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 sweepTxHash = self.validateProof(sweepTx, sweepProof);\\n\\n (\\n bytes20 walletPubKeyHash,\\n uint64 sweepTxOutputValue\\n ) = processMovedFundsSweepTxOutput(self, sweepTx.outputVector);\\n\\n (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n ) = resolveMovedFundsSweepingWallet(self, walletPubKeyHash, mainUtxo);\\n\\n uint256 sweepTxInputsTotalValue = processMovedFundsSweepTxInputs(\\n self,\\n sweepTx.inputVector,\\n resolvedMainUtxo,\\n walletPubKeyHash\\n );\\n\\n require(\\n sweepTxInputsTotalValue - sweepTxOutputValue <=\\n self.movedFundsSweepTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n // Use the sweep transaction output as the new sweeping wallet's main UTXO.\\n // Transaction output index is always 0 as sweep transaction always\\n // contains only one output.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(sweepTxHash, uint32(0), sweepTxOutputValue)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovedFundsSwept(walletPubKeyHash, sweepTxHash);\\n }\\n\\n /// @notice Processes the Bitcoin moved funds sweep transaction output vector\\n /// by extracting the single output and using it to gain additional\\n /// information required for further processing (e.g. value and\\n /// wallet public key hash).\\n /// @param sweepTxOutputVector Bitcoin moved funds sweep transaction output\\n /// vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVout` function before\\n /// it is passed here.\\n /// @return walletPubKeyHash 20-byte wallet public key hash.\\n /// @return value 8-byte moved funds sweep transaction output value.\\n /// @dev Requirements:\\n /// - Output vector must contain only one output,\\n /// - The single output must be of P2PKH or P2WPKH type and lock the\\n /// funds on a 20-byte public key hash.\\n function processMovedFundsSweepTxOutput(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxOutputVector\\n ) internal view returns (bytes20 walletPubKeyHash, uint64 value) {\\n // To determine the total number of sweep transaction outputs, we need to\\n // parse the compactSize uint (VarInt) the output vector is prepended by.\\n // That compactSize uint encodes the number of vector elements using the\\n // format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVout` validation performed as\\n // part of the `BitcoinTx.validateProof` call.\\n // See `BitcoinTx.outputVector` docs for more details.\\n (, uint256 outputsCount) = sweepTxOutputVector.parseVarInt();\\n require(\\n outputsCount == 1,\\n \\\"Moved funds sweep transaction must have a single output\\\"\\n );\\n\\n bytes memory output = sweepTxOutputVector.extractOutputAtIndex(0);\\n walletPubKeyHash = self.extractPubKeyHash(output);\\n value = output.extractValue();\\n\\n return (walletPubKeyHash, value);\\n }\\n\\n /// @notice Resolves sweeping wallet based on the provided wallet public key\\n /// hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @return wallet Data of the sweeping wallet.\\n /// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet\\n /// resolved by cross-checking the `mainUtxo` parameter with\\n /// the chain state. If the validation went well, this is the\\n /// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - If the main UTXO of the sweeping wallet exists in the storage,\\n /// the passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveMovedFundsSweepingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n )\\n internal\\n view\\n returns (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n )\\n {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n\\n // Check if the main UTXO for given wallet exists. If so, validate\\n // passed main UTXO data against the stored hash and use them for\\n // further processing. If no main UTXO exists, use empty data.\\n resolvedMainUtxo = BitcoinTx.UTXO(bytes32(0), 0, 0);\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n if (mainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n resolvedMainUtxo = mainUtxo;\\n }\\n }\\n\\n /// @notice Processes the Bitcoin moved funds sweep transaction input vector.\\n /// It extracts the first input and tries to match it with one of\\n /// the moved funds sweep requests targeting the sweeping wallet.\\n /// If the sweep request is an existing Pending request, this\\n /// function marks it as Processed. If the sweeping wallet has a\\n /// main UTXO, this function extracts the second input, makes sure\\n /// it refers to the wallet main UTXO, and marks that main UTXO as\\n /// correctly spent.\\n /// @param sweepTxInputVector Bitcoin moved funds sweep transaction input vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before\\n /// it is passed here.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO. If no main UTXO\\n /// exists for the given the wallet, this parameter's fields should\\n /// be zeroed to bypass the main UTXO validation.\\n /// @param walletPubKeyHash 20-byte public key hash of the sweeping wallet.\\n /// @return inputsTotalValue Total inputs value sum.\\n /// @dev Requirements:\\n /// - The input vector must consist of one mandatory and one optional\\n /// input,\\n /// - The mandatory input must be the first input in the vector,\\n /// - The mandatory input must point to a Pending moved funds sweep\\n /// request that is targeted to the sweeping wallet,\\n /// - The optional output must be the second input in the vector,\\n /// - The optional input is required if the sweeping wallet has a\\n /// main UTXO (i.e. the `mainUtxo` is not zeroed). In that case,\\n /// that input must point the the sweeping wallet main UTXO.\\n function processMovedFundsSweepTxInputs(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxInputVector,\\n BitcoinTx.UTXO memory mainUtxo,\\n bytes20 walletPubKeyHash\\n ) internal returns (uint256 inputsTotalValue) {\\n // To determine the total number of Bitcoin transaction inputs,\\n // we need to parse the compactSize uint (VarInt) the input vector is\\n // prepended by. That compactSize uint encodes the number of vector\\n // elements using the format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVin` validation performed as\\n // part of the `BitcoinTx.validateProof` call.\\n // See `BitcoinTx.inputVector` docs for more details.\\n (\\n uint256 inputsCompactSizeUintLength,\\n uint256 inputsCount\\n ) = sweepTxInputVector.parseVarInt();\\n\\n // To determine the first input starting index, we must jump over\\n // the compactSize uint which prepends the input vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 1 + inputsCompactSizeUintLength;\\n\\n // We always expect the first input to be the swept UTXO. Additionally,\\n // if the sweeping wallet has a main UTXO, that main UTXO should be\\n // pointed by the second input.\\n require(\\n inputsCount == (mainUtxo.txHash != bytes32(0) ? 2 : 1),\\n \\\"Moved funds sweep transaction must have a proper inputs count\\\"\\n );\\n\\n // Parse the first input and extract its outpoint tx hash and index.\\n (\\n bytes32 firstInputOutpointTxHash,\\n uint32 firstInputOutpointIndex,\\n uint256 firstInputLength\\n ) = parseMovedFundsSweepTxInputAt(\\n sweepTxInputVector,\\n inputStartingIndex\\n );\\n\\n // Build the request key and fetch the corresponding moved funds sweep\\n // request from contract storage.\\n MovedFundsSweepRequest storage sweepRequest = self\\n .movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n firstInputOutpointTxHash,\\n firstInputOutpointIndex\\n )\\n )\\n )\\n ];\\n\\n require(\\n sweepRequest.state == MovedFundsSweepRequestState.Pending,\\n \\\"Sweep request must be in Pending state\\\"\\n );\\n // We must check if the wallet extracted from the moved funds sweep\\n // transaction output is truly the owner of the sweep request connected\\n // with the swept UTXO. This is needed to prevent a case when a wallet\\n // handles its own sweep request but locks the funds on another\\n // wallet public key hash.\\n require(\\n sweepRequest.walletPubKeyHash == walletPubKeyHash,\\n \\\"Sweep request belongs to another wallet\\\"\\n );\\n // If the validation passed, the sweep request must be marked as\\n // processed and its value should be counted into the total inputs\\n // value sum.\\n sweepRequest.state = MovedFundsSweepRequestState.Processed;\\n inputsTotalValue += sweepRequest.value;\\n\\n self\\n .registeredWallets[walletPubKeyHash]\\n .pendingMovedFundsSweepRequestsCount--;\\n\\n // If the main UTXO for the sweeping wallet exists, it must be processed.\\n if (mainUtxo.txHash != bytes32(0)) {\\n // The second input is supposed to point to that sweeping wallet\\n // main UTXO. We need to parse that input.\\n (\\n bytes32 secondInputOutpointTxHash,\\n uint32 secondInputOutpointIndex,\\n\\n ) = parseMovedFundsSweepTxInputAt(\\n sweepTxInputVector,\\n inputStartingIndex + firstInputLength\\n );\\n // Make sure the second input refers to the sweeping wallet main UTXO.\\n require(\\n mainUtxo.txHash == secondInputOutpointTxHash &&\\n mainUtxo.txOutputIndex == secondInputOutpointIndex,\\n \\\"Second input must point to the wallet's main UTXO\\\"\\n );\\n\\n // If the validation passed, count the main UTXO value into the\\n // total inputs value sum.\\n inputsTotalValue += mainUtxo.txOutputValue;\\n\\n // Main UTXO used as an input, mark it as spent. This is needed\\n // to defend against fraud challenges referring to this main UTXO.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n secondInputOutpointTxHash,\\n secondInputOutpointIndex\\n )\\n )\\n )\\n ] = true;\\n }\\n\\n return inputsTotalValue;\\n }\\n\\n /// @notice Parses a Bitcoin transaction input starting at the given index.\\n /// @param inputVector Bitcoin transaction input vector.\\n /// @param inputStartingIndex Index the given input starts at.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the given input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the given input's outpoint.\\n /// @return inputLength Byte length of the given input.\\n /// @dev This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before it\\n /// is passed here.\\n function parseMovedFundsSweepTxInputAt(\\n bytes memory inputVector,\\n uint256 inputStartingIndex\\n )\\n internal\\n pure\\n returns (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n )\\n {\\n outpointTxHash = inputVector.extractInputTxIdLeAt(inputStartingIndex);\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(inputVector.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n inputLength = inputVector.determineInputLengthAt(inputStartingIndex);\\n\\n return (outpointTxHash, outpointIndex, inputLength);\\n }\\n\\n /// @notice Notifies about a timed out moved funds sweep process. If the\\n /// wallet is not terminated yet, that function terminates\\n /// the wallet and slashes signing group members as a result.\\n /// Marks the given sweep request as TimedOut.\\n /// @param movingFundsTxHash 32-byte hash of the moving funds transaction\\n /// that caused the sweep request to be created.\\n /// @param movingFundsTxOutputIndex Index of the moving funds transaction\\n /// output that is subject of the sweep request.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The moved funds sweep request must be in the Pending state,\\n /// - The moved funds sweep timeout must be actually exceeded,\\n /// - The wallet must be either in the Live or MovingFunds or\\n /// Terminated state,,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovedFundsSweepTimeout(\\n BridgeState.Storage storage self,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n // Wallet state is validated in `notifyWalletMovedFundsSweepTimeout`.\\n\\n MovedFundsSweepRequest storage sweepRequest = self\\n .movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n movingFundsTxHash,\\n movingFundsTxOutputIndex\\n )\\n )\\n )\\n ];\\n\\n require(\\n sweepRequest.state == MovedFundsSweepRequestState.Pending,\\n \\\"Sweep request must be in Pending state\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n sweepRequest.createdAt + self.movedFundsSweepTimeout,\\n \\\"Sweep request has not timed out yet\\\"\\n );\\n\\n bytes20 walletPubKeyHash = sweepRequest.walletPubKeyHash;\\n\\n self.notifyWalletMovedFundsSweepTimeout(\\n walletPubKeyHash,\\n walletMembersIDs\\n );\\n\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n sweepRequest.state = MovedFundsSweepRequestState.TimedOut;\\n wallet.pendingMovedFundsSweepRequestsCount--;\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovedFundsSweepTimedOut(\\n walletPubKeyHash,\\n movingFundsTxHash,\\n movingFundsTxOutputIndex\\n );\\n }\\n}\\n\",\"keccak256\":\"0xce1afc1875d364e64cfa088558ee166a441e55ef6727f38002934654ac14b25d\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Redemption.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @notice Aggregates functions common to the redemption transaction proof\\n/// validation and to the moving funds transaction proof validation.\\nlibrary OutboundTx {\\n using BTCUtils for bytes;\\n\\n /// @notice Checks whether an outbound Bitcoin transaction performed from\\n /// the given wallet has an input vector that contains a single\\n /// input referring to the wallet's main UTXO. Marks that main UTXO\\n /// as correctly spent if the validation succeeds. Reverts otherwise.\\n /// There are two outbound transactions from a wallet possible: a\\n /// redemption transaction or a moving funds to another wallet\\n /// transaction.\\n /// @param walletOutboundTxInputVector Bitcoin outbound transaction's input\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVin` function\\n /// before it is passed here.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n function processWalletOutboundTxInput(\\n BridgeState.Storage storage self,\\n bytes memory walletOutboundTxInputVector,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) internal {\\n // Assert that the single outbound transaction input actually\\n // refers to the wallet's main UTXO.\\n (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex\\n ) = parseWalletOutboundTxInput(walletOutboundTxInputVector);\\n require(\\n mainUtxo.txHash == outpointTxHash &&\\n mainUtxo.txOutputIndex == outpointIndex,\\n \\\"Outbound transaction input must point to the wallet's main UTXO\\\"\\n );\\n\\n // Main UTXO used as an input, mark it as spent.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(mainUtxo.txHash, mainUtxo.txOutputIndex)\\n )\\n )\\n ] = true;\\n }\\n\\n /// @notice Parses the input vector of an outbound Bitcoin transaction\\n /// performed from the given wallet. It extracts the single input\\n /// then the transaction hash and output index from its outpoint.\\n /// There are two outbound transactions from a wallet possible: a\\n /// redemption transaction or a moving funds to another wallet\\n /// transaction.\\n /// @param walletOutboundTxInputVector Bitcoin outbound transaction input\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVin` function\\n /// before it is passed here.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the input's outpoint.\\n function parseWalletOutboundTxInput(\\n bytes memory walletOutboundTxInputVector\\n ) internal pure returns (bytes32 outpointTxHash, uint32 outpointIndex) {\\n // To determine the total number of Bitcoin transaction inputs,\\n // we need to parse the compactSize uint (VarInt) the input vector is\\n // prepended by. That compactSize uint encodes the number of vector\\n // elements using the format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVin` validation.\\n // See `BitcoinTx.inputVector` docs for more details.\\n (, uint256 inputsCount) = walletOutboundTxInputVector.parseVarInt();\\n require(\\n inputsCount == 1,\\n \\\"Outbound transaction must have a single input\\\"\\n );\\n\\n bytes memory input = walletOutboundTxInputVector.extractInputAtIndex(0);\\n\\n outpointTxHash = input.extractInputTxIdLE();\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(input.extractTxIndexLE())\\n );\\n\\n // There is only one input in the transaction. Input has an outpoint\\n // field that is a reference to the transaction being spent (see\\n // `BitcoinTx` docs). The outpoint contains the hash of the transaction\\n // to spend (`outpointTxHash`) and the index of the specific output\\n // from that transaction (`outpointIndex`).\\n return (outpointTxHash, outpointIndex);\\n }\\n}\\n\\n/// @title Bridge redemption\\n/// @notice The library handles the logic for redeeming Bitcoin balances from\\n/// the Bridge.\\n/// @dev To initiate a redemption, a user with a Bank balance supplies\\n/// a Bitcoin address. Then, the system calculates the redemption fee, and\\n/// releases balance to the provided Bitcoin address. Just like in case of\\n/// sweeps of revealed deposits, redemption requests are processed in\\n/// batches and require SPV proof to be submitted to the Bridge.\\nlibrary Redemption {\\n using BridgeState for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents a redemption request.\\n struct RedemptionRequest {\\n // ETH address of the redeemer who created the request.\\n address redeemer;\\n // Requested TBTC amount in satoshi.\\n uint64 requestedAmount;\\n // Treasury TBTC fee in satoshi at the moment of request creation.\\n uint64 treasuryFee;\\n // Transaction maximum BTC fee in satoshi at the moment of request\\n // creation.\\n uint64 txMaxFee;\\n // UNIX timestamp the request was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 requestedAt;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n /// @notice Represents an outcome of the redemption Bitcoin transaction\\n /// outputs processing.\\n struct RedemptionTxOutputsInfo {\\n // Sum of all outputs values i.e. all redemptions and change value,\\n // if present.\\n uint256 outputsTotalValue;\\n // Total TBTC value in satoshi that should be burned by the Bridge.\\n // It includes the total amount of all BTC redeemed in the transaction\\n // and the fee paid to BTC miners for the redemption transaction.\\n uint64 totalBurnableValue;\\n // Total TBTC value in satoshi that should be transferred to\\n // the treasury. It is a sum of all treasury fees paid by all\\n // redeemers included in the redemption transaction.\\n uint64 totalTreasuryFee;\\n // Index of the change output. The change output becomes\\n // the new main wallet's UTXO.\\n uint32 changeIndex;\\n // Value in satoshi of the change output.\\n uint64 changeValue;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents temporary information needed during the processing of\\n /// the redemption Bitcoin transaction outputs. This structure is an\\n /// internal one and should not be exported outside of the redemption\\n /// transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct RedemptionTxOutputsProcessingInfo {\\n // The first output starting index in the transaction.\\n uint256 outputStartingIndex;\\n // The number of outputs in the transaction.\\n uint256 outputsCount;\\n // P2PKH script for the wallet. Needed to determine the change output.\\n bytes32 walletP2PKHScriptKeccak;\\n // P2WPKH script for the wallet. Needed to determine the change output.\\n bytes32 walletP2WPKHScriptKeccak;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n event RedemptionRequested(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript,\\n address indexed redeemer,\\n uint64 requestedAmount,\\n uint64 treasuryFee,\\n uint64 txMaxFee\\n );\\n\\n event RedemptionsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 redemptionTxHash\\n );\\n\\n event RedemptionTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript\\n );\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script.\\n /// This function handles the simplest case, where balance owner is\\n /// the redeemer.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed. Balance owner address is stored as\\n /// a redeemer address who will be able co claim back the Bank\\n /// balance if anything goes wrong during the redemption.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address balanceOwner,\\n bytes calldata redeemerOutputScript,\\n uint64 amount\\n ) external {\\n requestRedemption(\\n self,\\n walletPubKeyHash,\\n mainUtxo,\\n balanceOwner,\\n balanceOwner,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Used by\\n /// `Bridge.receiveBalanceApproval`. Can handle more complex cases\\n /// where balance owner may be someone else than the redeemer.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @param redemptionData ABI-encoded redemption data:\\n /// [\\n /// address redeemer,\\n /// bytes20 walletPubKeyHash,\\n /// bytes32 mainUtxoTxHash,\\n /// uint32 mainUtxoTxOutputIndex,\\n /// uint64 mainUtxoTxOutputValue,\\n /// bytes redeemerOutputScript\\n /// ]\\n ///\\n /// - redeemer: The Ethereum address of the redeemer who will be able\\n /// to claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their Bitcoin\\n /// balance from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to,\\n /// - walletPubKeyHash: The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key),\\n /// - mainUtxoTxHash: Data of the wallet's main UTXO TX hash, as\\n /// currently known on the Ethereum chain,\\n /// - mainUtxoTxOutputIndex: Data of the wallet's main UTXO output\\n /// index, as currently known on Ethereum chain,\\n /// - mainUtxoTxOutputValue: Data of the wallet's main UTXO output\\n /// value, as currently known on Ethereum chain,\\n /// - redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo*` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n address balanceOwner,\\n uint64 amount,\\n bytes calldata redemptionData\\n ) external {\\n (\\n address redeemer,\\n bytes20 walletPubKeyHash,\\n bytes32 mainUtxoTxHash,\\n uint32 mainUtxoTxOutputIndex,\\n uint64 mainUtxoTxOutputValue,\\n bytes memory redeemerOutputScript\\n ) = abi.decode(\\n redemptionData,\\n (address, bytes20, bytes32, uint32, uint64, bytes)\\n );\\n\\n requestRedemption(\\n self,\\n walletPubKeyHash,\\n BitcoinTx.UTXO(\\n mainUtxoTxHash,\\n mainUtxoTxOutputIndex,\\n mainUtxoTxOutputValue\\n ),\\n balanceOwner,\\n redeemer,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param redeemer The Ethereum address of the redeemer who will be able to\\n /// claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their Bitcoin\\n /// balance from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO memory mainUtxo,\\n address balanceOwner,\\n address redeemer,\\n bytes memory redeemerOutputScript,\\n uint64 amount\\n ) internal {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n require(\\n mainUtxoHash != bytes32(0),\\n \\\"No main UTXO for the given wallet\\\"\\n );\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n // Validate if redeemer output script is a correct standard type\\n // (P2PKH, P2WPKH, P2SH or P2WSH). This is done by using\\n // `BTCUtils.extractHashAt` on it. Such a function extracts the payload\\n // properly only from standard outputs so if it succeeds, we have a\\n // guarantee the redeemer output script is proper. The underlying way\\n // of validation is the same as in tBTC v1.\\n bytes memory redeemerOutputScriptPayload = redeemerOutputScript\\n .extractHashAt(0, redeemerOutputScript.length);\\n\\n require(\\n redeemerOutputScriptPayload.length > 0,\\n \\\"Redeemer output script must be a standard type\\\"\\n );\\n // Check if the redeemer output script payload does not point to the\\n // wallet public key hash.\\n require(\\n redeemerOutputScriptPayload.length != 20 ||\\n walletPubKeyHash != redeemerOutputScriptPayload.slice20(0),\\n \\\"Redeemer output script must not point to the wallet PKH\\\"\\n );\\n\\n require(\\n amount >= self.redemptionDustThreshold,\\n \\\"Redemption amount too small\\\"\\n );\\n\\n // The redemption key is built on top of the wallet public key hash\\n // and redeemer output script pair. That means there can be only one\\n // request asking for redemption from the given wallet to the given\\n // BTC script at the same time.\\n uint256 redemptionKey = getRedemptionKey(\\n walletPubKeyHash,\\n redeemerOutputScript\\n );\\n\\n // Check if given redemption key is not used by a pending redemption.\\n // There is no need to check for existence in `timedOutRedemptions`\\n // since the wallet's state is changed to other than Live after\\n // first time out is reported so making new requests is not possible.\\n // slither-disable-next-line incorrect-equality\\n require(\\n self.pendingRedemptions[redemptionKey].requestedAt == 0,\\n \\\"There is a pending redemption request from this wallet to the same address\\\"\\n );\\n\\n // No need to check whether `amount - treasuryFee - txMaxFee > 0`\\n // since the `redemptionDustThreshold` should force that condition\\n // to be always true.\\n uint64 treasuryFee = self.redemptionTreasuryFeeDivisor > 0\\n ? amount / self.redemptionTreasuryFeeDivisor\\n : 0;\\n uint64 txMaxFee = self.redemptionTxMaxFee;\\n\\n // The main wallet UTXO's value doesn't include all pending redemptions.\\n // To determine if the requested redemption can be performed by the\\n // wallet we need to subtract the total value of all pending redemptions\\n // from that wallet's main UTXO value. Given that the treasury fee is\\n // not redeemed from the wallet, we are subtracting it.\\n wallet.pendingRedemptionsValue += amount - treasuryFee;\\n require(\\n mainUtxo.txOutputValue >= wallet.pendingRedemptionsValue,\\n \\\"Insufficient wallet funds\\\"\\n );\\n\\n self.pendingRedemptions[redemptionKey] = RedemptionRequest(\\n redeemer,\\n amount,\\n treasuryFee,\\n txMaxFee,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit RedemptionRequested(\\n walletPubKeyHash,\\n redeemerOutputScript,\\n redeemer,\\n amount,\\n treasuryFee,\\n txMaxFee\\n );\\n\\n self.bank.transferBalanceFrom(balanceOwner, address(this), amount);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC redemption transaction\\n /// and to make the necessary bookkeeping. Redemption is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by burning\\n /// the total redeemed Bitcoin amount from Bridge balance and\\n /// transferring the treasury fee sum to the treasury address.\\n ///\\n /// It is possible to prove the given redemption only one time.\\n /// @param redemptionTx Bitcoin redemption transaction data.\\n /// @param redemptionProof Bitcoin redemption proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @dev Requirements:\\n /// - `redemptionTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `redemptionTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs handling existing pending\\n /// redemption requests or pointing to reported timed out requests.\\n /// There can be also 1 optional output representing the\\n /// change and pointing back to the 20-byte wallet public key hash.\\n /// The change should be always present if the redeemed value sum\\n /// is lower than the total wallet's BTC balance,\\n /// - `redemptionProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input.\\n /// Other remarks:\\n /// - Putting the change output as the first transaction output can\\n /// save some gas because the output processing loop begins each\\n /// iteration by checking whether the given output is the change\\n /// thus uses some gas for making the comparison. Once the change\\n /// is identified, that check is omitted in further iterations.\\n function submitRedemptionProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata redemptionTx,\\n BitcoinTx.Proof calldata redemptionProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external {\\n // Wallet state validation is performed in the `resolveRedeemingWallet`\\n // function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 redemptionTxHash = self.validateProof(\\n redemptionTx,\\n redemptionProof\\n );\\n\\n Wallets.Wallet storage wallet = resolveRedeemingWallet(\\n self,\\n walletPubKeyHash,\\n mainUtxo\\n );\\n\\n // Process the redemption transaction input. Specifically, check if it\\n // refers to the expected wallet's main UTXO.\\n OutboundTx.processWalletOutboundTxInput(\\n self,\\n redemptionTx.inputVector,\\n mainUtxo\\n );\\n\\n // Process redemption transaction outputs to extract some info required\\n // for further processing.\\n RedemptionTxOutputsInfo memory outputsInfo = processRedemptionTxOutputs(\\n self,\\n redemptionTx.outputVector,\\n walletPubKeyHash\\n );\\n\\n require(\\n mainUtxo.txOutputValue - outputsInfo.outputsTotalValue <=\\n self.redemptionTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n if (outputsInfo.changeValue > 0) {\\n // If the change value is grater than zero, it means the change\\n // output exists and can be used as new wallet's main UTXO.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(\\n redemptionTxHash,\\n outputsInfo.changeIndex,\\n outputsInfo.changeValue\\n )\\n );\\n } else {\\n // If the change value is zero, it means the change output doesn't\\n // exists and no funds left on the wallet. Delete the main UTXO\\n // for that wallet to represent that state in a proper way.\\n delete wallet.mainUtxoHash;\\n }\\n\\n wallet.pendingRedemptionsValue -= outputsInfo.totalBurnableValue;\\n\\n emit RedemptionsCompleted(walletPubKeyHash, redemptionTxHash);\\n\\n self.bank.decreaseBalance(outputsInfo.totalBurnableValue);\\n\\n if (outputsInfo.totalTreasuryFee > 0) {\\n self.bank.transferBalance(\\n self.treasury,\\n outputsInfo.totalTreasuryFee\\n );\\n }\\n }\\n\\n function mock__submitRedemptionProof(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n bytes calldata redeemerOutputScript,\\n bytes32 redemptionTxHash\\n ) external {\\n uint256 redemptionKey = getRedemptionKey(\\n walletPubKeyHash,\\n redeemerOutputScript\\n );\\n RedemptionRequest storage request = self.pendingRedemptions[\\n redemptionKey\\n ];\\n\\n uint64 redeemableAmount = request.requestedAmount - request.treasuryFee;\\n delete self.pendingRedemptions[redemptionKey];\\n emit RedemptionsCompleted(walletPubKeyHash, redemptionTxHash);\\n\\n self.bank.decreaseBalance(redeemableAmount);\\n self.bank.transferBalance(self.treasury, request.treasuryFee);\\n }\\n\\n /// @notice Resolves redeeming wallet based on the provided wallet public\\n /// key hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @return wallet Data of the sweeping wallet.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - Main UTXO of the redeeming wallet must exists in the storage,\\n /// - The passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveRedeemingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) internal view returns (Wallets.Wallet storage wallet) {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n // Assert that main UTXO for passed wallet exists in storage.\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n require(mainUtxoHash != bytes32(0), \\\"No main UTXO for given wallet\\\");\\n\\n // Assert that passed main UTXO parameter is the same as in storage and\\n // can be used for further processing.\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n }\\n\\n /// @notice Processes the Bitcoin redemption transaction output vector.\\n /// It extracts each output and tries to identify it as a pending\\n /// redemption request, reported timed out request, or change.\\n /// Reverts if one of the outputs cannot be recognized properly.\\n /// This function also marks each request as processed by removing\\n /// them from `pendingRedemptions` mapping.\\n /// @param redemptionTxOutputVector Bitcoin redemption transaction output\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVout` function\\n /// before it is passed here.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @return info Outcomes of the processing.\\n function processRedemptionTxOutputs(\\n BridgeState.Storage storage self,\\n bytes memory redemptionTxOutputVector,\\n bytes20 walletPubKeyHash\\n ) internal returns (RedemptionTxOutputsInfo memory info) {\\n // Determining the total number of redemption transaction outputs in\\n // the same way as for number of inputs. See `BitcoinTx.outputVector`\\n // docs for more details.\\n (\\n uint256 outputsCompactSizeUintLength,\\n uint256 outputsCount\\n ) = redemptionTxOutputVector.parseVarInt();\\n\\n // To determine the first output starting index, we must jump over\\n // the compactSize uint which prepends the output vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 outputStartingIndex = 1 + outputsCompactSizeUintLength;\\n\\n // Calculate the keccak256 for two possible wallet's P2PKH or P2WPKH\\n // scripts that can be used to lock the change. This is done upfront to\\n // save on gas. Both scripts have a strict format defined by Bitcoin.\\n //\\n // The P2PKH script has the byte format: <0x1976a914> <20-byte PKH> <0x88ac>.\\n // According to https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n // - 0x19: Byte length of the entire script\\n // - 0x76: OP_DUP\\n // - 0xa9: OP_HASH160\\n // - 0x14: Byte length of the public key hash\\n // - 0x88: OP_EQUALVERIFY\\n // - 0xac: OP_CHECKSIG\\n // which matches the P2PKH structure as per:\\n // https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash\\n bytes32 walletP2PKHScriptKeccak = keccak256(\\n abi.encodePacked(BitcoinTx.makeP2PKHScript(walletPubKeyHash))\\n );\\n // The P2WPKH script has the byte format: <0x160014> <20-byte PKH>.\\n // According to https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n // - 0x16: Byte length of the entire script\\n // - 0x00: OP_0\\n // - 0x14: Byte length of the public key hash\\n // which matches the P2WPKH structure as per:\\n // https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH\\n bytes32 walletP2WPKHScriptKeccak = keccak256(\\n abi.encodePacked(BitcoinTx.makeP2WPKHScript(walletPubKeyHash))\\n );\\n\\n return\\n processRedemptionTxOutputs(\\n self,\\n redemptionTxOutputVector,\\n walletPubKeyHash,\\n RedemptionTxOutputsProcessingInfo(\\n outputStartingIndex,\\n outputsCount,\\n walletP2PKHScriptKeccak,\\n walletP2WPKHScriptKeccak\\n )\\n );\\n }\\n\\n /// @notice Processes all outputs from the redemption transaction. Tries to\\n /// identify output as a change output, pending redemption request\\n /// or reported redemption. Reverts if one of the outputs cannot be\\n /// recognized properly. Marks each request as processed by removing\\n /// them from `pendingRedemptions` mapping.\\n /// @param redemptionTxOutputVector Bitcoin redemption transaction output\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVout` function\\n /// before it is passed here.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @param processInfo RedemptionTxOutputsProcessingInfo identifying output\\n /// starting index, the number of outputs and possible wallet change\\n /// P2PKH and P2WPKH scripts.\\n function processRedemptionTxOutputs(\\n BridgeState.Storage storage self,\\n bytes memory redemptionTxOutputVector,\\n bytes20 walletPubKeyHash,\\n RedemptionTxOutputsProcessingInfo memory processInfo\\n ) internal returns (RedemptionTxOutputsInfo memory resultInfo) {\\n // Helper flag indicating whether there was at least one redemption\\n // output present (redemption must be either pending or reported as\\n // timed out).\\n bool redemptionPresent = false;\\n\\n // Outputs processing loop.\\n for (uint256 i = 0; i < processInfo.outputsCount; i++) {\\n uint256 outputLength = redemptionTxOutputVector\\n .determineOutputLengthAt(processInfo.outputStartingIndex);\\n\\n // Extract the value from given output.\\n uint64 outputValue = redemptionTxOutputVector.extractValueAt(\\n processInfo.outputStartingIndex\\n );\\n\\n // The output consists of an 8-byte value and a variable length\\n // script. To hash that script we slice the output starting from\\n // 9th byte until the end.\\n uint256 scriptLength = outputLength - 8;\\n uint256 outputScriptStart = processInfo.outputStartingIndex + 8;\\n\\n bytes32 outputScriptHash;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n // The first argument to assembly keccak256 is the pointer.\\n // We point to `redemptionTxOutputVector` but at the position\\n // indicated by `outputScriptStart`. To load that position, we\\n // need to call `add(outputScriptStart, 32)` because\\n // `outputScriptStart` has 32 bytes.\\n outputScriptHash := keccak256(\\n add(redemptionTxOutputVector, add(outputScriptStart, 32)),\\n scriptLength\\n )\\n }\\n\\n if (\\n resultInfo.changeValue == 0 &&\\n (outputScriptHash == processInfo.walletP2PKHScriptKeccak ||\\n outputScriptHash == processInfo.walletP2WPKHScriptKeccak) &&\\n outputValue > 0\\n ) {\\n // If we entered here, that means the change output with a\\n // proper non-zero value was found.\\n resultInfo.changeIndex = uint32(i);\\n resultInfo.changeValue = outputValue;\\n } else {\\n // If we entered here, that the means the given output is\\n // supposed to represent a redemption.\\n (\\n uint64 burnableValue,\\n uint64 treasuryFee\\n ) = processNonChangeRedemptionTxOutput(\\n self,\\n _getRedemptionKey(walletPubKeyHash, outputScriptHash),\\n outputValue\\n );\\n resultInfo.totalBurnableValue += burnableValue;\\n resultInfo.totalTreasuryFee += treasuryFee;\\n redemptionPresent = true;\\n }\\n\\n resultInfo.outputsTotalValue += outputValue;\\n\\n // Make the `outputStartingIndex` pointing to the next output by\\n // increasing it by current output's length.\\n processInfo.outputStartingIndex += outputLength;\\n }\\n\\n // Protect against the cases when there is only a single change output\\n // referring back to the wallet PKH and just burning main UTXO value\\n // for transaction fees.\\n require(\\n redemptionPresent,\\n \\\"Redemption transaction must process at least one redemption\\\"\\n );\\n }\\n\\n /// @notice Processes a single redemption transaction output. Tries to\\n /// identify output as a pending redemption request or reported\\n /// redemption timeout. Output script passed to this function must\\n /// not be the change output. Such output needs to be identified\\n /// separately before calling this function.\\n /// Reverts if output is neither requested pending redemption nor\\n /// requested and reported timed-out redemption.\\n /// This function also marks each pending request as processed by\\n /// removing them from `pendingRedemptions` mapping.\\n /// @param redemptionKey Redemption key of the output being processed.\\n /// @param outputValue Value of the output being processed.\\n /// @return burnableValue The value burnable as a result of processing this\\n /// single redemption output. This value needs to be summed up with\\n /// burnable values of all other outputs to evaluate total burnable\\n /// value for the entire redemption transaction. This value is 0\\n /// for a timed-out redemption request.\\n /// @return treasuryFee The treasury fee from this single redemption output.\\n /// This value needs to be summed up with treasury fees of all other\\n /// outputs to evaluate the total treasury fee for the entire\\n /// redemption transaction. This value is 0 for a timed-out\\n /// redemption request.\\n /// @dev Requirements:\\n /// - This function should be called only if the given output\\n /// represents redemption. It must not be the change output.\\n function processNonChangeRedemptionTxOutput(\\n BridgeState.Storage storage self,\\n uint256 redemptionKey,\\n uint64 outputValue\\n ) internal returns (uint64 burnableValue, uint64 treasuryFee) {\\n if (self.pendingRedemptions[redemptionKey].requestedAt != 0) {\\n // If we entered here, that means the output was identified\\n // as a pending redemption request.\\n RedemptionRequest storage request = self.pendingRedemptions[\\n redemptionKey\\n ];\\n // Compute the request's redeemable amount as the requested\\n // amount reduced by the treasury fee. The request's\\n // minimal amount is then the redeemable amount reduced by\\n // the maximum transaction fee.\\n uint64 redeemableAmount = request.requestedAmount -\\n request.treasuryFee;\\n // Output value must fit between the request's redeemable\\n // and minimal amounts to be deemed valid.\\n require(\\n redeemableAmount - request.txMaxFee <= outputValue &&\\n outputValue <= redeemableAmount,\\n \\\"Output value is not within the acceptable range of the pending request\\\"\\n );\\n // Add the redeemable amount to the total burnable value\\n // the Bridge will use to decrease its balance in the Bank.\\n burnableValue = redeemableAmount;\\n // Add the request's treasury fee to the total treasury fee\\n // value the Bridge will transfer to the treasury.\\n treasuryFee = request.treasuryFee;\\n // Request was properly handled so remove its redemption\\n // key from the mapping to make it reusable for further\\n // requests.\\n delete self.pendingRedemptions[redemptionKey];\\n } else {\\n // If we entered here, the output is not a redemption\\n // request but there is still a chance the given output is\\n // related to a reported timed out redemption request.\\n // If so, check if the output value matches the request\\n // amount to confirm this is an overdue request fulfillment\\n // then bypass this output and process the subsequent\\n // ones. That also means the wallet was already punished\\n // for the inactivity. Otherwise, just revert.\\n RedemptionRequest storage request = self.timedOutRedemptions[\\n redemptionKey\\n ];\\n\\n require(\\n request.requestedAt != 0,\\n \\\"Output is a non-requested redemption\\\"\\n );\\n\\n uint64 redeemableAmount = request.requestedAmount -\\n request.treasuryFee;\\n\\n require(\\n redeemableAmount - request.txMaxFee <= outputValue &&\\n outputValue <= redeemableAmount,\\n \\\"Output value is not within the acceptable range of the timed out request\\\"\\n );\\n\\n delete self.timedOutRedemptions[redemptionKey];\\n }\\n }\\n\\n /// @notice Notifies that there is a pending redemption request associated\\n /// with the given wallet, that has timed out. The redemption\\n /// request is identified by the key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The results of calling this function:\\n /// - the pending redemptions value for the wallet will be decreased\\n /// by the requested amount (minus treasury fee),\\n /// - the tokens taken from the redeemer on redemption request will\\n /// be returned to the redeemer,\\n /// - the request will be moved from pending redemptions to\\n /// timed-out redemptions,\\n /// - if the state of the wallet is `Live` or `MovingFunds`, the\\n /// wallet operators will be slashed and the notifier will be\\n /// rewarded,\\n /// - if the state of wallet is `Live`, the wallet will be closed or\\n /// marked as `MovingFunds` (depending on the presence or absence\\n /// of the wallet's main UTXO) and the wallet will no longer be\\n /// marked as the active wallet (if it was marked as such).\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH).\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Terminated state,\\n /// - The redemption request identified by `walletPubKeyHash` and\\n /// `redeemerOutputScript` must exist,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time defined by `redemptionTimeout` must have\\n /// passed since the redemption was requested (the request must be\\n /// timed-out).\\n function notifyRedemptionTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n bytes calldata redeemerOutputScript\\n ) external {\\n // Wallet state is validated in `notifyWalletRedemptionTimeout`.\\n uint256 redemptionKey = getRedemptionKey(\\n walletPubKeyHash,\\n redeemerOutputScript\\n );\\n Redemption.RedemptionRequest memory request = self.pendingRedemptions[\\n redemptionKey\\n ];\\n\\n require(request.requestedAt > 0, \\\"Redemption request does not exist\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n request.requestedAt + self.redemptionTimeout < block.timestamp,\\n \\\"Redemption request has not timed out\\\"\\n );\\n\\n // Update the wallet's pending redemptions value\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n wallet.pendingRedemptionsValue -=\\n request.requestedAmount -\\n request.treasuryFee;\\n\\n // It is worth noting that there is no need to check if\\n // `timedOutRedemption` mapping already contains the given redemption\\n // key. There is no possibility to re-use a key of a reported timed-out\\n // redemption because the wallet responsible for causing the timeout is\\n // moved to a state that prevents it to receive new redemption requests.\\n\\n // Propagate timeout consequences to the wallet\\n self.notifyWalletRedemptionTimeout(walletPubKeyHash, walletMembersIDs);\\n\\n // Move the redemption from pending redemptions to timed-out redemptions\\n self.timedOutRedemptions[redemptionKey] = request;\\n delete self.pendingRedemptions[redemptionKey];\\n\\n // slither-disable-next-line reentrancy-events\\n emit RedemptionTimedOut(walletPubKeyHash, redeemerOutputScript);\\n\\n // Return the requested amount of tokens to the redeemer\\n self.bank.transferBalance(request.redeemer, request.requestedAmount);\\n }\\n\\n /// @notice Calculate redemption key without allocations.\\n /// @param walletPubKeyHash the pubkey hash of the wallet.\\n /// @param script the output script of the redemption.\\n /// @return The key = keccak256(keccak256(script) | walletPubKeyHash).\\n function getRedemptionKey(bytes20 walletPubKeyHash, bytes memory script)\\n internal\\n pure\\n returns (uint256)\\n {\\n bytes32 scriptHash = keccak256(script);\\n uint256 key;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n mstore(0, scriptHash)\\n mstore(32, walletPubKeyHash)\\n key := keccak256(0, 52)\\n }\\n return key;\\n }\\n\\n /// @notice Finish calculating redemption key without allocations.\\n /// @param walletPubKeyHash the pubkey hash of the wallet.\\n /// @param scriptHash the output script hash of the redemption.\\n /// @return The key = keccak256(scriptHash | walletPubKeyHash).\\n function _getRedemptionKey(bytes20 walletPubKeyHash, bytes32 scriptHash)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 key;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n mstore(0, scriptHash)\\n mstore(32, walletPubKeyHash)\\n key := keccak256(0, 52)\\n }\\n return key;\\n }\\n}\\n\",\"keccak256\":\"0x54b18f38316cf55d689e55f3bf8c9a4fad7302d9ae6e70cd749458f9edaa45a3\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Wallets.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {EcdsaDkg} from \\\"@keep-network/ecdsa/contracts/libraries/EcdsaDkg.sol\\\";\\nimport {Math} from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\n\\n/// @title Wallet library\\n/// @notice Library responsible for handling integration between Bridge\\n/// contract and ECDSA wallets.\\nlibrary Wallets {\\n using BTCUtils for bytes;\\n\\n /// @notice Represents wallet state:\\n enum WalletState {\\n /// @dev The wallet is unknown to the Bridge.\\n Unknown,\\n /// @dev The wallet can sweep deposits and accept redemption requests.\\n Live,\\n /// @dev The wallet was deemed unhealthy and is expected to move their\\n /// outstanding funds to another wallet. The wallet can still\\n /// fulfill their pending redemption requests although new\\n /// redemption requests and new deposit reveals are not accepted.\\n MovingFunds,\\n /// @dev The wallet moved or redeemed all their funds and is in the\\n /// closing period where it is still a subject of fraud challenges\\n /// and must defend against them. This state is needed to protect\\n /// against deposit frauds on deposits revealed but not swept.\\n /// The closing period must be greater that the deposit refund\\n /// time plus some time margin.\\n Closing,\\n /// @dev The wallet finalized the closing period successfully and\\n /// can no longer perform any action in the Bridge.\\n Closed,\\n /// @dev The wallet committed a fraud that was reported, did not move\\n /// funds to another wallet before a timeout, or did not sweep\\n /// funds moved to if from another wallet before a timeout. The\\n /// wallet is blocked and can not perform any actions in the Bridge.\\n /// Off-chain coordination with the wallet operators is needed to\\n /// recover funds.\\n Terminated\\n }\\n\\n /// @notice Holds information about a wallet.\\n struct Wallet {\\n // Identifier of a ECDSA Wallet registered in the ECDSA Wallet Registry.\\n bytes32 ecdsaWalletID;\\n // Latest wallet's main UTXO hash computed as\\n // keccak256(txHash | txOutputIndex | txOutputValue). The `tx` prefix\\n // refers to the transaction which created that main UTXO. The `txHash`\\n // is `bytes32` (ordered as in Bitcoin internally), `txOutputIndex`\\n // an `uint32`, and `txOutputValue` an `uint64` value.\\n bytes32 mainUtxoHash;\\n // The total redeemable value of pending redemption requests targeting\\n // that wallet.\\n uint64 pendingRedemptionsValue;\\n // UNIX timestamp the wallet was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 createdAt;\\n // UNIX timestamp indicating the moment the wallet was requested to\\n // move their funds.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 movingFundsRequestedAt;\\n // UNIX timestamp indicating the moment the wallet's closing period\\n // started.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 closingStartedAt;\\n // Total count of pending moved funds sweep requests targeting this wallet.\\n uint32 pendingMovedFundsSweepRequestsCount;\\n // Current state of the wallet.\\n WalletState state;\\n // Moving funds target wallet commitment submitted by the wallet. It\\n // is built by applying the keccak256 hash over the list of 20-byte\\n // public key hashes of the target wallets.\\n bytes32 movingFundsTargetWalletsCommitmentHash;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event NewWalletRequested();\\n\\n event NewWalletRegistered(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletMovingFunds(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosing(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosed(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletTerminated(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n /// @notice Requests creation of a new wallet. This function just\\n /// forms a request and the creation process is performed\\n /// asynchronously. Outcome of that process should be delivered\\n /// using `registerNewWallet` function.\\n /// @param activeWalletMainUtxo Data of the active wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `activeWalletMainUtxo` components must point to the recent main\\n /// UTXO of the given active wallet, as currently known on the\\n /// Ethereum chain. If there is no active wallet at the moment, or\\n /// the active wallet has no main UTXO, this parameter can be\\n /// empty as it is ignored,\\n /// - Wallet creation must not be in progress,\\n /// - If the active wallet is set, one of the following\\n /// conditions must be true:\\n /// - The active wallet BTC balance is above the minimum threshold\\n /// and the active wallet is old enough, i.e. the creation period\\n /// was elapsed since its creation time,\\n /// - The active wallet BTC balance is above the maximum threshold.\\n function requestNewWallet(\\n BridgeState.Storage storage self,\\n BitcoinTx.UTXO calldata activeWalletMainUtxo\\n ) external {\\n require(\\n self.ecdsaWalletRegistry.getWalletCreationState() ==\\n EcdsaDkg.State.IDLE,\\n \\\"Wallet creation already in progress\\\"\\n );\\n\\n bytes20 activeWalletPubKeyHash = self.activeWalletPubKeyHash;\\n\\n // If the active wallet is set, fetch this wallet's details from\\n // storage to perform conditions check. The `registerNewWallet`\\n // function guarantees an active wallet is always one of the\\n // registered ones.\\n if (activeWalletPubKeyHash != bytes20(0)) {\\n uint64 activeWalletBtcBalance = getWalletBtcBalance(\\n self,\\n activeWalletPubKeyHash,\\n activeWalletMainUtxo\\n );\\n uint32 activeWalletCreatedAt = self\\n .registeredWallets[activeWalletPubKeyHash]\\n .createdAt;\\n /* solhint-disable-next-line not-rely-on-time */\\n bool activeWalletOldEnough = block.timestamp >=\\n activeWalletCreatedAt + self.walletCreationPeriod;\\n\\n require(\\n (activeWalletOldEnough &&\\n activeWalletBtcBalance >=\\n self.walletCreationMinBtcBalance) ||\\n activeWalletBtcBalance >= self.walletCreationMaxBtcBalance,\\n \\\"Wallet creation conditions are not met\\\"\\n );\\n }\\n\\n emit NewWalletRequested();\\n\\n self.ecdsaWalletRegistry.requestNewWallet();\\n }\\n\\n /// @notice Registers a new wallet. This function should be called\\n /// after the wallet creation process initiated using\\n /// `requestNewWallet` completes and brings the outcomes.\\n /// @param ecdsaWalletID Wallet's unique identifier.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Given wallet data must not belong to an already registered wallet.\\n function registerNewWallet(\\n BridgeState.Storage storage self,\\n bytes32 ecdsaWalletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external {\\n require(\\n msg.sender == address(self.ecdsaWalletRegistry),\\n \\\"Caller is not the ECDSA Wallet Registry\\\"\\n );\\n\\n // Compress wallet's public key and calculate Bitcoin's hash160 of it.\\n bytes20 walletPubKeyHash = bytes20(\\n EcdsaLib.compressPublicKey(publicKeyX, publicKeyY).hash160View()\\n );\\n\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n require(\\n wallet.state == WalletState.Unknown,\\n \\\"ECDSA wallet has been already registered\\\"\\n );\\n wallet.ecdsaWalletID = ecdsaWalletID;\\n wallet.state = WalletState.Live;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.createdAt = uint32(block.timestamp);\\n\\n // Set the freshly created wallet as the new active wallet.\\n self.activeWalletPubKeyHash = walletPubKeyHash;\\n\\n self.liveWalletsCount++;\\n\\n emit NewWalletRegistered(ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n function mock__registerEcdsaWallet(\\n BridgeState.Storage storage self,\\n bytes32 ecdsaWalletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) external {\\n bytes20 walletPubKeyHash = bytes20(\\n EcdsaLib.compressPublicKey(publicKeyX, publicKeyY).hash160View()\\n );\\n\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n require(\\n wallet.state == WalletState.Unknown,\\n \\\"ECDSA wallet has been already registered\\\"\\n );\\n wallet.ecdsaWalletID = ecdsaWalletID;\\n wallet.state = WalletState.Live;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.createdAt = uint32(block.timestamp);\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(\\n walletMainUtxo.txHash,\\n walletMainUtxo.txOutputIndex,\\n walletMainUtxo.txOutputValue\\n )\\n );\\n\\n // Set the freshly created wallet as the new active wallet.\\n self.activeWalletPubKeyHash = walletPubKeyHash;\\n\\n self.liveWalletsCount++;\\n\\n emit NewWalletRegistered(ecdsaWalletID, 0x0);\\n }\\n\\n /// @notice Handles a notification about a wallet redemption timeout.\\n /// Triggers the wallet moving funds process only if the wallet is\\n /// still in the Live state. That means multiple action timeouts can\\n /// be reported for the same wallet but only the first report\\n /// requests the wallet to move their funds. Executes slashing if\\n /// the wallet is in Live or MovingFunds state. Allows to notify\\n /// redemption timeout also for a Terminated wallet in case the\\n /// redemption was requested before the wallet got terminated.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`,\\n /// or `Terminated` state.\\n function notifyWalletRedemptionTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n require(\\n walletState == WalletState.Live ||\\n walletState == WalletState.MovingFunds ||\\n walletState == WalletState.Terminated,\\n \\\"Wallet must be in Live or MovingFunds or Terminated state\\\"\\n );\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds\\n ) {\\n // Slash the wallet operators and reward the notifier\\n self.ecdsaWalletRegistry.seize(\\n self.redemptionTimeoutSlashingAmount,\\n self.redemptionTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n }\\n\\n if (walletState == WalletState.Live) {\\n moveFunds(self, walletPubKeyHash);\\n }\\n }\\n\\n /// @notice Handles a notification about a wallet heartbeat failure and\\n /// triggers the wallet moving funds process.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Wallet must be in Live state.\\n function notifyWalletHeartbeatFailed(\\n BridgeState.Storage storage self,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external {\\n require(\\n msg.sender == address(self.ecdsaWalletRegistry),\\n \\\"Caller is not the ECDSA Wallet Registry\\\"\\n );\\n\\n // Compress wallet's public key and calculate Bitcoin's hash160 of it.\\n bytes20 walletPubKeyHash = bytes20(\\n EcdsaLib.compressPublicKey(publicKeyX, publicKeyY).hash160View()\\n );\\n\\n require(\\n self.registeredWallets[walletPubKeyHash].state == WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n moveFunds(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies that the wallet is either old enough or has too few\\n /// satoshis left and qualifies to be closed.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - Wallet must not be set as the current active wallet,\\n /// - Wallet must exceed the wallet maximum age OR the wallet BTC\\n /// balance must be lesser than the minimum threshold. If the latter\\n /// case is true, the `walletMainUtxo` components must point to the\\n /// recent main UTXO of the given wallet, as currently known on the\\n /// Ethereum chain. If the wallet has no main UTXO, this parameter\\n /// can be empty as it is ignored since the wallet balance is\\n /// assumed to be zero,\\n /// - Wallet must be in Live state.\\n function notifyWalletCloseable(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) external {\\n require(\\n self.activeWalletPubKeyHash != walletPubKeyHash,\\n \\\"Active wallet cannot be considered closeable\\\"\\n );\\n\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n require(\\n wallet.state == WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n bool walletOldEnough = block.timestamp >=\\n wallet.createdAt + self.walletMaxAge;\\n\\n require(\\n walletOldEnough ||\\n getWalletBtcBalance(self, walletPubKeyHash, walletMainUtxo) <\\n self.walletClosureMinBtcBalance,\\n \\\"Wallet needs to be old enough or have too few satoshis\\\"\\n );\\n\\n moveFunds(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies about the end of the closing period for the given wallet.\\n /// Closes the wallet ultimately and notifies the ECDSA registry\\n /// about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the Closing state,\\n /// - The wallet closing period must have elapsed.\\n function notifyWalletClosingPeriodElapsed(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n require(\\n wallet.state == WalletState.Closing,\\n \\\"Wallet must be in Closing state\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n wallet.closingStartedAt + self.walletClosingPeriod,\\n \\\"Closing period has not elapsed yet\\\"\\n );\\n\\n finalizeWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies that the wallet completed the moving funds process\\n /// successfully. Checks if the funds were moved to the expected\\n /// target wallets. Closes the source wallet if everything went\\n /// good and reverts otherwise.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param targetWalletsHash 32-byte keccak256 hash over the list of\\n /// 20-byte public key hashes of the target wallets actually used\\n /// within the moving funds transactions.\\n /// @dev Requirements:\\n /// - The caller must make sure the moving funds transaction actually\\n /// happened on Bitcoin chain and fits the protocol requirements,\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must be submitted by the source\\n /// wallet,\\n /// - The actual target wallets used in the moving funds transaction\\n /// must be exactly the same as the target wallets commitment.\\n function notifyWalletFundsMoved(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n bytes32 targetWalletsHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n // Check that the wallet is in the MovingFunds state but don't check\\n // if the moving funds timeout is exceeded. That should give a\\n // possibility to move funds in case when timeout was hit but was\\n // not reported yet.\\n require(\\n wallet.state == WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n bytes32 targetWalletsCommitmentHash = wallet\\n .movingFundsTargetWalletsCommitmentHash;\\n\\n require(\\n targetWalletsCommitmentHash != bytes32(0),\\n \\\"Target wallets commitment not submitted yet\\\"\\n );\\n\\n // Make sure that the target wallets where funds were moved to are\\n // exactly the same as the ones the source wallet committed to.\\n require(\\n targetWalletsCommitmentHash == targetWalletsHash,\\n \\\"Target wallets don't correspond to the commitment\\\"\\n );\\n\\n // If funds were moved, the wallet has no longer a main UTXO.\\n delete wallet.mainUtxoHash;\\n\\n beginWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when a MovingFunds wallet has a balance below the dust\\n /// threshold. Begins the wallet closing.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state.\\n function notifyWalletMovingFundsBelowDust(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n WalletState walletState = self\\n .registeredWallets[walletPubKeyHash]\\n .state;\\n\\n require(\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n beginWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when the timeout for MovingFunds for the wallet elapsed.\\n /// Slashes wallet members and terminates the wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state.\\n function notifyWalletMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n self.ecdsaWalletRegistry.seize(\\n self.movingFundsTimeoutSlashingAmount,\\n self.movingFundsTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when a wallet which was asked to sweep funds moved from\\n /// another wallet did not provide a sweeping proof before a timeout.\\n /// Slashes and terminates the wallet who failed to provide a proof.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet which was\\n /// supposed to sweep funds.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`,\\n /// or `Terminated` state.\\n function notifyWalletMovedFundsSweepTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n require(\\n walletState == WalletState.Live ||\\n walletState == WalletState.MovingFunds ||\\n walletState == WalletState.Terminated,\\n \\\"Wallet must be in Live or MovingFunds or Terminated state\\\"\\n );\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds\\n ) {\\n self.ecdsaWalletRegistry.seize(\\n self.movedFundsSweepTimeoutSlashingAmount,\\n self.movedFundsSweepTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n }\\n }\\n\\n /// @notice Called when a wallet which was challenged for a fraud did not\\n /// defeat the challenge before the timeout. Slashes and terminates\\n /// the wallet who failed to defeat the challenge. If the wallet is\\n /// already terminated, it does nothing.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet which was\\n /// supposed to sweep funds.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param challenger Address of the party which submitted the fraud\\n /// challenge.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`, `Closing`\\n /// or `Terminated` state.\\n function notifyWalletFraudChallengeDefeatTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n address challenger\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds ||\\n walletState == Wallets.WalletState.Closing\\n ) {\\n self.ecdsaWalletRegistry.seize(\\n self.fraudSlashingAmount,\\n self.fraudNotifierRewardMultiplier,\\n challenger,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n } else if (walletState == Wallets.WalletState.Terminated) {\\n // This is a special case when the wallet was already terminated\\n // due to a previous deliberate protocol violation. In that\\n // case, this function should be still callable for other fraud\\n // challenges timeouts in order to let the challenger unlock its\\n // ETH deposit back. However, the wallet termination logic is\\n // not called and the challenger is not rewarded.\\n } else {\\n revert(\\n \\\"Wallet must be in Live or MovingFunds or Closing or Terminated state\\\"\\n );\\n }\\n }\\n\\n /// @notice Requests a wallet to move their funds. If the wallet balance\\n /// is zero, the wallet closing begins immediately. If the move\\n /// funds request refers to the current active wallet, such a wallet\\n /// is no longer considered active and the active wallet slot\\n /// is unset allowing to trigger a new wallet creation immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the Live state.\\n function moveFunds(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n if (wallet.mainUtxoHash == bytes32(0)) {\\n // If the wallet has no main UTXO, that means its BTC balance\\n // is zero and the wallet closing should begin immediately.\\n beginWalletClosing(self, walletPubKeyHash);\\n } else {\\n // Otherwise, initialize the moving funds process.\\n wallet.state = WalletState.MovingFunds;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.movingFundsRequestedAt = uint32(block.timestamp);\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletMovingFunds(wallet.ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n if (self.activeWalletPubKeyHash == walletPubKeyHash) {\\n // If the move funds request refers to the current active wallet,\\n // unset the active wallet and make the wallet creation process\\n // possible in order to get a new healthy active wallet.\\n delete self.activeWalletPubKeyHash;\\n }\\n\\n self.liveWalletsCount--;\\n }\\n\\n /// @notice Begins the closing period of the given wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the\\n /// MovingFunds state.\\n function beginWalletClosing(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n // Initialize the closing period.\\n wallet.state = WalletState.Closing;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.closingStartedAt = uint32(block.timestamp);\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletClosing(wallet.ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n /// @notice Finalizes the closing period of the given wallet and notifies\\n /// the ECDSA registry about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the Closing state.\\n function finalizeWalletClosing(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n wallet.state = WalletState.Closed;\\n\\n emit WalletClosed(wallet.ecdsaWalletID, walletPubKeyHash);\\n\\n self.ecdsaWalletRegistry.closeWallet(wallet.ecdsaWalletID);\\n }\\n\\n /// @notice Terminates the given wallet and notifies the ECDSA registry\\n /// about this fact. If the wallet termination refers to the current\\n /// active wallet, such a wallet is no longer considered active and\\n /// the active wallet slot is unset allowing to trigger a new wallet\\n /// creation immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the\\n /// Live or MovingFunds or Closing state.\\n function terminateWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n if (wallet.state == WalletState.Live) {\\n self.liveWalletsCount--;\\n }\\n\\n wallet.state = WalletState.Terminated;\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletTerminated(wallet.ecdsaWalletID, walletPubKeyHash);\\n\\n if (self.activeWalletPubKeyHash == walletPubKeyHash) {\\n // If termination refers to the current active wallet,\\n // unset the active wallet and make the wallet creation process\\n // possible in order to get a new healthy active wallet.\\n delete self.activeWalletPubKeyHash;\\n }\\n\\n self.ecdsaWalletRegistry.closeWallet(wallet.ecdsaWalletID);\\n }\\n\\n /// @notice Gets BTC balance for given the wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @return walletBtcBalance Current BTC balance for the given wallet.\\n /// @dev Requirements:\\n /// - `walletMainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored.\\n function getWalletBtcBalance(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) internal view returns (uint64 walletBtcBalance) {\\n bytes32 walletMainUtxoHash = self\\n .registeredWallets[walletPubKeyHash]\\n .mainUtxoHash;\\n\\n // If the wallet has a main UTXO hash set, cross-check it with the\\n // provided plain-text parameter and get the transaction output value\\n // as BTC balance. Otherwise, the BTC balance is just zero.\\n if (walletMainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n walletMainUtxo.txHash,\\n walletMainUtxo.txOutputIndex,\\n walletMainUtxo.txOutputValue\\n )\\n ) == walletMainUtxoHash,\\n \\\"Invalid wallet main UTXO data\\\"\\n );\\n\\n walletBtcBalance = walletMainUtxo.txOutputValue;\\n }\\n\\n return walletBtcBalance;\\n }\\n}\\n\",\"keccak256\":\"0x94803673c1779077a611a1fac606ff329abffac5bedda771d5060dedaa016464\",\"license\":\"GPL-3.0-only\"},\"contracts/token/TBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\\\";\\n\\ncontract TBTC is ERC20WithPermit, MisfundRecovery {\\n constructor() ERC20WithPermit(\\\"tBTC v2\\\", \\\"tBTC\\\") {}\\n}\\n\",\"keccak256\":\"0x4542aaa48f7682005b815253768b6433c811daff5d2727db256d5f1879f5ccbf\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/IVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport \\\"../bank/IReceiveBalanceApproval.sol\\\";\\n\\n/// @title Bank Vault interface\\n/// @notice `IVault` is an interface for a smart contract consuming Bank\\n/// balances of other contracts or externally owned accounts (EOA).\\ninterface IVault is IReceiveBalanceApproval {\\n /// @notice Called by the Bank in `increaseBalanceAndCall` function after\\n /// increasing the balance in the Bank for the vault. It happens in\\n /// the same transaction in which deposits were swept by the Bridge.\\n /// This allows the depositor to route their deposit revealed to the\\n /// Bridge to the particular smart contract (vault) in the same\\n /// transaction in which the deposit is revealed. This way, the\\n /// depositor does not have to execute additional transaction after\\n /// the deposit gets swept by the Bridge to approve and transfer\\n /// their balance to the vault.\\n /// @param depositors Addresses of depositors whose deposits have been swept.\\n /// @param depositedAmounts Amounts deposited by individual depositors and\\n /// swept.\\n /// @dev The implementation must ensure this function can only be called\\n /// by the Bank. The Bank guarantees that the vault's balance was\\n /// increased by the sum of all deposited amounts before this function\\n /// is called, in the same transaction.\\n function receiveBalanceIncrease(\\n address[] calldata depositors,\\n uint256[] calldata depositedAmounts\\n ) external;\\n}\\n\",\"keccak256\":\"0x12866d625abab349324ee28c6f6ec0114eaa7069ea0c5f7c7b23f6a0f833ae60\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/TBTCOptimisticMinting.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport \\\"../bridge/Bridge.sol\\\";\\nimport \\\"../bridge/Deposit.sol\\\";\\nimport \\\"../GovernanceUtils.sol\\\";\\n\\n/// @title TBTC Optimistic Minting\\n/// @notice The Optimistic Minting mechanism allows to mint TBTC before\\n/// `TBTCVault` receives the Bank balance. There are two permissioned\\n/// sets in the system: Minters and Guardians, both set up in 1-of-n\\n/// mode. Minters observe the revealed deposits and request minting TBTC.\\n/// Any single Minter can perform this action. There is an\\n/// `optimisticMintingDelay` between the time of the request from\\n/// a Minter to the time TBTC is minted. During the time of the delay,\\n/// any Guardian can cancel the minting.\\n/// @dev This functionality is a part of `TBTCVault`. It is implemented in\\n/// a separate abstract contract to achieve better separation of concerns\\n/// and easier-to-follow code.\\nabstract contract TBTCOptimisticMinting is Ownable {\\n // Represents optimistic minting request for the given deposit revealed\\n // to the Bridge.\\n struct OptimisticMintingRequest {\\n // UNIX timestamp at which the optimistic minting was requested.\\n uint64 requestedAt;\\n // UNIX timestamp at which the optimistic minting was finalized.\\n // 0 if not yet finalized.\\n uint64 finalizedAt;\\n }\\n\\n /// @notice The time delay that needs to pass between initializing and\\n /// finalizing the upgrade of governable parameters.\\n uint256 public constant GOVERNANCE_DELAY = 120;\\n\\n /// @notice Multiplier to convert satoshi to TBTC token units.\\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\\n\\n Bridge public immutable bridge;\\n\\n /// @notice Indicates if the optimistic minting has been paused. Only the\\n /// Governance can pause optimistic minting. Note that the pause of\\n /// the optimistic minting does not stop the standard minting flow\\n /// where wallets sweep deposits.\\n bool public isOptimisticMintingPaused;\\n\\n /// @notice Divisor used to compute the treasury fee taken from each\\n /// optimistically minted deposit and transferred to the treasury\\n /// upon finalization of the optimistic mint. This fee is computed\\n /// as follows: `fee = amount / optimisticMintingFeeDivisor`.\\n /// For example, if the fee needs to be 2%, the\\n /// `optimisticMintingFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n /// The optimistic minting fee does not replace the deposit treasury\\n /// fee cut by the Bridge. The optimistic fee is a percentage AFTER\\n /// the treasury fee is cut:\\n /// `optimisticMintingFee = (depositAmount - treasuryFee) / optimisticMintingFeeDivisor`\\n uint32 public optimisticMintingFeeDivisor = 500; // 1/500 = 0.002 = 0.2%\\n\\n /// @notice The time that needs to pass between the moment the optimistic\\n /// minting is requested and the moment optimistic minting is\\n /// finalized with minting TBTC.\\n uint32 public optimisticMintingDelay = 120;\\n\\n /// @notice Indicates if the given address is a Minter. Only Minters can\\n /// request optimistic minting.\\n mapping(address => bool) public isMinter;\\n\\n /// @notice List of all Minters.\\n /// @dev May be used to establish an order in which the Minters should\\n /// request for an optimistic minting.\\n address[] public minters;\\n\\n /// @notice Indicates if the given address is a Guardian. Only Guardians can\\n /// cancel requested optimistic minting.\\n mapping(address => bool) public isGuardian;\\n\\n /// @notice Collection of all revealed deposits for which the optimistic\\n /// minting was requested. Indexed by a deposit key computed as\\n /// `keccak256(fundingTxHash | fundingOutputIndex)`.\\n mapping(uint256 => OptimisticMintingRequest)\\n public optimisticMintingRequests;\\n\\n /// @notice Optimistic minting debt value per depositor's address. The debt\\n /// represents the total value of all depositor's deposits revealed\\n /// to the Bridge that has not been yet swept and led to the\\n /// optimistic minting of TBTC. When `TBTCVault` sweeps a deposit,\\n /// the debt is fully or partially paid off, no matter if that\\n /// particular swept deposit was used for the optimistic minting or\\n /// not. The values are in 1e18 Ethereum precision.\\n mapping(address => uint256) public optimisticMintingDebt;\\n\\n /// @notice New optimistic minting fee divisor value. Set only when the\\n /// parameter update process is pending. Once the update gets\\n // finalized, this will be the value of the divisor.\\n uint32 public newOptimisticMintingFeeDivisor;\\n /// @notice The timestamp at which the update of the optimistic minting fee\\n /// divisor started. Zero if update is not in progress.\\n uint256 public optimisticMintingFeeUpdateInitiatedTimestamp;\\n\\n /// @notice New optimistic minting delay value. Set only when the parameter\\n /// update process is pending. Once the update gets finalized, this\\n // will be the value of the delay.\\n uint32 public newOptimisticMintingDelay;\\n /// @notice The timestamp at which the update of the optimistic minting\\n /// delay started. Zero if update is not in progress.\\n uint256 public optimisticMintingDelayUpdateInitiatedTimestamp;\\n\\n event OptimisticMintingRequested(\\n address indexed minter,\\n uint256 indexed depositKey,\\n address indexed depositor,\\n uint256 amount, // amount in 1e18 Ethereum precision\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n );\\n event OptimisticMintingFinalized(\\n address indexed minter,\\n uint256 indexed depositKey,\\n address indexed depositor,\\n uint256 optimisticMintingDebt\\n );\\n event OptimisticMintingCancelled(\\n address indexed guardian,\\n uint256 indexed depositKey\\n );\\n event OptimisticMintingDebtRepaid(\\n address indexed depositor,\\n uint256 optimisticMintingDebt\\n );\\n event MinterAdded(address indexed minter);\\n event MinterRemoved(address indexed minter);\\n event GuardianAdded(address indexed guardian);\\n event GuardianRemoved(address indexed guardian);\\n event OptimisticMintingPaused();\\n event OptimisticMintingUnpaused();\\n\\n event OptimisticMintingFeeUpdateStarted(\\n uint32 newOptimisticMintingFeeDivisor\\n );\\n event OptimisticMintingFeeUpdated(uint32 newOptimisticMintingFeeDivisor);\\n\\n event OptimisticMintingDelayUpdateStarted(uint32 newOptimisticMintingDelay);\\n event OptimisticMintingDelayUpdated(uint32 newOptimisticMintingDelay);\\n\\n modifier onlyMinter() {\\n require(isMinter[msg.sender], \\\"Caller is not a minter\\\");\\n _;\\n }\\n\\n modifier onlyGuardian() {\\n require(isGuardian[msg.sender], \\\"Caller is not a guardian\\\");\\n _;\\n }\\n\\n modifier onlyOwnerOrGuardian() {\\n require(\\n owner() == msg.sender || isGuardian[msg.sender],\\n \\\"Caller is not the owner or guardian\\\"\\n );\\n _;\\n }\\n\\n modifier whenOptimisticMintingNotPaused() {\\n require(!isOptimisticMintingPaused, \\\"Optimistic minting paused\\\");\\n _;\\n }\\n\\n modifier onlyAfterGovernanceDelay(uint256 updateInitiatedTimestamp) {\\n GovernanceUtils.onlyAfterGovernanceDelay(\\n updateInitiatedTimestamp,\\n GOVERNANCE_DELAY\\n );\\n _;\\n }\\n\\n constructor(Bridge _bridge) {\\n require(\\n address(_bridge) != address(0),\\n \\\"Bridge can not be the zero address\\\"\\n );\\n\\n bridge = _bridge;\\n }\\n\\n /// @dev Mints the given amount of TBTC to the given depositor's address.\\n /// Implemented by TBTCVault.\\n function _mint(address minter, uint256 amount) internal virtual;\\n\\n /// @notice Allows to fetch a list of all Minters.\\n function getMinters() external view returns (address[] memory) {\\n return minters;\\n }\\n\\n /// @notice Allows a Minter to request for an optimistic minting of TBTC.\\n /// The following conditions must be met:\\n /// - There is no optimistic minting request for the deposit,\\n /// finalized or not.\\n /// - The deposit with the given Bitcoin funding transaction hash\\n /// and output index has been revealed to the Bridge.\\n /// - The deposit has not been swept yet.\\n /// - The deposit is targeted into the TBTCVault.\\n /// - The optimistic minting is not paused.\\n /// After calling this function, the Minter has to wait for\\n /// `optimisticMintingDelay` before finalizing the mint with a call\\n /// to finalizeOptimisticMint.\\n /// @dev The deposit done on the Bitcoin side must be revealed early enough\\n /// to the Bridge on Ethereum to pass the Bridge's validation. The\\n /// validation passes successfully only if the deposit reveal is done\\n /// respectively earlier than the moment when the deposit refund\\n /// locktime is reached, i.e. the deposit becomes refundable. It may\\n /// happen that the wallet does not sweep a revealed deposit and one of\\n /// the Minters requests an optimistic mint for that deposit just\\n /// before the locktime is reached. Guardians must cancel optimistic\\n /// minting for this deposit because the wallet will not be able to\\n /// sweep it. The on-chain optimistic minting code does not perform any\\n /// validation for gas efficiency: it would have to perform the same\\n /// validation as `validateDepositRefundLocktime` and expect the entire\\n /// `DepositRevealInfo` to be passed to assemble the expected script\\n /// hash on-chain. Guardians must validate if the deposit happened on\\n /// Bitcoin, that the script hash has the expected format, and that the\\n /// wallet is an active one so they can also validate the time left for\\n /// the refund.\\n function requestOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyMinter whenOptimisticMintingNotPaused {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt == 0,\\n \\\"Optimistic minting already requested for the deposit\\\"\\n );\\n\\n Deposit.DepositRequest memory deposit = bridge.deposits(depositKey);\\n\\n require(deposit.revealedAt != 0, \\\"The deposit has not been revealed\\\");\\n require(deposit.sweptAt == 0, \\\"The deposit is already swept\\\");\\n require(deposit.vault == address(this), \\\"Unexpected vault address\\\");\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n request.requestedAt = uint64(block.timestamp);\\n\\n emit OptimisticMintingRequested(\\n msg.sender,\\n depositKey,\\n deposit.depositor,\\n deposit.amount * SATOSHI_MULTIPLIER,\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n }\\n\\n /// @notice Allows a Minter to finalize previously requested optimistic\\n /// minting. The following conditions must be met:\\n /// - The optimistic minting has been requested for the given\\n /// deposit.\\n /// - The deposit has not been swept yet.\\n /// - At least `optimisticMintingDelay` passed since the optimistic\\n /// minting was requested for the given deposit.\\n /// - The optimistic minting has not been finalized earlier for the\\n /// given deposit.\\n /// - The optimistic minting request for the given deposit has not\\n /// been canceled by a Guardian.\\n /// - The optimistic minting is not paused.\\n /// This function mints TBTC and increases `optimisticMintingDebt`\\n /// for the given depositor. The optimistic minting request is\\n /// marked as finalized.\\n function finalizeOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyMinter whenOptimisticMintingNotPaused {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt != 0,\\n \\\"Optimistic minting not requested for the deposit\\\"\\n );\\n require(\\n request.finalizedAt == 0,\\n \\\"Optimistic minting already finalized for the deposit\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp > request.requestedAt + optimisticMintingDelay,\\n \\\"Optimistic minting delay has not passed yet\\\"\\n );\\n\\n Deposit.DepositRequest memory deposit = bridge.deposits(depositKey);\\n require(deposit.sweptAt == 0, \\\"The deposit is already swept\\\");\\n\\n // Bridge, when sweeping, cuts a deposit treasury fee and splits\\n // Bitcoin miner fee for the sweep transaction evenly between the\\n // depositors in the sweep.\\n //\\n // When tokens are optimistically minted, we do not know what the\\n // Bitcoin miner fee for the sweep transaction will look like.\\n // The Bitcoin miner fee is ignored. When sweeping, the miner fee is\\n // subtracted so the optimisticMintingDebt may stay non-zero after the\\n // deposit is swept.\\n //\\n // This imbalance is supposed to be solved by a donation to the Bridge.\\n uint256 amountToMint = (deposit.amount - deposit.treasuryFee) *\\n SATOSHI_MULTIPLIER;\\n\\n // The Optimistic Minting mechanism may additionally cut a fee from the\\n // amount that is left after deducting the Bridge deposit treasury fee.\\n // Think of this fee as an extra payment for faster processing of\\n // deposits. One does not need to use the Optimistic Minting mechanism\\n // and they may wait for the Bridge to sweep their deposit if they do\\n // not want to pay the Optimistic Minting fee.\\n uint256 optimisticMintFee = optimisticMintingFeeDivisor > 0\\n ? (amountToMint / optimisticMintingFeeDivisor)\\n : 0;\\n\\n // Both the optimistic minting fee and the share that goes to the\\n // depositor are optimistically minted. All TBTC that is optimistically\\n // minted should be added to the optimistic minting debt. When the\\n // deposit is swept, it is paying off both the depositor's share and the\\n // treasury's share (optimistic minting fee).\\n uint256 newDebt = optimisticMintingDebt[deposit.depositor] +\\n amountToMint;\\n optimisticMintingDebt[deposit.depositor] = newDebt;\\n\\n _mint(deposit.depositor, amountToMint - optimisticMintFee);\\n if (optimisticMintFee > 0) {\\n _mint(bridge.treasury(), optimisticMintFee);\\n }\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n request.finalizedAt = uint64(block.timestamp);\\n\\n emit OptimisticMintingFinalized(\\n msg.sender,\\n depositKey,\\n deposit.depositor,\\n newDebt\\n );\\n }\\n\\n /// @notice Allows a Guardian to cancel optimistic minting request. The\\n /// following conditions must be met:\\n /// - The optimistic minting request for the given deposit exists.\\n /// - The optimistic minting request for the given deposit has not\\n /// been finalized yet.\\n /// Optimistic minting request is removed. It is possible to request\\n /// optimistic minting again for the same deposit later.\\n /// @dev Guardians must validate the following conditions for every deposit\\n /// for which the optimistic minting was requested:\\n /// - The deposit happened on Bitcoin side and it has enough\\n /// confirmations.\\n /// - The optimistic minting has been requested early enough so that\\n /// the wallet has enough time to sweep the deposit.\\n /// - The wallet is an active one and it does perform sweeps or it will\\n /// perform sweeps once the sweeps are activated.\\n function cancelOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyGuardian {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt != 0,\\n \\\"Optimistic minting not requested for the deposit\\\"\\n );\\n require(\\n request.finalizedAt == 0,\\n \\\"Optimistic minting already finalized for the deposit\\\"\\n );\\n\\n // Delete it. It allows to request optimistic minting for the given\\n // deposit again. Useful in case of an errant Guardian.\\n delete optimisticMintingRequests[depositKey];\\n\\n emit OptimisticMintingCancelled(msg.sender, depositKey);\\n }\\n\\n /// @notice Adds the address to the Minter list.\\n function addMinter(address minter) external onlyOwner {\\n require(!isMinter[minter], \\\"This address is already a minter\\\");\\n isMinter[minter] = true;\\n minters.push(minter);\\n emit MinterAdded(minter);\\n }\\n\\n /// @notice Removes the address from the Minter list.\\n function removeMinter(address minter) external onlyOwnerOrGuardian {\\n require(isMinter[minter], \\\"This address is not a minter\\\");\\n delete isMinter[minter];\\n\\n // We do not expect too many Minters so a simple loop is safe.\\n for (uint256 i = 0; i < minters.length; i++) {\\n if (minters[i] == minter) {\\n minters[i] = minters[minters.length - 1];\\n // slither-disable-next-line costly-loop\\n minters.pop();\\n break;\\n }\\n }\\n\\n emit MinterRemoved(minter);\\n }\\n\\n /// @notice Adds the address to the Guardian set.\\n function addGuardian(address guardian) external onlyOwner {\\n require(!isGuardian[guardian], \\\"This address is already a guardian\\\");\\n isGuardian[guardian] = true;\\n emit GuardianAdded(guardian);\\n }\\n\\n /// @notice Removes the address from the Guardian set.\\n function removeGuardian(address guardian) external onlyOwner {\\n require(isGuardian[guardian], \\\"This address is not a guardian\\\");\\n delete isGuardian[guardian];\\n emit GuardianRemoved(guardian);\\n }\\n\\n /// @notice Pauses the optimistic minting. Note that the pause of the\\n /// optimistic minting does not stop the standard minting flow\\n /// where wallets sweep deposits.\\n function pauseOptimisticMinting() external onlyOwner {\\n require(\\n !isOptimisticMintingPaused,\\n \\\"Optimistic minting already paused\\\"\\n );\\n isOptimisticMintingPaused = true;\\n emit OptimisticMintingPaused();\\n }\\n\\n /// @notice Unpauses the optimistic minting.\\n function unpauseOptimisticMinting() external onlyOwner {\\n require(isOptimisticMintingPaused, \\\"Optimistic minting is not paused\\\");\\n isOptimisticMintingPaused = false;\\n emit OptimisticMintingUnpaused();\\n }\\n\\n /// @notice Begins the process of updating optimistic minting fee.\\n /// The fee is computed as follows:\\n /// `fee = amount / optimisticMintingFeeDivisor`.\\n /// For example, if the fee needs to be 2% of each deposit,\\n /// the `optimisticMintingFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n /// @dev See the documentation for optimisticMintingFeeDivisor.\\n function beginOptimisticMintingFeeUpdate(\\n uint32 _newOptimisticMintingFeeDivisor\\n ) external onlyOwner {\\n /* solhint-disable-next-line not-rely-on-time */\\n optimisticMintingFeeUpdateInitiatedTimestamp = block.timestamp;\\n newOptimisticMintingFeeDivisor = _newOptimisticMintingFeeDivisor;\\n emit OptimisticMintingFeeUpdateStarted(_newOptimisticMintingFeeDivisor);\\n }\\n\\n /// @notice Finalizes the update process of the optimistic minting fee.\\n function finalizeOptimisticMintingFeeUpdate()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(optimisticMintingFeeUpdateInitiatedTimestamp)\\n {\\n optimisticMintingFeeDivisor = newOptimisticMintingFeeDivisor;\\n emit OptimisticMintingFeeUpdated(newOptimisticMintingFeeDivisor);\\n\\n newOptimisticMintingFeeDivisor = 0;\\n optimisticMintingFeeUpdateInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Begins the process of updating optimistic minting delay.\\n function beginOptimisticMintingDelayUpdate(\\n uint32 _newOptimisticMintingDelay\\n ) external onlyOwner {\\n /* solhint-disable-next-line not-rely-on-time */\\n optimisticMintingDelayUpdateInitiatedTimestamp = block.timestamp;\\n newOptimisticMintingDelay = _newOptimisticMintingDelay;\\n emit OptimisticMintingDelayUpdateStarted(_newOptimisticMintingDelay);\\n }\\n\\n /// @notice Finalizes the update process of the optimistic minting delay.\\n function finalizeOptimisticMintingDelayUpdate()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(optimisticMintingDelayUpdateInitiatedTimestamp)\\n {\\n optimisticMintingDelay = newOptimisticMintingDelay;\\n emit OptimisticMintingDelayUpdated(newOptimisticMintingDelay);\\n\\n newOptimisticMintingDelay = 0;\\n optimisticMintingDelayUpdateInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Calculates deposit key the same way as the Bridge contract.\\n /// The deposit key is computed as\\n /// `keccak256(fundingTxHash | fundingOutputIndex)`.\\n function calculateDepositKey(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) public pure returns (uint256) {\\n return\\n uint256(\\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\\n );\\n }\\n\\n /// @notice Used by `TBTCVault.receiveBalanceIncrease` to repay the optimistic\\n /// minting debt before TBTC is minted. When optimistic minting is\\n /// finalized, debt equal to the value of the deposit being\\n /// a subject of the optimistic minting is incurred. When `TBTCVault`\\n /// sweeps a deposit, the debt is fully or partially paid off, no\\n /// matter if that particular deposit was used for the optimistic\\n /// minting or not.\\n /// @dev See `TBTCVault.receiveBalanceIncrease`\\n /// @param depositor The depositor whose balance increase is received.\\n /// @param amount The balance increase amount for the depositor received.\\n /// @return The TBTC amount that should be minted after paying off the\\n /// optimistic minting debt.\\n function repayOptimisticMintingDebt(address depositor, uint256 amount)\\n internal\\n returns (uint256)\\n {\\n uint256 debt = optimisticMintingDebt[depositor];\\n if (debt == 0) {\\n return amount;\\n }\\n\\n if (amount > debt) {\\n optimisticMintingDebt[depositor] = 0;\\n emit OptimisticMintingDebtRepaid(depositor, 0);\\n return amount - debt;\\n } else {\\n optimisticMintingDebt[depositor] = debt - amount;\\n emit OptimisticMintingDebtRepaid(depositor, debt - amount);\\n return 0;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfff2b8b8711df8ee71ad048884dc61e5424d4e4108d32e9df38b433237ed7430\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/TBTCVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\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.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IVault.sol\\\";\\nimport \\\"./TBTCOptimisticMinting.sol\\\";\\nimport \\\"../bank/Bank.sol\\\";\\nimport \\\"../token/TBTC.sol\\\";\\n\\n/// @title TBTC application vault\\n/// @notice TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of\\n/// Bitcoin. It facilitates Bitcoin holders to act on the Ethereum\\n/// blockchain and access the decentralized finance (DeFi) ecosystem.\\n/// TBTC Vault mints and unmints TBTC based on Bitcoin balances in the\\n/// Bank.\\n/// @dev TBTC Vault is the owner of TBTC token contract and is the only contract\\n/// minting the token.\\ncontract TBTCVault is IVault, Ownable, TBTCOptimisticMinting {\\n using SafeERC20 for IERC20;\\n\\n Bank public immutable bank;\\n TBTC public immutable tbtcToken;\\n\\n /// @notice The address of a new TBTC vault. Set only when the upgrade\\n /// process is pending. Once the upgrade gets finalized, the new\\n /// TBTC vault will become an owner of TBTC token.\\n address public newVault;\\n /// @notice The timestamp at which an upgrade to a new TBTC vault was\\n /// initiated. Set only when the upgrade process is pending.\\n uint256 public upgradeInitiatedTimestamp;\\n\\n event Minted(address indexed to, uint256 amount);\\n event Unminted(address indexed from, uint256 amount);\\n\\n event UpgradeInitiated(address newVault, uint256 timestamp);\\n event UpgradeFinalized(address newVault);\\n\\n modifier onlyBank() {\\n require(msg.sender == address(bank), \\\"Caller is not the Bank\\\");\\n _;\\n }\\n\\n constructor(\\n Bank _bank,\\n TBTC _tbtcToken,\\n Bridge _bridge\\n ) TBTCOptimisticMinting(_bridge) {\\n require(\\n address(_bank) != address(0),\\n \\\"Bank can not be the zero address\\\"\\n );\\n\\n require(\\n address(_tbtcToken) != address(0),\\n \\\"TBTC token can not be the zero address\\\"\\n );\\n\\n bank = _bank;\\n tbtcToken = _tbtcToken;\\n }\\n\\n /// @notice Mints the given `amount` of TBTC to the caller previously\\n /// transferring `amount / SATOSHI_MULTIPLIER` of the Bank balance\\n /// from caller to TBTC Vault. If `amount` is not divisible by\\n /// SATOSHI_MULTIPLIER, the remainder is left on the caller's\\n /// Bank balance.\\n /// @dev TBTC Vault must have an allowance for caller's balance in the\\n /// Bank for at least `amount / SATOSHI_MULTIPLIER`.\\n /// @param amount Amount of TBTC to mint.\\n function mint(uint256 amount) external {\\n (uint256 convertibleAmount, , uint256 satoshis) = amountToSatoshis(\\n amount\\n );\\n\\n require(\\n bank.balanceOf(msg.sender) >= satoshis,\\n \\\"Amount exceeds balance in the bank\\\"\\n );\\n _mint(msg.sender, convertibleAmount);\\n bank.transferBalanceFrom(msg.sender, address(this), satoshis);\\n }\\n\\n /// @notice Transfers `satoshis` of the Bank balance from the caller\\n /// to TBTC Vault and mints `satoshis * SATOSHI_MULTIPLIER` of TBTC\\n /// to the caller.\\n /// @dev Can only be called by the Bank via `approveBalanceAndCall`.\\n /// @param owner The owner who approved their Bank balance.\\n /// @param satoshis Amount of satoshis used to mint TBTC.\\n function receiveBalanceApproval(\\n address owner,\\n uint256 satoshis,\\n bytes calldata\\n ) external override onlyBank {\\n require(\\n bank.balanceOf(owner) >= satoshis,\\n \\\"Amount exceeds balance in the bank\\\"\\n );\\n _mint(owner, satoshis * SATOSHI_MULTIPLIER);\\n bank.transferBalanceFrom(owner, address(this), satoshis);\\n }\\n\\n /// @notice Mints the same amount of TBTC as the deposited satoshis amount\\n /// multiplied by SATOSHI_MULTIPLIER for each depositor in the array.\\n /// Can only be called by the Bank after the Bridge swept deposits\\n /// and Bank increased balance for the vault.\\n /// @dev Fails if `depositors` array is empty. Expects the length of\\n /// `depositors` and `depositedSatoshiAmounts` is the same.\\n function receiveBalanceIncrease(\\n address[] calldata depositors,\\n uint256[] calldata depositedSatoshiAmounts\\n ) external override onlyBank {\\n require(depositors.length != 0, \\\"No depositors specified\\\");\\n for (uint256 i = 0; i < depositors.length; i++) {\\n address depositor = depositors[i];\\n uint256 satoshis = depositedSatoshiAmounts[i];\\n _mint(\\n depositor,\\n repayOptimisticMintingDebt(\\n depositor,\\n satoshis * SATOSHI_MULTIPLIER\\n )\\n );\\n }\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance and transfers\\n /// `amount / SATOSHI_MULTIPLIER` back to the caller's balance in\\n /// the Bank. If `amount` is not divisible by SATOSHI_MULTIPLIER,\\n /// the remainder is left on the caller's account.\\n /// @dev Caller must have at least `amount` of TBTC approved to\\n /// TBTC Vault.\\n /// @param amount Amount of TBTC to unmint.\\n function unmint(uint256 amount) external {\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n\\n _unmint(msg.sender, convertibleAmount);\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance and transfers\\n /// `amount / SATOSHI_MULTIPLIER` of Bank balance to the Bridge\\n /// requesting redemption based on the provided `redemptionData`.\\n /// If `amount` is not divisible by SATOSHI_MULTIPLIER, the\\n /// remainder is left on the caller's account.\\n /// @dev Caller must have at least `amount` of TBTC approved to\\n /// TBTC Vault.\\n /// @param amount Amount of TBTC to unmint and request to redeem in Bridge.\\n /// @param redemptionData Redemption data in a format expected from\\n /// `redemptionData` parameter of Bridge's `receiveBalanceApproval`\\n /// function.\\n function unmintAndRedeem(uint256 amount, bytes calldata redemptionData)\\n external\\n {\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n\\n _unmintAndRedeem(msg.sender, convertibleAmount, redemptionData);\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance. If `extraData`\\n /// is empty, transfers `amount` back to the caller's balance in the\\n /// Bank. If `extraData` is not empty, requests redemption in the\\n /// Bridge using the `extraData` as a `redemptionData` parameter to\\n /// Bridge's `receiveBalanceApproval` function.\\n /// If `amount` is not divisible by SATOSHI_MULTIPLIER, the\\n /// remainder is left on the caller's account. Note that it may\\n /// left a token approval equal to the remainder.\\n /// @dev This function is doing the same as `unmint` or `unmintAndRedeem`\\n /// (depending on `extraData` parameter) but it allows to execute\\n /// unminting without a separate approval transaction. The function can\\n /// be called only via `approveAndCall` of TBTC token.\\n /// @param from TBTC token holder executing unminting.\\n /// @param amount Amount of TBTC to unmint.\\n /// @param token TBTC token address.\\n /// @param extraData Redemption data in a format expected from\\n /// `redemptionData` parameter of Bridge's `receiveBalanceApproval`\\n /// function. If empty, `receiveApproval` is not requesting a\\n /// redemption of Bank balance but is instead performing just TBTC\\n /// unminting to a Bank balance.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external {\\n require(token == address(tbtcToken), \\\"Token is not TBTC\\\");\\n require(msg.sender == token, \\\"Only TBTC caller allowed\\\");\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n if (extraData.length == 0) {\\n _unmint(from, convertibleAmount);\\n } else {\\n _unmintAndRedeem(from, convertibleAmount, extraData);\\n }\\n }\\n\\n /// @notice Initiates vault upgrade process. The upgrade process needs to be\\n /// finalized with a call to `finalizeUpgrade` function after the\\n /// `UPGRADE_GOVERNANCE_DELAY` passes. Only the governance can\\n /// initiate the upgrade.\\n /// @param _newVault The new vault address.\\n function initiateUpgrade(address _newVault) external onlyOwner {\\n require(_newVault != address(0), \\\"New vault address cannot be zero\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n emit UpgradeInitiated(_newVault, block.timestamp);\\n /* solhint-disable-next-line not-rely-on-time */\\n upgradeInitiatedTimestamp = block.timestamp;\\n newVault = _newVault;\\n }\\n\\n /// @notice Allows the governance to finalize vault upgrade process. The\\n /// upgrade process needs to be first initiated with a call to\\n /// `initiateUpgrade` and the `GOVERNANCE_DELAY` needs to pass.\\n /// Once the upgrade is finalized, the new vault becomes the owner\\n /// of the TBTC token and receives the whole Bank balance of this\\n /// vault.\\n function finalizeUpgrade()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(upgradeInitiatedTimestamp)\\n {\\n emit UpgradeFinalized(newVault);\\n // slither-disable-next-line reentrancy-no-eth\\n tbtcToken.transferOwnership(newVault);\\n bank.transferBalance(newVault, bank.balanceOf(address(this)));\\n newVault = address(0);\\n upgradeInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC20\\n /// token sent mistakenly to the TBTC token contract address.\\n /// @param token Address of the recovered ERC20 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param amount Recovered amount.\\n function recoverERC20FromToken(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n tbtcToken.recoverERC20(token, recipient, amount);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC721\\n /// token sent mistakenly to the TBTC token contract address.\\n /// @param token Address of the recovered ERC721 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param tokenId Identifier of the recovered token.\\n /// @param data Additional data.\\n function recoverERC721FromToken(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n tbtcToken.recoverERC721(token, recipient, tokenId, data);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC20\\n /// token sent - mistakenly or not - to the vault address. This\\n /// function should be used to withdraw TBTC v1 tokens transferred\\n /// to TBTCVault as a result of VendingMachine > TBTCVault upgrade.\\n /// @param token Address of the recovered ERC20 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param amount Recovered amount.\\n function recoverERC20(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n token.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC721\\n /// token sent mistakenly to the vault address.\\n /// @param token Address of the recovered ERC721 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param tokenId Identifier of the recovered token.\\n /// @param data Additional data.\\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 /// @notice Returns the amount of TBTC to be minted/unminted, the remainder,\\n /// and the Bank balance to be transferred for the given mint/unmint.\\n /// Note that if the `amount` is not divisible by SATOSHI_MULTIPLIER,\\n /// the remainder is left on the caller's account when minting or\\n /// unminting.\\n /// @return convertibleAmount Amount of TBTC to be minted/unminted.\\n /// @return remainder Not convertible remainder if amount is not divisible\\n /// by SATOSHI_MULTIPLIER.\\n /// @return satoshis Amount in satoshis - the Bank balance to be transferred\\n /// for the given mint/unmint\\n function amountToSatoshis(uint256 amount)\\n public\\n view\\n returns (\\n uint256 convertibleAmount,\\n uint256 remainder,\\n uint256 satoshis\\n )\\n {\\n remainder = amount % SATOSHI_MULTIPLIER;\\n convertibleAmount = amount - remainder;\\n satoshis = convertibleAmount / SATOSHI_MULTIPLIER;\\n }\\n\\n // slither-disable-next-line calls-loop\\n function _mint(address minter, uint256 amount) internal override {\\n emit Minted(minter, amount);\\n tbtcToken.mint(minter, amount);\\n }\\n\\n /// @dev `amount` MUST be divisible by SATOSHI_MULTIPLIER with no change.\\n function _unmint(address unminter, uint256 amount) internal {\\n emit Unminted(unminter, amount);\\n tbtcToken.burnFrom(unminter, amount);\\n bank.transferBalance(unminter, amount / SATOSHI_MULTIPLIER);\\n }\\n\\n /// @dev `amount` MUST be divisible by SATOSHI_MULTIPLIER with no change.\\n function _unmintAndRedeem(\\n address redeemer,\\n uint256 amount,\\n bytes calldata redemptionData\\n ) internal {\\n emit Unminted(redeemer, amount);\\n tbtcToken.burnFrom(redeemer, amount);\\n bank.approveBalanceAndCall(\\n address(bridge),\\n amount / SATOSHI_MULTIPLIER,\\n redemptionData\\n );\\n }\\n}\\n\",\"keccak256\":\"0x98f5c27ce01926f53eb30daa11bd9b2b0cf24274d81a99a04a74ed220f0a69cb\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", "bytecode": "0x60e060405260008054600160a81b600160e81b031916641e0000007d60aa1b1790553480156200002e57600080fd5b5060405162003a3438038062003a3483398101604081905262000051916200020b565b806200005d33620001a2565b6001600160a01b038116620000c45760405162461bcd60e51b815260206004820152602260248201527f4272696467652063616e206e6f7420626520746865207a65726f206164647265604482015261737360f01b60648201526084015b60405180910390fd5b6001600160a01b039081166080528316620001225760405162461bcd60e51b815260206004820181905260248201527f42616e6b2063616e206e6f7420626520746865207a65726f20616464726573736044820152606401620000bb565b6001600160a01b038216620001895760405162461bcd60e51b815260206004820152602660248201527f5442544320746f6b656e2063616e206e6f7420626520746865207a65726f206160448201526564647265737360d01b6064820152608401620000bb565b506001600160a01b0391821660a0521660c0526200025f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200020857600080fd5b50565b6000806000606084860312156200022157600080fd5b83516200022e81620001f2565b60208501519093506200024181620001f2565b60408501519092506200025481620001f2565b809150509250925092565b60805160a05160c0516137196200031b60003960008181610731015281816108b901528181610bf201528181611dac015281816120e90152818161297f01528181612aea0152612c3101526000818161057901528181610c5f01528181610dba01528181610e4801528181610f4d015281816121650152818161229d0152818161238e01528181612b480152612c8f015260008181610758015281816113ee0152818161158a01528181611b5e0152612b7701526137196000f3fe608060405234801561001057600080fd5b50600436106103365760003560e01c80638532c511116101b2578063a410d29b116100f9578063c36b32b7116100a2578063e5d3d7141161007c578063e5d3d7141461072c578063e78cea9214610753578063f2fde38b1461077a578063fc4e51f61461078d57600080fd5b8063c36b32b7146106fd578063c7ba034714610710578063d0ff65b51461071c57600080fd5b8063b0b54895116100d3578063b0b54895146106cd578063b9f78798146106d5578063bc7b6b99146106f557600080fd5b8063a410d29b1461068f578063a526d83b14610697578063aa271e1a146106aa57600080fd5b8063951315261161015b5780639a508c8e116101355780639a508c8e1461066b578063a0712d6814610673578063a0cceb951461068657600080fd5b80639513152614610647578063983b2d56146106505780639a4e36d51461066357600080fd5b8063897f712c1161018c578063897f712c1461060f5780638da5cb5b146106235780638f4ffcb11461063457600080fd5b80638532c511146105d95780638623ec7b146105e957806388aaf0c8146105fc57600080fd5b806347c1ffdb116102815780636c626aa41161022a5780637445a5a0116102045780637445a5a01461054657806376cdb03b1461057457806380df5ed2146105b3578063820b5513146105c657600080fd5b80636c626aa4146104d0578063714041561461052b578063715018a61461053e57600080fd5b806364e779b11161025b57806364e779b1146104955780636abe3a6c146104a85780636b32810b146104bb57600080fd5b806347c1ffdb1461046357806353dce4df1461046b5780635ae2da461461047e57600080fd5b80633092afd5116102e3578063461c6373116102bd578063461c63731461042a578063475d05701461043d578063479aa9271461045057600080fd5b80633092afd5146103fb578063317dfa761461040e57806341906ab71461042157600080fd5b80631171bda9116103145780631171bda9146103b4578063124f65bd146103c75780632e73e398146103e857600080fd5b806309b53f511461033b5780630c68ba211461036c5780630f3425731461039f575b600080fd5b60005461035290600160a81b900463ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b61038f61037a366004613008565b60036020526000908152604090205460ff1681565b6040519015158152602001610363565b6103b26103ad36600461303e565b6107a0565b005b6103b26103c236600461305b565b6107fb565b6103da6103d536600461309c565b61081c565b604051908152602001610363565b6103b26103f6366004613115565b610881565b6103b2610409366004613008565b61092f565b6103b261041c36600461305b565b610ba3565b6103da60095481565b6103b26104383660046131cd565b610c54565b6103b261044b366004613239565b610daf565b6103b261045e366004613008565b610fb0565b6103b2611075565b6103b2610479366004613289565b611111565b60005461035290600160c81b900463ffffffff1681565b6103b26104a33660046132d5565b611132565b6103b26104b636600461309c565b61114f565b6104c361169c565b60405161036391906132ee565b61050a6104de3660046132d5565b60046020526000908152604090205467ffffffffffffffff808216916801000000000000000090041682565b6040805167ffffffffffffffff938416815292909116602083015201610363565b6103b2610539366004613008565b6116fe565b6103b26117b7565b6105596105543660046132d5565b6117cb565b60408051938452602084019290925290820152606001610363565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610363565b6103b26105c136600461309c565b611803565b6103b26105d436600461309c565b6119ef565b6006546103529063ffffffff1681565b61059b6105f73660046132d5565b611d80565b600a5461059b906001600160a01b031681565b60005461038f90600160a01b900460ff1681565b6000546001600160a01b031661059b565b6103b261064236600461333b565b611daa565b6103da600b5481565b6103b261065e366004613008565b611ebf565b6103b2611fbc565b6103b2612058565b6103b26106813660046132d5565b61226d565b6103da60075481565b6103b26123c5565b6103b26106a5366004613008565b61246d565b61038f6106b8366004613008565b60016020526000908152604090205460ff1681565b6103da607881565b6103da6106e3366004613008565b60056020526000908152604090205481565b6103b2612550565b6103b261070b36600461303e565b6125e7565b6103da6402540be40081565b6008546103529063ffffffff1681565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6103b2610788366004613008565b61263b565b6103b261079b366004613115565b6126cb565b6107a8612720565b426009556008805463ffffffff191663ffffffff83169081179091556040519081527f682bc0fb7e0d6bcb974cf556b95f68533cafc411d83d9f33ac192ccf45dda605906020015b60405180910390a150565b610803612720565b6108176001600160a01b038416838361277a565b505050565b6000828260405160200161085f92919091825260e01b7fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6040516020818303038152906040528051906020012060001c90505b92915050565b610889612720565b6040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fc4e51f6906108f690889088908890889088906004016133ba565b600060405180830381600087803b15801561091057600080fd5b505af1158015610924573d6000803e3d6000fd5b505050505050505050565b336109426000546001600160a01b031690565b6001600160a01b0316148061096657503360009081526003602052604090205460ff165b6109dd5760405162461bcd60e51b815260206004820152602360248201527f43616c6c6572206973206e6f7420746865206f776e6572206f7220677561726460448201527f69616e000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6001600160a01b03811660009081526001602052604090205460ff16610a455760405162461bcd60e51b815260206004820152601c60248201527f546869732061646472657373206973206e6f742061206d696e7465720000000060448201526064016109d4565b6001600160a01b0381166000908152600160205260408120805460ff191690555b600254811015610b6b57816001600160a01b031660028281548110610a8d57610a8d6133ed565b6000918252602090912001546001600160a01b031603610b595760028054610ab790600190613419565b81548110610ac757610ac76133ed565b600091825260209091200154600280546001600160a01b039092169183908110610af357610af36133ed565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506002805480610b3257610b3261342c565b600082815260209020810160001990810180546001600160a01b0319169055019055610b6b565b80610b6381613442565b915050610a66565b506040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b610bab612720565b6040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301528381166024830152604482018390527f00000000000000000000000000000000000000000000000000000000000000001690631171bda9906064015b600060405180830381600087803b158015610c3757600080fd5b505af1158015610c4b573d6000803e3d6000fd5b50505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610ccc5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016109d4565b6000839003610d1d5760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f72732073706563696669656400000000000000000060448201526064016109d4565b60005b83811015610da8576000858583818110610d3c57610d3c6133ed565b9050602002016020810190610d519190613008565b90506000848484818110610d6757610d676133ed565b905060200201359050610d9382610d8e846402540be40085610d89919061345b565b6127fa565b6128fd565b50508080610da090613442565b915050610d20565b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610e275760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016109d4565b6040516370a0823160e01b81526001600160a01b03858116600483015284917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa158015610e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb59190613472565b1015610f0e5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016109d4565b610f2184610d8e6402540be4008661345b565b604051631f1b6d2760e21b81526001600160a01b038581166004830152306024830152604482018590527f00000000000000000000000000000000000000000000000000000000000000001690637c6db49c906064015b600060405180830381600087803b158015610f9257600080fd5b505af1158015610fa6573d6000803e3d6000fd5b5050505050505050565b610fb8612720565b6001600160a01b03811661100e5760405162461bcd60e51b815260206004820181905260248201527f4e6577207661756c7420616464726573732063616e6e6f74206265207a65726f60448201526064016109d4565b604080516001600160a01b03831681524260208201527f5cc842cab066489e13292128663547c68705dbf476f0131e0107f155719c6124910160405180910390a142600b55600a80546001600160a01b0319166001600160a01b0392909216919091179055565b61107d612720565b60075461108b8160786129d8565b600654600080547fffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160a81b81029290921790556040519081527fa7f4ce7c3586e2000cdec6b25c5e7d0b20f9b4f435aa22d9c1feb32dbb506f779060200160405180910390a1506006805463ffffffff191690556000600755565b600061111c846117cb565b5050905061112c33828585612a81565b50505050565b600061113d826117cb565b5050905061114b3382612bc8565b5050565b3360009081526001602052604090205460ff166111ae5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016109d4565b600054600160a01b900460ff16156112085760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016109d4565b6000611214838361081c565b600081815260046020526040812080549293509167ffffffffffffffff1690036112a65760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016109d4565b805468010000000000000000900467ffffffffffffffff16156113315760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016109d4565b600054815461135791600160c81b900463ffffffff169067ffffffffffffffff1661348b565b67ffffffffffffffff1642116113d55760405162461bcd60e51b815260206004820152602b60248201527f4f7074696d6973746963206d696e74696e672064656c617920686173206e6f7460448201527f207061737365642079657400000000000000000000000000000000000000000060648201526084016109d4565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa15801561143d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146191906134df565b90508060a0015163ffffffff166000146114bd5760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016109d4565b60006402540be400826080015183602001516114d9919061358c565b67ffffffffffffffff166114ed919061345b565b6000805491925090600160a81b900463ffffffff1661150d576000611527565b60005461152790600160a81b900463ffffffff16836135c3565b83516001600160a01b0316600090815260056020526040812054919250906115509084906135d7565b84516001600160a01b03166000908152600560205260409020819055845190915061157f90610d8e8486613419565b8115611610576116107f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160a91906135ea565b836128fd565b84547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff16680100000000000000004267ffffffffffffffff160217855583516040518281526001600160a01b0390911690879033907f2cffebf26d639426e79514d100febae8b2c63e700e5dc0fa6c88a129633506369060200160405180910390a45050505050505050565b606060028054806020026020016040519081016040528092919081815260200182805480156116f457602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116116d6575b5050505050905090565b611706612720565b6001600160a01b03811660009081526003602052604090205460ff1661176e5760405162461bcd60e51b815260206004820152601e60248201527f546869732061646472657373206973206e6f74206120677561726469616e000060448201526064016109d4565b6001600160a01b038116600081815260036020526040808220805460ff19169055517fb8107d0c6b40be480ce3172ee66ba6d64b71f6b1685a851340036e6e2e3e3c529190a250565b6117bf612720565b6117c96000612d17565b565b600080806117de6402540be40085613607565b91506117ea8285613419565b92506117fb6402540be400846135c3565b929491935050565b3360009081526003602052604090205460ff166118625760405162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f74206120677561726469616e000000000000000060448201526064016109d4565b600061186e838361081c565b600081815260046020526040812080549293509167ffffffffffffffff1690036119005760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016109d4565b805468010000000000000000900467ffffffffffffffff161561198b5760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016109d4565b60008281526004602052604080822080547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016905551839133917f1256b41d4b18d922811c358ab80cb0375aae28f45373de35cfda580662193fcd9190a350505050565b3360009081526001602052604090205460ff16611a4e5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016109d4565b600054600160a01b900460ff1615611aa85760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016109d4565b6000611ab4838361081c565b600081815260046020526040902080549192509067ffffffffffffffff1615611b455760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c726561647920726571756560448201527f7374656420666f7220746865206465706f73697400000000000000000000000060648201526084016109d4565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa158015611bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd191906134df565b9050806040015163ffffffff16600003611c375760405162461bcd60e51b815260206004820152602160248201527f546865206465706f73697420686173206e6f74206265656e2072657665616c656044820152601960fa1b60648201526084016109d4565b60a081015163ffffffff1615611c8f5760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016109d4565b60608101516001600160a01b03163014611ceb5760405162461bcd60e51b815260206004820152601860248201527f556e6578706563746564207661756c742061646472657373000000000000000060448201526064016109d4565b815467ffffffffffffffff19164267ffffffffffffffff908116919091178355815160208301516001600160a01b0390911691859133917f36f39c606d55d7dd2a05b8c4e41e9a6ca8c501cea10009c1762f6826a146e05591611d55916402540be400911661345b565b60408051918252602082018b905263ffffffff8a169082015260600160405180910390a45050505050565b60028181548110611d9057600080fd5b6000918252602090912001546001600160a01b0316905081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614611e2b5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f74205442544300000000000000000000000000000060448201526064016109d4565b336001600160a01b03841614611e835760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f776564000000000000000060448201526064016109d4565b6000611e8e856117cb565b50909150506000829003611eab57611ea68682612bc8565b611eb7565b611eb786828585612a81565b505050505050565b611ec7612720565b6001600160a01b03811660009081526001602052604090205460ff1615611f305760405162461bcd60e51b815260206004820181905260248201527f54686973206164647265737320697320616c72656164792061206d696e74657260448201526064016109d4565b6001600160a01b0381166000818152600160208190526040808320805460ff19168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180546001600160a01b03191684179055517f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f69190a250565b611fc4612720565b600954611fd28160786129d8565b600854600080547fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160c81b81029290921790556040519081527ff52de3377e3ae270d1e38f99b9b8d587814643811516ea55ba4d597f9950d4ec9060200160405180910390a1506008805463ffffffff191690556000600955565b612060612720565b600b5461206e8160786129d8565b600a546040516001600160a01b0390911681527f81a9bb8030ed4116b405800280e065110a37afb57b69948e714c97fab23475ec9060200160405180910390a1600a546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063f2fde38b90602401600060405180830381600087803b15801561212f57600080fd5b505af1158015612143573d6000803e3d6000fd5b5050600a546040516370a0823160e01b81523060048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811694506356a6d9ef93509091169083906370a0823190602401602060405180830381865afa1580156121bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121df9190613472565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561223d57600080fd5b505af1158015612251573d6000803e3d6000fd5b5050600a80546001600160a01b031916905550506000600b5550565b600080612279836117cb565b6040516370a0823160e01b8152336004820152929450925082916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691506370a0823190602401602060405180830381865afa1580156122e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123099190613472565b10156123625760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016109d4565b61236c33836128fd565b604051631f1b6d2760e21b8152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637c6db49c90606401610c1d565b6123cd612720565b600054600160a01b900460ff16156124315760405162461bcd60e51b815260206004820152602160248201527f4f7074696d6973746963206d696e74696e6720616c72656164792070617573656044820152601960fa1b60648201526084016109d4565b6000805460ff60a01b1916600160a01b1781556040517f23a83c8aeda8c831401c17b5bfb8b2ead79fcfe9c027fe34a4f8576e2c7c74cc9190a1565b612475612720565b6001600160a01b03811660009081526003602052604090205460ff16156125045760405162461bcd60e51b815260206004820152602260248201527f54686973206164647265737320697320616c726561647920612067756172646960448201527f616e00000000000000000000000000000000000000000000000000000000000060648201526084016109d4565b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f038596bb31e2e7d3d9f184d4c98b310103f6d7f5830e5eec32bffe6f1728f9699190a250565b612558612720565b600054600160a01b900460ff166125b15760405162461bcd60e51b815260206004820181905260248201527f4f7074696d6973746963206d696e74696e67206973206e6f742070617573656460448201526064016109d4565b6000805460ff60a01b191681556040517fcb27470ed9568d9eeb8939707bafc19404d908a26ce5f468a6aa781024fd6a839190a1565b6125ef612720565b426007556006805463ffffffff191663ffffffff83169081179091556040519081527f0dbfec7f12acffbb5cec595ac4370907eaf84caa7025dd71f4021433be79eba9906020016107f0565b612643612720565b6001600160a01b0381166126bf5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109d4565b6126c881612d17565b50565b6126d3612720565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde906108f690309088908890889088906004016133ba565b6000546001600160a01b031633146117c95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109d4565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610817908490612d67565b6001600160a01b038216600090815260056020526040812054808203612823578291505061087b565b8083111561288a576001600160a01b0384166000818152600560209081526040808320839055519182527fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8910160405180910390a26128828184613419565b91505061087b565b6128948382613419565b6001600160a01b0385166000818152600560205260409020919091557fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f86128db8584613419565b60405190815260200160405180910390a2600091505061087b565b5092915050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161293891815260200190565b60405180910390a26040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906340c10f19906044015b600060405180830381600087803b1580156129c457600080fd5b505af1158015611eb7573d6000803e3d6000fd5b60008211612a285760405162461bcd60e51b815260206004820152601460248201527f4368616e6765206e6f7420696e6974696174656400000000000000000000000060448201526064016109d4565b80612a338342613419565b101561114b5760405162461bcd60e51b815260206004820181905260248201527f476f7665726e616e63652064656c617920686173206e6f7420656c617073656460448201526064016109d4565b836001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b884604051612abc91815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038581166004830152602482018590527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b158015612b2e57600080fd5b505af1158015612b42573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a38757e7f00000000000000000000000000000000000000000000000000000000000000006402540be40086612ba791906135c3565b85856040518563ffffffff1660e01b8152600401610f78949392919061361b565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b882604051612c0391815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b158015612c7557600080fd5b505af1158015612c89573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166356a6d9ef836402540be40084612cce91906135c3565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b03909216600483015260248201526044016129aa565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000612dbc826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e4c9092919063ffffffff16565b8051909150156108175780806020019051810190612dda919061364e565b6108175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016109d4565b6060612e5b8484600085612e63565b949350505050565b606082471015612edb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016109d4565b600080866001600160a01b03168587604051612ef79190613694565b60006040518083038185875af1925050503d8060008114612f34576040519150601f19603f3d011682016040523d82523d6000602084013e612f39565b606091505b5091509150612f4a87838387612f55565b979650505050505050565b60608315612fc4578251600003612fbd576001600160a01b0385163b612fbd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109d4565b5081612e5b565b612e5b8383815115612fd95781518083602001fd5b8060405162461bcd60e51b81526004016109d491906136b0565b6001600160a01b03811681146126c857600080fd5b60006020828403121561301a57600080fd5b813561302581612ff3565b9392505050565b63ffffffff811681146126c857600080fd5b60006020828403121561305057600080fd5b81356130258161302c565b60008060006060848603121561307057600080fd5b833561307b81612ff3565b9250602084013561308b81612ff3565b929592945050506040919091013590565b600080604083850312156130af57600080fd5b8235915060208301356130c18161302c565b809150509250929050565b60008083601f8401126130de57600080fd5b50813567ffffffffffffffff8111156130f657600080fd5b60208301915083602082850101111561310e57600080fd5b9250929050565b60008060008060006080868803121561312d57600080fd5b853561313881612ff3565b9450602086013561314881612ff3565b935060408601359250606086013567ffffffffffffffff81111561316b57600080fd5b613177888289016130cc565b969995985093965092949392505050565b60008083601f84011261319a57600080fd5b50813567ffffffffffffffff8111156131b257600080fd5b6020830191508360208260051b850101111561310e57600080fd5b600080600080604085870312156131e357600080fd5b843567ffffffffffffffff808211156131fb57600080fd5b61320788838901613188565b9096509450602087013591508082111561322057600080fd5b5061322d87828801613188565b95989497509550505050565b6000806000806060858703121561324f57600080fd5b843561325a81612ff3565b935060208501359250604085013567ffffffffffffffff81111561327d57600080fd5b61322d878288016130cc565b60008060006040848603121561329e57600080fd5b83359250602084013567ffffffffffffffff8111156132bc57600080fd5b6132c8868287016130cc565b9497909650939450505050565b6000602082840312156132e757600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b8181101561332f5783516001600160a01b03168352928401929184019160010161330a565b50909695505050505050565b60008060008060006080868803121561335357600080fd5b853561335e81612ff3565b945060208601359350604086013561337581612ff3565b9250606086013567ffffffffffffffff81111561316b57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b03808816835280871660208401525084604083015260806060830152612f4a608083018486613391565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561087b5761087b613403565b634e487b7160e01b600052603160045260246000fd5b60006001820161345457613454613403565b5060010190565b808202811582820484141761087b5761087b613403565b60006020828403121561348457600080fd5b5051919050565b67ffffffffffffffff8181168382160190808211156128f6576128f6613403565b80516134b781612ff3565b919050565b805167ffffffffffffffff811681146134b757600080fd5b80516134b78161302c565b600060c082840312156134f157600080fd5b60405160c0810181811067ffffffffffffffff8211171561352257634e487b7160e01b600052604160045260246000fd5b60405261352e836134ac565b815261353c602084016134bc565b602082015261354d604084016134d4565b604082015261355e606084016134ac565b606082015261356f608084016134bc565b608082015261358060a084016134d4565b60a08201529392505050565b67ffffffffffffffff8281168282160390808211156128f6576128f6613403565b634e487b7160e01b600052601260045260246000fd5b6000826135d2576135d26135ad565b500490565b8082018082111561087b5761087b613403565b6000602082840312156135fc57600080fd5b815161302581612ff3565b600082613616576136166135ad565b500690565b6001600160a01b0385168152836020820152606060408201526000613644606083018486613391565b9695505050505050565b60006020828403121561366057600080fd5b8151801515811461302557600080fd5b60005b8381101561368b578181015183820152602001613673565b50506000910152565b600082516136a6818460208701613670565b9190910192915050565b60208152600082518060208401526136cf816040850160208701613670565b601f01601f1916919091016040019291505056fea264697066735822122067e598157c5e78f471b8da3413f39b587773c962feeb0c84c36ad4d283f8c55964736f6c63430008110033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103365760003560e01c80638532c511116101b2578063a410d29b116100f9578063c36b32b7116100a2578063e5d3d7141161007c578063e5d3d7141461072c578063e78cea9214610753578063f2fde38b1461077a578063fc4e51f61461078d57600080fd5b8063c36b32b7146106fd578063c7ba034714610710578063d0ff65b51461071c57600080fd5b8063b0b54895116100d3578063b0b54895146106cd578063b9f78798146106d5578063bc7b6b99146106f557600080fd5b8063a410d29b1461068f578063a526d83b14610697578063aa271e1a146106aa57600080fd5b8063951315261161015b5780639a508c8e116101355780639a508c8e1461066b578063a0712d6814610673578063a0cceb951461068657600080fd5b80639513152614610647578063983b2d56146106505780639a4e36d51461066357600080fd5b8063897f712c1161018c578063897f712c1461060f5780638da5cb5b146106235780638f4ffcb11461063457600080fd5b80638532c511146105d95780638623ec7b146105e957806388aaf0c8146105fc57600080fd5b806347c1ffdb116102815780636c626aa41161022a5780637445a5a0116102045780637445a5a01461054657806376cdb03b1461057457806380df5ed2146105b3578063820b5513146105c657600080fd5b80636c626aa4146104d0578063714041561461052b578063715018a61461053e57600080fd5b806364e779b11161025b57806364e779b1146104955780636abe3a6c146104a85780636b32810b146104bb57600080fd5b806347c1ffdb1461046357806353dce4df1461046b5780635ae2da461461047e57600080fd5b80633092afd5116102e3578063461c6373116102bd578063461c63731461042a578063475d05701461043d578063479aa9271461045057600080fd5b80633092afd5146103fb578063317dfa761461040e57806341906ab71461042157600080fd5b80631171bda9116103145780631171bda9146103b4578063124f65bd146103c75780632e73e398146103e857600080fd5b806309b53f511461033b5780630c68ba211461036c5780630f3425731461039f575b600080fd5b60005461035290600160a81b900463ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b61038f61037a366004613008565b60036020526000908152604090205460ff1681565b6040519015158152602001610363565b6103b26103ad36600461303e565b6107a0565b005b6103b26103c236600461305b565b6107fb565b6103da6103d536600461309c565b61081c565b604051908152602001610363565b6103b26103f6366004613115565b610881565b6103b2610409366004613008565b61092f565b6103b261041c36600461305b565b610ba3565b6103da60095481565b6103b26104383660046131cd565b610c54565b6103b261044b366004613239565b610daf565b6103b261045e366004613008565b610fb0565b6103b2611075565b6103b2610479366004613289565b611111565b60005461035290600160c81b900463ffffffff1681565b6103b26104a33660046132d5565b611132565b6103b26104b636600461309c565b61114f565b6104c361169c565b60405161036391906132ee565b61050a6104de3660046132d5565b60046020526000908152604090205467ffffffffffffffff808216916801000000000000000090041682565b6040805167ffffffffffffffff938416815292909116602083015201610363565b6103b2610539366004613008565b6116fe565b6103b26117b7565b6105596105543660046132d5565b6117cb565b60408051938452602084019290925290820152606001610363565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610363565b6103b26105c136600461309c565b611803565b6103b26105d436600461309c565b6119ef565b6006546103529063ffffffff1681565b61059b6105f73660046132d5565b611d80565b600a5461059b906001600160a01b031681565b60005461038f90600160a01b900460ff1681565b6000546001600160a01b031661059b565b6103b261064236600461333b565b611daa565b6103da600b5481565b6103b261065e366004613008565b611ebf565b6103b2611fbc565b6103b2612058565b6103b26106813660046132d5565b61226d565b6103da60075481565b6103b26123c5565b6103b26106a5366004613008565b61246d565b61038f6106b8366004613008565b60016020526000908152604090205460ff1681565b6103da607881565b6103da6106e3366004613008565b60056020526000908152604090205481565b6103b2612550565b6103b261070b36600461303e565b6125e7565b6103da6402540be40081565b6008546103529063ffffffff1681565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6103b2610788366004613008565b61263b565b6103b261079b366004613115565b6126cb565b6107a8612720565b426009556008805463ffffffff191663ffffffff83169081179091556040519081527f682bc0fb7e0d6bcb974cf556b95f68533cafc411d83d9f33ac192ccf45dda605906020015b60405180910390a150565b610803612720565b6108176001600160a01b038416838361277a565b505050565b6000828260405160200161085f92919091825260e01b7fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6040516020818303038152906040528051906020012060001c90505b92915050565b610889612720565b6040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fc4e51f6906108f690889088908890889088906004016133ba565b600060405180830381600087803b15801561091057600080fd5b505af1158015610924573d6000803e3d6000fd5b505050505050505050565b336109426000546001600160a01b031690565b6001600160a01b0316148061096657503360009081526003602052604090205460ff165b6109dd5760405162461bcd60e51b815260206004820152602360248201527f43616c6c6572206973206e6f7420746865206f776e6572206f7220677561726460448201527f69616e000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6001600160a01b03811660009081526001602052604090205460ff16610a455760405162461bcd60e51b815260206004820152601c60248201527f546869732061646472657373206973206e6f742061206d696e7465720000000060448201526064016109d4565b6001600160a01b0381166000908152600160205260408120805460ff191690555b600254811015610b6b57816001600160a01b031660028281548110610a8d57610a8d6133ed565b6000918252602090912001546001600160a01b031603610b595760028054610ab790600190613419565b81548110610ac757610ac76133ed565b600091825260209091200154600280546001600160a01b039092169183908110610af357610af36133ed565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506002805480610b3257610b3261342c565b600082815260209020810160001990810180546001600160a01b0319169055019055610b6b565b80610b6381613442565b915050610a66565b506040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b610bab612720565b6040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301528381166024830152604482018390527f00000000000000000000000000000000000000000000000000000000000000001690631171bda9906064015b600060405180830381600087803b158015610c3757600080fd5b505af1158015610c4b573d6000803e3d6000fd5b50505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610ccc5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016109d4565b6000839003610d1d5760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f72732073706563696669656400000000000000000060448201526064016109d4565b60005b83811015610da8576000858583818110610d3c57610d3c6133ed565b9050602002016020810190610d519190613008565b90506000848484818110610d6757610d676133ed565b905060200201359050610d9382610d8e846402540be40085610d89919061345b565b6127fa565b6128fd565b50508080610da090613442565b915050610d20565b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610e275760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016109d4565b6040516370a0823160e01b81526001600160a01b03858116600483015284917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa158015610e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb59190613472565b1015610f0e5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016109d4565b610f2184610d8e6402540be4008661345b565b604051631f1b6d2760e21b81526001600160a01b038581166004830152306024830152604482018590527f00000000000000000000000000000000000000000000000000000000000000001690637c6db49c906064015b600060405180830381600087803b158015610f9257600080fd5b505af1158015610fa6573d6000803e3d6000fd5b5050505050505050565b610fb8612720565b6001600160a01b03811661100e5760405162461bcd60e51b815260206004820181905260248201527f4e6577207661756c7420616464726573732063616e6e6f74206265207a65726f60448201526064016109d4565b604080516001600160a01b03831681524260208201527f5cc842cab066489e13292128663547c68705dbf476f0131e0107f155719c6124910160405180910390a142600b55600a80546001600160a01b0319166001600160a01b0392909216919091179055565b61107d612720565b60075461108b8160786129d8565b600654600080547fffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160a81b81029290921790556040519081527fa7f4ce7c3586e2000cdec6b25c5e7d0b20f9b4f435aa22d9c1feb32dbb506f779060200160405180910390a1506006805463ffffffff191690556000600755565b600061111c846117cb565b5050905061112c33828585612a81565b50505050565b600061113d826117cb565b5050905061114b3382612bc8565b5050565b3360009081526001602052604090205460ff166111ae5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016109d4565b600054600160a01b900460ff16156112085760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016109d4565b6000611214838361081c565b600081815260046020526040812080549293509167ffffffffffffffff1690036112a65760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016109d4565b805468010000000000000000900467ffffffffffffffff16156113315760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016109d4565b600054815461135791600160c81b900463ffffffff169067ffffffffffffffff1661348b565b67ffffffffffffffff1642116113d55760405162461bcd60e51b815260206004820152602b60248201527f4f7074696d6973746963206d696e74696e672064656c617920686173206e6f7460448201527f207061737365642079657400000000000000000000000000000000000000000060648201526084016109d4565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa15801561143d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146191906134df565b90508060a0015163ffffffff166000146114bd5760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016109d4565b60006402540be400826080015183602001516114d9919061358c565b67ffffffffffffffff166114ed919061345b565b6000805491925090600160a81b900463ffffffff1661150d576000611527565b60005461152790600160a81b900463ffffffff16836135c3565b83516001600160a01b0316600090815260056020526040812054919250906115509084906135d7565b84516001600160a01b03166000908152600560205260409020819055845190915061157f90610d8e8486613419565b8115611610576116107f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160a91906135ea565b836128fd565b84547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff16680100000000000000004267ffffffffffffffff160217855583516040518281526001600160a01b0390911690879033907f2cffebf26d639426e79514d100febae8b2c63e700e5dc0fa6c88a129633506369060200160405180910390a45050505050505050565b606060028054806020026020016040519081016040528092919081815260200182805480156116f457602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116116d6575b5050505050905090565b611706612720565b6001600160a01b03811660009081526003602052604090205460ff1661176e5760405162461bcd60e51b815260206004820152601e60248201527f546869732061646472657373206973206e6f74206120677561726469616e000060448201526064016109d4565b6001600160a01b038116600081815260036020526040808220805460ff19169055517fb8107d0c6b40be480ce3172ee66ba6d64b71f6b1685a851340036e6e2e3e3c529190a250565b6117bf612720565b6117c96000612d17565b565b600080806117de6402540be40085613607565b91506117ea8285613419565b92506117fb6402540be400846135c3565b929491935050565b3360009081526003602052604090205460ff166118625760405162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f74206120677561726469616e000000000000000060448201526064016109d4565b600061186e838361081c565b600081815260046020526040812080549293509167ffffffffffffffff1690036119005760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016109d4565b805468010000000000000000900467ffffffffffffffff161561198b5760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016109d4565b60008281526004602052604080822080547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016905551839133917f1256b41d4b18d922811c358ab80cb0375aae28f45373de35cfda580662193fcd9190a350505050565b3360009081526001602052604090205460ff16611a4e5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016109d4565b600054600160a01b900460ff1615611aa85760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016109d4565b6000611ab4838361081c565b600081815260046020526040902080549192509067ffffffffffffffff1615611b455760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c726561647920726571756560448201527f7374656420666f7220746865206465706f73697400000000000000000000000060648201526084016109d4565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa158015611bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd191906134df565b9050806040015163ffffffff16600003611c375760405162461bcd60e51b815260206004820152602160248201527f546865206465706f73697420686173206e6f74206265656e2072657665616c656044820152601960fa1b60648201526084016109d4565b60a081015163ffffffff1615611c8f5760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016109d4565b60608101516001600160a01b03163014611ceb5760405162461bcd60e51b815260206004820152601860248201527f556e6578706563746564207661756c742061646472657373000000000000000060448201526064016109d4565b815467ffffffffffffffff19164267ffffffffffffffff908116919091178355815160208301516001600160a01b0390911691859133917f36f39c606d55d7dd2a05b8c4e41e9a6ca8c501cea10009c1762f6826a146e05591611d55916402540be400911661345b565b60408051918252602082018b905263ffffffff8a169082015260600160405180910390a45050505050565b60028181548110611d9057600080fd5b6000918252602090912001546001600160a01b0316905081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614611e2b5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f74205442544300000000000000000000000000000060448201526064016109d4565b336001600160a01b03841614611e835760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f776564000000000000000060448201526064016109d4565b6000611e8e856117cb565b50909150506000829003611eab57611ea68682612bc8565b611eb7565b611eb786828585612a81565b505050505050565b611ec7612720565b6001600160a01b03811660009081526001602052604090205460ff1615611f305760405162461bcd60e51b815260206004820181905260248201527f54686973206164647265737320697320616c72656164792061206d696e74657260448201526064016109d4565b6001600160a01b0381166000818152600160208190526040808320805460ff19168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180546001600160a01b03191684179055517f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f69190a250565b611fc4612720565b600954611fd28160786129d8565b600854600080547fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160c81b81029290921790556040519081527ff52de3377e3ae270d1e38f99b9b8d587814643811516ea55ba4d597f9950d4ec9060200160405180910390a1506008805463ffffffff191690556000600955565b612060612720565b600b5461206e8160786129d8565b600a546040516001600160a01b0390911681527f81a9bb8030ed4116b405800280e065110a37afb57b69948e714c97fab23475ec9060200160405180910390a1600a546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063f2fde38b90602401600060405180830381600087803b15801561212f57600080fd5b505af1158015612143573d6000803e3d6000fd5b5050600a546040516370a0823160e01b81523060048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811694506356a6d9ef93509091169083906370a0823190602401602060405180830381865afa1580156121bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121df9190613472565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561223d57600080fd5b505af1158015612251573d6000803e3d6000fd5b5050600a80546001600160a01b031916905550506000600b5550565b600080612279836117cb565b6040516370a0823160e01b8152336004820152929450925082916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691506370a0823190602401602060405180830381865afa1580156122e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123099190613472565b10156123625760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016109d4565b61236c33836128fd565b604051631f1b6d2760e21b8152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637c6db49c90606401610c1d565b6123cd612720565b600054600160a01b900460ff16156124315760405162461bcd60e51b815260206004820152602160248201527f4f7074696d6973746963206d696e74696e6720616c72656164792070617573656044820152601960fa1b60648201526084016109d4565b6000805460ff60a01b1916600160a01b1781556040517f23a83c8aeda8c831401c17b5bfb8b2ead79fcfe9c027fe34a4f8576e2c7c74cc9190a1565b612475612720565b6001600160a01b03811660009081526003602052604090205460ff16156125045760405162461bcd60e51b815260206004820152602260248201527f54686973206164647265737320697320616c726561647920612067756172646960448201527f616e00000000000000000000000000000000000000000000000000000000000060648201526084016109d4565b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f038596bb31e2e7d3d9f184d4c98b310103f6d7f5830e5eec32bffe6f1728f9699190a250565b612558612720565b600054600160a01b900460ff166125b15760405162461bcd60e51b815260206004820181905260248201527f4f7074696d6973746963206d696e74696e67206973206e6f742070617573656460448201526064016109d4565b6000805460ff60a01b191681556040517fcb27470ed9568d9eeb8939707bafc19404d908a26ce5f468a6aa781024fd6a839190a1565b6125ef612720565b426007556006805463ffffffff191663ffffffff83169081179091556040519081527f0dbfec7f12acffbb5cec595ac4370907eaf84caa7025dd71f4021433be79eba9906020016107f0565b612643612720565b6001600160a01b0381166126bf5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109d4565b6126c881612d17565b50565b6126d3612720565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde906108f690309088908890889088906004016133ba565b6000546001600160a01b031633146117c95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109d4565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610817908490612d67565b6001600160a01b038216600090815260056020526040812054808203612823578291505061087b565b8083111561288a576001600160a01b0384166000818152600560209081526040808320839055519182527fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8910160405180910390a26128828184613419565b91505061087b565b6128948382613419565b6001600160a01b0385166000818152600560205260409020919091557fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f86128db8584613419565b60405190815260200160405180910390a2600091505061087b565b5092915050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161293891815260200190565b60405180910390a26040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906340c10f19906044015b600060405180830381600087803b1580156129c457600080fd5b505af1158015611eb7573d6000803e3d6000fd5b60008211612a285760405162461bcd60e51b815260206004820152601460248201527f4368616e6765206e6f7420696e6974696174656400000000000000000000000060448201526064016109d4565b80612a338342613419565b101561114b5760405162461bcd60e51b815260206004820181905260248201527f476f7665726e616e63652064656c617920686173206e6f7420656c617073656460448201526064016109d4565b836001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b884604051612abc91815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038581166004830152602482018590527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b158015612b2e57600080fd5b505af1158015612b42573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a38757e7f00000000000000000000000000000000000000000000000000000000000000006402540be40086612ba791906135c3565b85856040518563ffffffff1660e01b8152600401610f78949392919061361b565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b882604051612c0391815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b158015612c7557600080fd5b505af1158015612c89573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166356a6d9ef836402540be40084612cce91906135c3565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b03909216600483015260248201526044016129aa565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000612dbc826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e4c9092919063ffffffff16565b8051909150156108175780806020019051810190612dda919061364e565b6108175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016109d4565b6060612e5b8484600085612e63565b949350505050565b606082471015612edb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016109d4565b600080866001600160a01b03168587604051612ef79190613694565b60006040518083038185875af1925050503d8060008114612f34576040519150601f19603f3d011682016040523d82523d6000602084013e612f39565b606091505b5091509150612f4a87838387612f55565b979650505050505050565b60608315612fc4578251600003612fbd576001600160a01b0385163b612fbd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109d4565b5081612e5b565b612e5b8383815115612fd95781518083602001fd5b8060405162461bcd60e51b81526004016109d491906136b0565b6001600160a01b03811681146126c857600080fd5b60006020828403121561301a57600080fd5b813561302581612ff3565b9392505050565b63ffffffff811681146126c857600080fd5b60006020828403121561305057600080fd5b81356130258161302c565b60008060006060848603121561307057600080fd5b833561307b81612ff3565b9250602084013561308b81612ff3565b929592945050506040919091013590565b600080604083850312156130af57600080fd5b8235915060208301356130c18161302c565b809150509250929050565b60008083601f8401126130de57600080fd5b50813567ffffffffffffffff8111156130f657600080fd5b60208301915083602082850101111561310e57600080fd5b9250929050565b60008060008060006080868803121561312d57600080fd5b853561313881612ff3565b9450602086013561314881612ff3565b935060408601359250606086013567ffffffffffffffff81111561316b57600080fd5b613177888289016130cc565b969995985093965092949392505050565b60008083601f84011261319a57600080fd5b50813567ffffffffffffffff8111156131b257600080fd5b6020830191508360208260051b850101111561310e57600080fd5b600080600080604085870312156131e357600080fd5b843567ffffffffffffffff808211156131fb57600080fd5b61320788838901613188565b9096509450602087013591508082111561322057600080fd5b5061322d87828801613188565b95989497509550505050565b6000806000806060858703121561324f57600080fd5b843561325a81612ff3565b935060208501359250604085013567ffffffffffffffff81111561327d57600080fd5b61322d878288016130cc565b60008060006040848603121561329e57600080fd5b83359250602084013567ffffffffffffffff8111156132bc57600080fd5b6132c8868287016130cc565b9497909650939450505050565b6000602082840312156132e757600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b8181101561332f5783516001600160a01b03168352928401929184019160010161330a565b50909695505050505050565b60008060008060006080868803121561335357600080fd5b853561335e81612ff3565b945060208601359350604086013561337581612ff3565b9250606086013567ffffffffffffffff81111561316b57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b03808816835280871660208401525084604083015260806060830152612f4a608083018486613391565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561087b5761087b613403565b634e487b7160e01b600052603160045260246000fd5b60006001820161345457613454613403565b5060010190565b808202811582820484141761087b5761087b613403565b60006020828403121561348457600080fd5b5051919050565b67ffffffffffffffff8181168382160190808211156128f6576128f6613403565b80516134b781612ff3565b919050565b805167ffffffffffffffff811681146134b757600080fd5b80516134b78161302c565b600060c082840312156134f157600080fd5b60405160c0810181811067ffffffffffffffff8211171561352257634e487b7160e01b600052604160045260246000fd5b60405261352e836134ac565b815261353c602084016134bc565b602082015261354d604084016134d4565b604082015261355e606084016134ac565b606082015261356f608084016134bc565b608082015261358060a084016134d4565b60a08201529392505050565b67ffffffffffffffff8281168282160390808211156128f6576128f6613403565b634e487b7160e01b600052601260045260246000fd5b6000826135d2576135d26135ad565b500490565b8082018082111561087b5761087b613403565b6000602082840312156135fc57600080fd5b815161302581612ff3565b600082613616576136166135ad565b500690565b6001600160a01b0385168152836020820152606060408201526000613644606083018486613391565b9695505050505050565b60006020828403121561366057600080fd5b8151801515811461302557600080fd5b60005b8381101561368b578181015183820152602001613673565b50506000910152565b600082516136a6818460208701613670565b9190910192915050565b60208152600082518060208401526136cf816040850160208701613670565b601f01601f1916919091016040019291505056fea264697066735822122067e598157c5e78f471b8da3413f39b587773c962feeb0c84c36ad4d283f8c55964736f6c63430008110033", @@ -1405,7 +1405,7 @@ "storageLayout": { "storage": [ { - "astId": 17301, + "astId": 17299, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "_owner", "offset": 0, @@ -1413,7 +1413,7 @@ "type": "t_address" }, { - "astId": 42010, + "astId": 41998, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "isOptimisticMintingPaused", "offset": 20, @@ -1421,7 +1421,7 @@ "type": "t_bool" }, { - "astId": 42014, + "astId": 42002, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "optimisticMintingFeeDivisor", "offset": 21, @@ -1429,7 +1429,7 @@ "type": "t_uint32" }, { - "astId": 42018, + "astId": 42006, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "optimisticMintingDelay", "offset": 25, @@ -1437,7 +1437,7 @@ "type": "t_uint32" }, { - "astId": 42023, + "astId": 42011, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "isMinter", "offset": 0, @@ -1445,7 +1445,7 @@ "type": "t_mapping(t_address,t_bool)" }, { - "astId": 42027, + "astId": 42015, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "minters", "offset": 0, @@ -1453,7 +1453,7 @@ "type": "t_array(t_address)dyn_storage" }, { - "astId": 42032, + "astId": 42020, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "isGuardian", "offset": 0, @@ -1461,15 +1461,15 @@ "type": "t_mapping(t_address,t_bool)" }, { - "astId": 42038, + "astId": 42026, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "optimisticMintingRequests", "offset": 0, "slot": "4", - "type": "t_mapping(t_uint256,t_struct(OptimisticMintingRequest)41994_storage)" + "type": "t_mapping(t_uint256,t_struct(OptimisticMintingRequest)41982_storage)" }, { - "astId": 42043, + "astId": 42031, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "optimisticMintingDebt", "offset": 0, @@ -1477,7 +1477,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 42046, + "astId": 42034, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "newOptimisticMintingFeeDivisor", "offset": 0, @@ -1485,7 +1485,7 @@ "type": "t_uint32" }, { - "astId": 42049, + "astId": 42037, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "optimisticMintingFeeUpdateInitiatedTimestamp", "offset": 0, @@ -1493,7 +1493,7 @@ "type": "t_uint256" }, { - "astId": 42052, + "astId": 42040, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "newOptimisticMintingDelay", "offset": 0, @@ -1501,7 +1501,7 @@ "type": "t_uint32" }, { - "astId": 42055, + "astId": 42043, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "optimisticMintingDelayUpdateInitiatedTimestamp", "offset": 0, @@ -1509,7 +1509,7 @@ "type": "t_uint256" }, { - "astId": 42926, + "astId": 42914, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "newVault", "offset": 0, @@ -1517,7 +1517,7 @@ "type": "t_address" }, { - "astId": 42929, + "astId": 42917, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "upgradeInitiatedTimestamp", "offset": 0, @@ -1556,19 +1556,19 @@ "numberOfBytes": "32", "value": "t_uint256" }, - "t_mapping(t_uint256,t_struct(OptimisticMintingRequest)41994_storage)": { + "t_mapping(t_uint256,t_struct(OptimisticMintingRequest)41982_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct TBTCOptimisticMinting.OptimisticMintingRequest)", "numberOfBytes": "32", - "value": "t_struct(OptimisticMintingRequest)41994_storage" + "value": "t_struct(OptimisticMintingRequest)41982_storage" }, - "t_struct(OptimisticMintingRequest)41994_storage": { + "t_struct(OptimisticMintingRequest)41982_storage": { "encoding": "inplace", "label": "struct TBTCOptimisticMinting.OptimisticMintingRequest", "members": [ { - "astId": 41991, + "astId": 41979, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "requestedAt", "offset": 0, @@ -1576,7 +1576,7 @@ "type": "t_uint64" }, { - "astId": 41993, + "astId": 41981, "contract": "contracts/vault/TBTCVault.sol:TBTCVault", "label": "finalizedAt", "offset": 8, diff --git a/src/threshold-ts/tbtc/dapp-development-goerli-artifacts/WalletRegistry.json b/src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/WalletRegistry.json similarity index 93% rename from src/threshold-ts/tbtc/dapp-development-goerli-artifacts/WalletRegistry.json rename to src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/WalletRegistry.json index 22cb52558..5a6307924 100644 --- a/src/threshold-ts/tbtc/dapp-development-goerli-artifacts/WalletRegistry.json +++ b/src/threshold-ts/tbtc/dapp-development-sepolia-artifacts/WalletRegistry.json @@ -1,5 +1,5 @@ { - "address": "0x18930D71C7aE52beCB474A39173Def1A09b861a0", + "address": "0x9e1C45D3EFecEfabEFdAEa8EcA0397845bE47E86", "abi": [ { "inputs": [ @@ -1906,80 +1906,80 @@ "type": "function" } ], - "transactionHash": "0xc364fcb7f9cb75f060e40bbcd5345f148fd47e547f2101a4ebf5ff869c9b75b0", + "transactionHash": "0xdb31edad1c978dbf7377cbabe5e2c4053b249fdda6febea0b75d5081abeaddfd", "receipt": { "to": null, - "from": "0xfd42E065d5b128a65d752F11A1dA089f74DBf49A", - "contractAddress": "0x18930D71C7aE52beCB474A39173Def1A09b861a0", - "transactionIndex": 25, - "gasUsed": "1053731", - "logsBloom": "0x00000000000000000000000000000000400000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000800000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000800000400000000000000000000000004000000000000000020000000000000000000040000000000000400000000000200000000000000020000000200000800000000000000000000000000000000000000000200", - "blockHash": "0x8a21d383cb665db389708e87036fa4f6cdac8f87d30b9db24d4466336d7d2672", - "transactionHash": "0xc364fcb7f9cb75f060e40bbcd5345f148fd47e547f2101a4ebf5ff869c9b75b0", + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x9e1C45D3EFecEfabEFdAEa8EcA0397845bE47E86", + "transactionIndex": 39, + "gasUsed": "1054015", + "logsBloom": "0x00000000000000000000000000000000400000004000000020000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000002000000000002000000000000000800000000000000000000000000000000000000000000001000000000800000000000000000002000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040000000000000400040000000000000000000000000000000000000800000000000000000000000000000000000000000000", + "blockHash": "0xc7de7fe5e5a356ceac8586030fb5ede1c059cf2e9d59e74e564e05a4ca8a3419", + "transactionHash": "0xdb31edad1c978dbf7377cbabe5e2c4053b249fdda6febea0b75d5081abeaddfd", "logs": [ { - "transactionIndex": 25, - "blockNumber": 8367831, - "transactionHash": "0xc364fcb7f9cb75f060e40bbcd5345f148fd47e547f2101a4ebf5ff869c9b75b0", - "address": "0x18930D71C7aE52beCB474A39173Def1A09b861a0", + "transactionIndex": 39, + "blockNumber": 4648393, + "transactionHash": "0xdb31edad1c978dbf7377cbabe5e2c4053b249fdda6febea0b75d5081abeaddfd", + "address": "0x9e1C45D3EFecEfabEFdAEa8EcA0397845bE47E86", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000fb52ee94382378c515e4ec7da399d6afaf86048f" + "0x0000000000000000000000003a2fa1927154749f70d065d120618aebe52c8566" ], "data": "0x", - "logIndex": 33, - "blockHash": "0x8a21d383cb665db389708e87036fa4f6cdac8f87d30b9db24d4466336d7d2672" + "logIndex": 41, + "blockHash": "0xc7de7fe5e5a356ceac8586030fb5ede1c059cf2e9d59e74e564e05a4ca8a3419" }, { - "transactionIndex": 25, - "blockNumber": 8367831, - "transactionHash": "0xc364fcb7f9cb75f060e40bbcd5345f148fd47e547f2101a4ebf5ff869c9b75b0", - "address": "0x18930D71C7aE52beCB474A39173Def1A09b861a0", + "transactionIndex": 39, + "blockNumber": 4648393, + "transactionHash": "0xdb31edad1c978dbf7377cbabe5e2c4053b249fdda6febea0b75d5081abeaddfd", + "address": "0x9e1C45D3EFecEfabEFdAEa8EcA0397845bE47E86", "topics": [ "0x5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80" ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fd42e065d5b128a65d752f11a1da089f74dbf49a", - "logIndex": 34, - "blockHash": "0x8a21d383cb665db389708e87036fa4f6cdac8f87d30b9db24d4466336d7d2672" + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc", + "logIndex": 42, + "blockHash": "0xc7de7fe5e5a356ceac8586030fb5ede1c059cf2e9d59e74e564e05a4ca8a3419" }, { - "transactionIndex": 25, - "blockNumber": 8367831, - "transactionHash": "0xc364fcb7f9cb75f060e40bbcd5345f148fd47e547f2101a4ebf5ff869c9b75b0", - "address": "0x18930D71C7aE52beCB474A39173Def1A09b861a0", + "transactionIndex": 39, + "blockNumber": 4648393, + "transactionHash": "0xdb31edad1c978dbf7377cbabe5e2c4053b249fdda6febea0b75d5081abeaddfd", + "address": "0x9e1C45D3EFecEfabEFdAEa8EcA0397845bE47E86", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", - "logIndex": 35, - "blockHash": "0x8a21d383cb665db389708e87036fa4f6cdac8f87d30b9db24d4466336d7d2672" + "logIndex": 43, + "blockHash": "0xc7de7fe5e5a356ceac8586030fb5ede1c059cf2e9d59e74e564e05a4ca8a3419" }, { - "transactionIndex": 25, - "blockNumber": 8367831, - "transactionHash": "0xc364fcb7f9cb75f060e40bbcd5345f148fd47e547f2101a4ebf5ff869c9b75b0", - "address": "0x18930D71C7aE52beCB474A39173Def1A09b861a0", + "transactionIndex": 39, + "blockNumber": 4648393, + "transactionHash": "0xdb31edad1c978dbf7377cbabe5e2c4053b249fdda6febea0b75d5081abeaddfd", + "address": "0x9e1C45D3EFecEfabEFdAEa8EcA0397845bE47E86", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009ffffa73021c1d07081428ffc4387643006a343f", - "logIndex": 36, - "blockHash": "0x8a21d383cb665db389708e87036fa4f6cdac8f87d30b9db24d4466336d7d2672" + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dd8bf5aca0579bee7e6cd20ac7683e279a5f7d48", + "logIndex": 44, + "blockHash": "0xc7de7fe5e5a356ceac8586030fb5ede1c059cf2e9d59e74e564e05a4ca8a3419" } ], - "blockNumber": 8367831, - "cumulativeGasUsed": "6659737", + "blockNumber": 4648393, + "cumulativeGasUsed": "5143872", "status": 1, "byzantium": true }, "args": [ - "0x376C72FD0C8a59483Fc7009F1104969d98fC9a35", - "0x3b82EFE7144B62c9dfE5bf774B284F9f0F018BE3" + "0x903aa036623923Db5FBbe4aA762600e1a6a453F8", + "0x8883236e97d9BD420B622484Dbe01f1cf0a6CE17" ], "numDeployments": 1, "libraries": { - "EcdsaInactivity": "0x744896217754b53fBF84464932a429AB847F16B9" + "EcdsaInactivity": "0xa97dc308607b7D912a01f8b93468187f46A7CdF5" }, - "implementation": "0xfB52Ee94382378C515E4EC7DA399d6aFAf86048F", + "implementation": "0x3a2fa1927154749F70d065d120618Aebe52c8566", "devdoc": "Contract deployed as upgradable proxy" } diff --git a/src/threshold-ts/tbtc/index.ts b/src/threshold-ts/tbtc/index.ts index 68255ff1b..88b97cd12 100644 --- a/src/threshold-ts/tbtc/index.ts +++ b/src/threshold-ts/tbtc/index.ts @@ -32,7 +32,7 @@ import { fromSatoshiToTokenPrecision, getContract, getContractPastEvents, - getGoerliDevelopmentContracts, + getSepoliaDevelopmentContracts, getSigner, getArtifact, isPayToScriptHashTypeAddress, @@ -511,7 +511,7 @@ export class TBTC implements ITBTC { const ethereumNetwork = await ethereumNetworkFromSigner(signer) const tbtcContracts = shouldUseTestnetDevelopmentContracts - ? getGoerliDevelopmentContracts(signer) + ? getSepoliaDevelopmentContracts(signer) : await loadEthereumContracts(signer, ethereumNetwork) this._sdk = await SDK.initializeCustom(tbtcContracts, this._bitcoinClient) @@ -525,7 +525,7 @@ export class TBTC implements ITBTC { const initializeFunction = this.bitcoinNetwork === BitcoinNetwork.Mainnet ? SDK.initializeMainnet - : SDK.initializeGoerli + : SDK.initializeSepolia this._sdk = await initializeFunction(signer) diff --git a/src/threshold-ts/tokens/goerli-artifacts/NuCypherToken.json b/src/threshold-ts/tokens/dapp-development-sepolia-artifacts/NuCypherToken.json similarity index 98% rename from src/threshold-ts/tokens/goerli-artifacts/NuCypherToken.json rename to src/threshold-ts/tokens/dapp-development-sepolia-artifacts/NuCypherToken.json index aade9d8be..7efe1c16b 100644 --- a/src/threshold-ts/tokens/goerli-artifacts/NuCypherToken.json +++ b/src/threshold-ts/tokens/dapp-development-sepolia-artifacts/NuCypherToken.json @@ -1,5 +1,5 @@ { - "address": "0x26bDc8Cb2D4F55Af3B43568069b65B435bCdc32c", + "address": "0x1943A53B7E43421373f6a72c9aC7B939c197ccFc", "abi": [ { "inputs": [], @@ -473,40 +473,40 @@ "type": "function" } ], - "transactionHash": "0x3e1cac8f5c99f9a02c27293c72c2697ef1710c7e64f490e4f4b63d5f09a57408", + "transactionHash": "0x3e9ad81ccb09c705ac2dfba39cd7e41f61c8cec24fe12478c59895f1788b1049", "receipt": { "to": null, "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", - "contractAddress": "0x26bDc8Cb2D4F55Af3B43568069b65B435bCdc32c", - "transactionIndex": 18, - "gasUsed": "1257963", - "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000100000000000400000000000000000000000000000000000000000000000000000000000200000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000002000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x136fe4b6eb516db7aa92fce2b2dbf855e163baa7865c7e7a4910e0354f9c5f89", - "transactionHash": "0x3e1cac8f5c99f9a02c27293c72c2697ef1710c7e64f490e4f4b63d5f09a57408", + "contractAddress": "0x1943A53B7E43421373f6a72c9aC7B939c197ccFc", + "transactionIndex": 27, + "gasUsed": "1258345", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000080200000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000200000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x376bee0979b6065e0f38f663450b87064359fd094836d90e2336dc78b25f9357", + "transactionHash": "0x3e9ad81ccb09c705ac2dfba39cd7e41f61c8cec24fe12478c59895f1788b1049", "logs": [ { - "transactionIndex": 18, - "blockNumber": 7681410, - "transactionHash": "0x3e1cac8f5c99f9a02c27293c72c2697ef1710c7e64f490e4f4b63d5f09a57408", - "address": "0x26bDc8Cb2D4F55Af3B43568069b65B435bCdc32c", + "transactionIndex": 27, + "blockNumber": 4648086, + "transactionHash": "0x3e9ad81ccb09c705ac2dfba39cd7e41f61c8cec24fe12478c59895f1788b1049", + "address": "0x1943A53B7E43421373f6a72c9aC7B939c197ccFc", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc" ], "data": "0x", - "logIndex": 22, - "blockHash": "0x136fe4b6eb516db7aa92fce2b2dbf855e163baa7865c7e7a4910e0354f9c5f89" + "logIndex": 25, + "blockHash": "0x376bee0979b6065e0f38f663450b87064359fd094836d90e2336dc78b25f9357" } ], - "blockNumber": 7681410, - "cumulativeGasUsed": "2751267", + "blockNumber": 4648086, + "cumulativeGasUsed": "3700851", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "c42403a734f7dc0bc16cac52ab22d6ca", + "solcInputHash": "8933389a43c675e66679c9f606d83ebd", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"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\":\"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\":\"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\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"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\":[],\"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`.\"},\"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.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"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.\"},\"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.\"},\"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`.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/TestToken.sol\":\"TestToken\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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\"},\"@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\"},\"contracts/test/TestToken.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\n\\ncontract TestToken is ERC20WithPermit {\\n constructor() ERC20WithPermit(\\\"Test Token\\\", \\\"TEST\\\") {}\\n}\\n\",\"keccak256\":\"0x4ac0ce221d23ff094f6256d571e1e3f79eeb2963ddaa34ad0c7e60d03836dd07\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", "bytecode": "0x60c06040523480156200001157600080fd5b506040518060400160405280600a8152602001692a32b9ba102a37b5b2b760b11b81525060405180604001604052806004815260200163151154d560e21b8152506200006c62000066620000b260201b60201c565b620000b6565b815162000081906005906020850190620001b7565b50805162000097906006906020840190620001b7565b5046608052620000a662000106565b60a052506200033e9050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60056040516200013a91906200029a565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b828054620001c5906200025d565b90600052602060002090601f016020900481019282620001e9576000855562000234565b82601f106200020457805160ff191683800117855562000234565b8280016001018555821562000234579182015b828111156200023457825182559160200191906001019062000217565b506200024292915062000246565b5090565b5b8082111562000242576000815560010162000247565b600181811c908216806200027257607f821691505b602082108114156200029457634e487b7160e01b600052602260045260246000fd5b50919050565b600080835481600182811c915080831680620002b757607f831692505b6020808410821415620002d857634e487b7160e01b86526022600452602486fd5b818015620002ef5760018114620003015762000330565b60ff1986168952848901965062000330565b60008a81526020902060005b86811015620003285781548b8201529085019083016200030d565b505084890196505b509498975050505050505050565b60805160a05161145262000372600039600081816102a301526104b201526000818161022e015261048901526114526000f3fe608060405234801561001057600080fd5b50600436106101125760003560e01c806306fdde0314610117578063095ea7b31461013557806318160ddd1461015857806323b872dd1461016f57806330adf81f14610182578063313ce567146101975780633644e515146101b157806340c10f19146101b957806342966c68146101ce57806370a08231146101e157806370ae92d214610201578063715018a614610221578063771da5c51461022957806379cc6790146102505780638da5cb5b1461026357806395d89b4114610283578063a9059cbb1461028b578063b4f94b2e1461029e578063cae9ca51146102c5578063d505accf146102d8578063dd62ed3e146102eb578063f2fde38b14610316575b600080fd5b61011f610329565b60405161012c9190610fe4565b60405180910390f35b610148610143366004611013565b6103b7565b604051901515815260200161012c565b61016160045481565b60405190815260200161012c565b61014861017d36600461103d565b6103cd565b6101616000805160206113fd83398151915281565b61019f601281565b60405160ff909116815260200161012c565b610161610485565b6101cc6101c7366004611013565b6104e1565b005b6101cc6101dc366004611079565b6105d8565b6101616101ef366004611092565b60016020526000908152604090205481565b61016161020f366004611092565b60036020526000908152604090205481565b6101cc6105e5565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101cc61025e366004611013565b610620565b61026b6106bb565b6040516001600160a01b03909116815260200161012c565b61011f6106ca565b610148610299366004611013565b6106d7565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101486102d33660046110c3565b6106e4565b6101cc6102e636600461118d565b61076c565b6101616102f9366004611200565b600260209081526000928352604080842090915290825290205481565b6101cc610324366004611092565b610a2a565b6005805461033690611233565b80601f016020809104026020016040519081016040528092919081815260200182805461036290611233565b80156103af5780601f10610384576101008083540402835291602001916103af565b820191906000526020600020905b81548152906001019060200180831161039257829003601f168201915b505050505081565b60006103c4338484610ac7565b50600192915050565b6001600160a01b0383166000908152600260209081526040808320338452909152812054600019811461046d57828110156104595760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636044820152606560f81b60648201526084015b60405180910390fd5b61046d85336104688685611284565b610ac7565b610478858585610bd3565b60019150505b9392505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614156104d457507f000000000000000000000000000000000000000000000000000000000000000090565b6104dc610dc8565b905090565b336104ea6106bb565b6001600160a01b0316146105105760405162461bcd60e51b81526004016104509061129b565b6001600160a01b0382166105615760405162461bcd60e51b81526020600482015260186024820152774d696e7420746f20746865207a65726f206164647265737360401b6044820152606401610450565b806004600082825461057391906112d0565b90915550506001600160a01b038216600090815260016020526040812080548392906105a09084906112d0565b90915550506040518181526001600160a01b038316906000906000805160206113dd8339815191529060200160405180910390a35050565b6105e23382610e77565b50565b336105ee6106bb565b6001600160a01b0316146106145760405162461bcd60e51b81526004016104509061129b565b61061e6000610f47565b565b6001600160a01b038216600090815260026020908152604080832033845290915290205460001981146106ac578181101561069d5760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e63650000006044820152606401610450565b6106ac83336104688585611284565b6106b68383610e77565b505050565b6000546001600160a01b031690565b6006805461033690611233565b60006103c4338484610bd3565b60006106f084846103b7565b1561076257604051638f4ffcb160e01b81526001600160a01b03851690638f4ffcb1906107279033908790309088906004016112e8565b600060405180830381600087803b15801561074157600080fd5b505af1158015610755573d6000803e3d6000fd5b505050506001905061047e565b5060009392505050565b428410156107b15760405162461bcd60e51b815260206004820152601260248201527114195c9b5a5cdcda5bdb88195e1c1a5c995960721b6044820152606401610450565b6fa2a8918ca85bafe22016d0b997e4df60600160ff1b038111156108155760405162461bcd60e51b815260206004820152601b60248201527a496e76616c6964207369676e6174757265202773272076616c756560281b6044820152606401610450565b8260ff16601b148061082a57508260ff16601c145b6108745760405162461bcd60e51b815260206004820152601b60248201527a496e76616c6964207369676e6174757265202776272076616c756560281b6044820152606401610450565b600061087e610485565b6001600160a01b038916600090815260036020526040812080546000805160206113fd833981519152928c928c928c929091906108ba83611325565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e0016040516020818303038152906040528051906020012060405160200161093392919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa15801561099e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906109d45750886001600160a01b0316816001600160a01b0316145b610a145760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b6044820152606401610450565b610a1f898989610ac7565b505050505050505050565b33610a336106bb565b6001600160a01b031614610a595760405162461bcd60e51b81526004016104509061129b565b6001600160a01b038116610abe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610450565b6105e281610f47565b6001600160a01b038316610b1d5760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f20616464726573730000006044820152606401610450565b6001600160a01b038216610b715760405162461bcd60e51b815260206004820152601b60248201527a417070726f766520746f20746865207a65726f206164647265737360281b6044820152606401610450565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b038316610c295760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f206164647265737300006044820152606401610450565b6001600160a01b038216610c7e5760405162461bcd60e51b815260206004820152601c60248201527b5472616e7366657220746f20746865207a65726f206164647265737360201b6044820152606401610450565b6001600160a01b038216301415610cd75760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e20616464726573730000006044820152606401610450565b6001600160a01b03831660009081526001602052604090205481811015610d405760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e6365006044820152606401610450565b610d4a8282611284565b6001600160a01b038086166000908152600160205260408082209390935590851681529081208054849290610d809084906112d0565b92505081905550826001600160a01b0316846001600160a01b03166000805160206113dd83398151915284604051610dba91815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051610dfa9190611340565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b03821660009081526001602052604090205481811015610ede5760405162461bcd60e51b815260206004820152601b60248201527a4275726e20616d6f756e7420657863656564732062616c616e636560281b6044820152606401610450565b610ee88282611284565b6001600160a01b03841660009081526001602052604081209190915560048054849290610f16908490611284565b90915550506040518281526000906001600160a01b038516906000805160206113dd83398151915290602001610bc6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000815180845260005b81811015610fbd57602081850181015186830182015201610fa1565b81811115610fcf576000602083870101525b50601f01601f19169290920160200192915050565b60208152600061047e6020830184610f97565b80356001600160a01b038116811461100e57600080fd5b919050565b6000806040838503121561102657600080fd5b61102f83610ff7565b946020939093013593505050565b60008060006060848603121561105257600080fd5b61105b84610ff7565b925061106960208501610ff7565b9150604084013590509250925092565b60006020828403121561108b57600080fd5b5035919050565b6000602082840312156110a457600080fd5b61047e82610ff7565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156110d857600080fd5b6110e184610ff7565b92506020840135915060408401356001600160401b038082111561110457600080fd5b818601915086601f83011261111857600080fd5b81358181111561112a5761112a6110ad565b604051601f8201601f19908116603f01168101908382118183101715611152576111526110ad565b8160405282815289602084870101111561116b57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a0312156111a857600080fd5b6111b188610ff7565b96506111bf60208901610ff7565b95506040880135945060608801359350608088013560ff811681146111e357600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561121357600080fd5b61121c83610ff7565b915061122a60208401610ff7565b90509250929050565b600181811c9082168061124757607f821691505b6020821081141561126857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000828210156112965761129661126e565b500390565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156112e3576112e361126e565b500190565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061131b90830184610f97565b9695505050505050565b60006000198214156113395761133961126e565b5060010190565b600080835481600182811c91508083168061135c57607f831692505b602080841082141561137c57634e487b7160e01b86526022600452602486fd5b81801561139057600181146113a1576113ce565b60ff198616895284890196506113ce565b60008a81526020902060005b868110156113c65781548b8201529085019083016113ad565b505084890196505b50949897505050505050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9a264697066735822122047c32e1d9a7b0fc2ebfc1d9640afe15da74720b8dcecc5347a0f70c5543ef46064736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101125760003560e01c806306fdde0314610117578063095ea7b31461013557806318160ddd1461015857806323b872dd1461016f57806330adf81f14610182578063313ce567146101975780633644e515146101b157806340c10f19146101b957806342966c68146101ce57806370a08231146101e157806370ae92d214610201578063715018a614610221578063771da5c51461022957806379cc6790146102505780638da5cb5b1461026357806395d89b4114610283578063a9059cbb1461028b578063b4f94b2e1461029e578063cae9ca51146102c5578063d505accf146102d8578063dd62ed3e146102eb578063f2fde38b14610316575b600080fd5b61011f610329565b60405161012c9190610fe4565b60405180910390f35b610148610143366004611013565b6103b7565b604051901515815260200161012c565b61016160045481565b60405190815260200161012c565b61014861017d36600461103d565b6103cd565b6101616000805160206113fd83398151915281565b61019f601281565b60405160ff909116815260200161012c565b610161610485565b6101cc6101c7366004611013565b6104e1565b005b6101cc6101dc366004611079565b6105d8565b6101616101ef366004611092565b60016020526000908152604090205481565b61016161020f366004611092565b60036020526000908152604090205481565b6101cc6105e5565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101cc61025e366004611013565b610620565b61026b6106bb565b6040516001600160a01b03909116815260200161012c565b61011f6106ca565b610148610299366004611013565b6106d7565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101486102d33660046110c3565b6106e4565b6101cc6102e636600461118d565b61076c565b6101616102f9366004611200565b600260209081526000928352604080842090915290825290205481565b6101cc610324366004611092565b610a2a565b6005805461033690611233565b80601f016020809104026020016040519081016040528092919081815260200182805461036290611233565b80156103af5780601f10610384576101008083540402835291602001916103af565b820191906000526020600020905b81548152906001019060200180831161039257829003601f168201915b505050505081565b60006103c4338484610ac7565b50600192915050565b6001600160a01b0383166000908152600260209081526040808320338452909152812054600019811461046d57828110156104595760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636044820152606560f81b60648201526084015b60405180910390fd5b61046d85336104688685611284565b610ac7565b610478858585610bd3565b60019150505b9392505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614156104d457507f000000000000000000000000000000000000000000000000000000000000000090565b6104dc610dc8565b905090565b336104ea6106bb565b6001600160a01b0316146105105760405162461bcd60e51b81526004016104509061129b565b6001600160a01b0382166105615760405162461bcd60e51b81526020600482015260186024820152774d696e7420746f20746865207a65726f206164647265737360401b6044820152606401610450565b806004600082825461057391906112d0565b90915550506001600160a01b038216600090815260016020526040812080548392906105a09084906112d0565b90915550506040518181526001600160a01b038316906000906000805160206113dd8339815191529060200160405180910390a35050565b6105e23382610e77565b50565b336105ee6106bb565b6001600160a01b0316146106145760405162461bcd60e51b81526004016104509061129b565b61061e6000610f47565b565b6001600160a01b038216600090815260026020908152604080832033845290915290205460001981146106ac578181101561069d5760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e63650000006044820152606401610450565b6106ac83336104688585611284565b6106b68383610e77565b505050565b6000546001600160a01b031690565b6006805461033690611233565b60006103c4338484610bd3565b60006106f084846103b7565b1561076257604051638f4ffcb160e01b81526001600160a01b03851690638f4ffcb1906107279033908790309088906004016112e8565b600060405180830381600087803b15801561074157600080fd5b505af1158015610755573d6000803e3d6000fd5b505050506001905061047e565b5060009392505050565b428410156107b15760405162461bcd60e51b815260206004820152601260248201527114195c9b5a5cdcda5bdb88195e1c1a5c995960721b6044820152606401610450565b6fa2a8918ca85bafe22016d0b997e4df60600160ff1b038111156108155760405162461bcd60e51b815260206004820152601b60248201527a496e76616c6964207369676e6174757265202773272076616c756560281b6044820152606401610450565b8260ff16601b148061082a57508260ff16601c145b6108745760405162461bcd60e51b815260206004820152601b60248201527a496e76616c6964207369676e6174757265202776272076616c756560281b6044820152606401610450565b600061087e610485565b6001600160a01b038916600090815260036020526040812080546000805160206113fd833981519152928c928c928c929091906108ba83611325565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e0016040516020818303038152906040528051906020012060405160200161093392919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa15801561099e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906109d45750886001600160a01b0316816001600160a01b0316145b610a145760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b6044820152606401610450565b610a1f898989610ac7565b505050505050505050565b33610a336106bb565b6001600160a01b031614610a595760405162461bcd60e51b81526004016104509061129b565b6001600160a01b038116610abe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610450565b6105e281610f47565b6001600160a01b038316610b1d5760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f20616464726573730000006044820152606401610450565b6001600160a01b038216610b715760405162461bcd60e51b815260206004820152601b60248201527a417070726f766520746f20746865207a65726f206164647265737360281b6044820152606401610450565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b038316610c295760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f206164647265737300006044820152606401610450565b6001600160a01b038216610c7e5760405162461bcd60e51b815260206004820152601c60248201527b5472616e7366657220746f20746865207a65726f206164647265737360201b6044820152606401610450565b6001600160a01b038216301415610cd75760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e20616464726573730000006044820152606401610450565b6001600160a01b03831660009081526001602052604090205481811015610d405760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e6365006044820152606401610450565b610d4a8282611284565b6001600160a01b038086166000908152600160205260408082209390935590851681529081208054849290610d809084906112d0565b92505081905550826001600160a01b0316846001600160a01b03166000805160206113dd83398151915284604051610dba91815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051610dfa9190611340565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b03821660009081526001602052604090205481811015610ede5760405162461bcd60e51b815260206004820152601b60248201527a4275726e20616d6f756e7420657863656564732062616c616e636560281b6044820152606401610450565b610ee88282611284565b6001600160a01b03841660009081526001602052604081209190915560048054849290610f16908490611284565b90915550506040518281526000906001600160a01b038516906000805160206113dd83398151915290602001610bc6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000815180845260005b81811015610fbd57602081850181015186830182015201610fa1565b81811115610fcf576000602083870101525b50601f01601f19169290920160200192915050565b60208152600061047e6020830184610f97565b80356001600160a01b038116811461100e57600080fd5b919050565b6000806040838503121561102657600080fd5b61102f83610ff7565b946020939093013593505050565b60008060006060848603121561105257600080fd5b61105b84610ff7565b925061106960208501610ff7565b9150604084013590509250925092565b60006020828403121561108b57600080fd5b5035919050565b6000602082840312156110a457600080fd5b61047e82610ff7565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156110d857600080fd5b6110e184610ff7565b92506020840135915060408401356001600160401b038082111561110457600080fd5b818601915086601f83011261111857600080fd5b81358181111561112a5761112a6110ad565b604051601f8201601f19908116603f01168101908382118183101715611152576111526110ad565b8160405282815289602084870101111561116b57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a0312156111a857600080fd5b6111b188610ff7565b96506111bf60208901610ff7565b95506040880135945060608801359350608088013560ff811681146111e357600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561121357600080fd5b61121c83610ff7565b915061122a60208401610ff7565b90509250929050565b600181811c9082168061124757607f821691505b6020821081141561126857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000828210156112965761129661126e565b500390565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156112e3576112e361126e565b500190565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061131b90830184610f97565b9695505050505050565b60006000198214156113395761133961126e565b5060010190565b600080835481600182811c91508083168061135c57607f831692505b602080841082141561137c57634e487b7160e01b86526022600452602486fd5b81801561139057600181146113a1576113ce565b60ff198616895284890196506113ce565b60008a81526020902060005b868110156113c65781548b8201529085019083016113ad565b505084890196505b50949897505050505050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9a264697066735822122047c32e1d9a7b0fc2ebfc1d9640afe15da74720b8dcecc5347a0f70c5543ef46064736f6c63430008090033", diff --git a/src/threshold-ts/tokens/dapp-development-goerli-artifacts/NuCypherToken.json b/src/threshold-ts/tokens/sepolia-artifacts/NuCypherToken.json similarity index 98% rename from src/threshold-ts/tokens/dapp-development-goerli-artifacts/NuCypherToken.json rename to src/threshold-ts/tokens/sepolia-artifacts/NuCypherToken.json index deeffcac0..e7965c363 100644 --- a/src/threshold-ts/tokens/dapp-development-goerli-artifacts/NuCypherToken.json +++ b/src/threshold-ts/tokens/sepolia-artifacts/NuCypherToken.json @@ -1,5 +1,5 @@ { - "address": "0x0aCB1570e4a17C8A4d41A29906E2e2FD4670148c", + "address": "0x805ff4312f99f01F8CC4138858D62c10f35eA4DF", "abi": [ { "inputs": [], @@ -473,40 +473,40 @@ "type": "function" } ], - "transactionHash": "0x24db7beab8cca5c599b677ce36f162dd6daa91c6b7eee4a9b64639f3ef9b9f60", + "transactionHash": "0x3a9c255f4a4c911c371596d652bed29f45fabb009d122138701eb170ee856e0e", "receipt": { "to": null, - "from": "0xfd42E065d5b128a65d752F11A1dA089f74DBf49A", - "contractAddress": "0x0aCB1570e4a17C8A4d41A29906E2e2FD4670148c", - "transactionIndex": 18, - "gasUsed": "1257963", - "logsBloom": "0x00000000000000000000000000000000002000000000000000800000000000000000000000000010000004000000000000000000000000000000000000000000008000000000000010000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xdeca7e855ecd0e30e0bec37417bcb126adfdd6b04130b209510cc777f1dbf2aa", - "transactionHash": "0x24db7beab8cca5c599b677ce36f162dd6daa91c6b7eee4a9b64639f3ef9b9f60", + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x805ff4312f99f01F8CC4138858D62c10f35eA4DF", + "transactionIndex": 227, + "gasUsed": "1258345", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000200000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000020000000000000000000000000000000000020000000000000000000000000000000000020000000000000000000000000000000", + "blockHash": "0x4816351dc0e996ae8408b1550f21f7e014a30b4cb72b1ad27f8623995dcb7be4", + "transactionHash": "0x3a9c255f4a4c911c371596d652bed29f45fabb009d122138701eb170ee856e0e", "logs": [ { - "transactionIndex": 18, - "blockNumber": 8259798, - "transactionHash": "0x24db7beab8cca5c599b677ce36f162dd6daa91c6b7eee4a9b64639f3ef9b9f60", - "address": "0x0aCB1570e4a17C8A4d41A29906E2e2FD4670148c", + "transactionIndex": 227, + "blockNumber": 4320492, + "transactionHash": "0x3a9c255f4a4c911c371596d652bed29f45fabb009d122138701eb170ee856e0e", + "address": "0x805ff4312f99f01F8CC4138858D62c10f35eA4DF", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000fd42e065d5b128a65d752f11a1da089f74dbf49a" + "0x00000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc" ], "data": "0x", - "logIndex": 34, - "blockHash": "0xdeca7e855ecd0e30e0bec37417bcb126adfdd6b04130b209510cc777f1dbf2aa" + "logIndex": 267, + "blockHash": "0x4816351dc0e996ae8408b1550f21f7e014a30b4cb72b1ad27f8623995dcb7be4" } ], - "blockNumber": 8259798, - "cumulativeGasUsed": "3739735", + "blockNumber": 4320492, + "cumulativeGasUsed": "13769541", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "fa4158cdf7ba30d8892d97237acdb9a6", + "solcInputHash": "3e22d437f05c26959c9fff55c53befb8", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"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\":\"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\":\"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\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"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\":[],\"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`.\"},\"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.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"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.\"},\"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.\"},\"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`.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/TestToken.sol\":\"TestToken\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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\"},\"@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\"},\"contracts/test/TestToken.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\n\\ncontract TestToken is ERC20WithPermit {\\n constructor() ERC20WithPermit(\\\"Test Token\\\", \\\"TEST\\\") {}\\n}\\n\",\"keccak256\":\"0x4ac0ce221d23ff094f6256d571e1e3f79eeb2963ddaa34ad0c7e60d03836dd07\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", "bytecode": "0x60c06040523480156200001157600080fd5b506040518060400160405280600a8152602001692a32b9ba102a37b5b2b760b11b81525060405180604001604052806004815260200163151154d560e21b8152506200006c62000066620000b260201b60201c565b620000b6565b815162000081906005906020850190620001b7565b50805162000097906006906020840190620001b7565b5046608052620000a662000106565b60a052506200033e9050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60056040516200013a91906200029a565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b828054620001c5906200025d565b90600052602060002090601f016020900481019282620001e9576000855562000234565b82601f106200020457805160ff191683800117855562000234565b8280016001018555821562000234579182015b828111156200023457825182559160200191906001019062000217565b506200024292915062000246565b5090565b5b8082111562000242576000815560010162000247565b600181811c908216806200027257607f821691505b602082108114156200029457634e487b7160e01b600052602260045260246000fd5b50919050565b600080835481600182811c915080831680620002b757607f831692505b6020808410821415620002d857634e487b7160e01b86526022600452602486fd5b818015620002ef5760018114620003015762000330565b60ff1986168952848901965062000330565b60008a81526020902060005b86811015620003285781548b8201529085019083016200030d565b505084890196505b509498975050505050505050565b60805160a05161145262000372600039600081816102a301526104b201526000818161022e015261048901526114526000f3fe608060405234801561001057600080fd5b50600436106101125760003560e01c806306fdde0314610117578063095ea7b31461013557806318160ddd1461015857806323b872dd1461016f57806330adf81f14610182578063313ce567146101975780633644e515146101b157806340c10f19146101b957806342966c68146101ce57806370a08231146101e157806370ae92d214610201578063715018a614610221578063771da5c51461022957806379cc6790146102505780638da5cb5b1461026357806395d89b4114610283578063a9059cbb1461028b578063b4f94b2e1461029e578063cae9ca51146102c5578063d505accf146102d8578063dd62ed3e146102eb578063f2fde38b14610316575b600080fd5b61011f610329565b60405161012c9190610fe4565b60405180910390f35b610148610143366004611013565b6103b7565b604051901515815260200161012c565b61016160045481565b60405190815260200161012c565b61014861017d36600461103d565b6103cd565b6101616000805160206113fd83398151915281565b61019f601281565b60405160ff909116815260200161012c565b610161610485565b6101cc6101c7366004611013565b6104e1565b005b6101cc6101dc366004611079565b6105d8565b6101616101ef366004611092565b60016020526000908152604090205481565b61016161020f366004611092565b60036020526000908152604090205481565b6101cc6105e5565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101cc61025e366004611013565b610620565b61026b6106bb565b6040516001600160a01b03909116815260200161012c565b61011f6106ca565b610148610299366004611013565b6106d7565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101486102d33660046110c3565b6106e4565b6101cc6102e636600461118d565b61076c565b6101616102f9366004611200565b600260209081526000928352604080842090915290825290205481565b6101cc610324366004611092565b610a2a565b6005805461033690611233565b80601f016020809104026020016040519081016040528092919081815260200182805461036290611233565b80156103af5780601f10610384576101008083540402835291602001916103af565b820191906000526020600020905b81548152906001019060200180831161039257829003601f168201915b505050505081565b60006103c4338484610ac7565b50600192915050565b6001600160a01b0383166000908152600260209081526040808320338452909152812054600019811461046d57828110156104595760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636044820152606560f81b60648201526084015b60405180910390fd5b61046d85336104688685611284565b610ac7565b610478858585610bd3565b60019150505b9392505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614156104d457507f000000000000000000000000000000000000000000000000000000000000000090565b6104dc610dc8565b905090565b336104ea6106bb565b6001600160a01b0316146105105760405162461bcd60e51b81526004016104509061129b565b6001600160a01b0382166105615760405162461bcd60e51b81526020600482015260186024820152774d696e7420746f20746865207a65726f206164647265737360401b6044820152606401610450565b806004600082825461057391906112d0565b90915550506001600160a01b038216600090815260016020526040812080548392906105a09084906112d0565b90915550506040518181526001600160a01b038316906000906000805160206113dd8339815191529060200160405180910390a35050565b6105e23382610e77565b50565b336105ee6106bb565b6001600160a01b0316146106145760405162461bcd60e51b81526004016104509061129b565b61061e6000610f47565b565b6001600160a01b038216600090815260026020908152604080832033845290915290205460001981146106ac578181101561069d5760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e63650000006044820152606401610450565b6106ac83336104688585611284565b6106b68383610e77565b505050565b6000546001600160a01b031690565b6006805461033690611233565b60006103c4338484610bd3565b60006106f084846103b7565b1561076257604051638f4ffcb160e01b81526001600160a01b03851690638f4ffcb1906107279033908790309088906004016112e8565b600060405180830381600087803b15801561074157600080fd5b505af1158015610755573d6000803e3d6000fd5b505050506001905061047e565b5060009392505050565b428410156107b15760405162461bcd60e51b815260206004820152601260248201527114195c9b5a5cdcda5bdb88195e1c1a5c995960721b6044820152606401610450565b6fa2a8918ca85bafe22016d0b997e4df60600160ff1b038111156108155760405162461bcd60e51b815260206004820152601b60248201527a496e76616c6964207369676e6174757265202773272076616c756560281b6044820152606401610450565b8260ff16601b148061082a57508260ff16601c145b6108745760405162461bcd60e51b815260206004820152601b60248201527a496e76616c6964207369676e6174757265202776272076616c756560281b6044820152606401610450565b600061087e610485565b6001600160a01b038916600090815260036020526040812080546000805160206113fd833981519152928c928c928c929091906108ba83611325565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e0016040516020818303038152906040528051906020012060405160200161093392919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa15801561099e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906109d45750886001600160a01b0316816001600160a01b0316145b610a145760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b6044820152606401610450565b610a1f898989610ac7565b505050505050505050565b33610a336106bb565b6001600160a01b031614610a595760405162461bcd60e51b81526004016104509061129b565b6001600160a01b038116610abe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610450565b6105e281610f47565b6001600160a01b038316610b1d5760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f20616464726573730000006044820152606401610450565b6001600160a01b038216610b715760405162461bcd60e51b815260206004820152601b60248201527a417070726f766520746f20746865207a65726f206164647265737360281b6044820152606401610450565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b038316610c295760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f206164647265737300006044820152606401610450565b6001600160a01b038216610c7e5760405162461bcd60e51b815260206004820152601c60248201527b5472616e7366657220746f20746865207a65726f206164647265737360201b6044820152606401610450565b6001600160a01b038216301415610cd75760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e20616464726573730000006044820152606401610450565b6001600160a01b03831660009081526001602052604090205481811015610d405760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e6365006044820152606401610450565b610d4a8282611284565b6001600160a01b038086166000908152600160205260408082209390935590851681529081208054849290610d809084906112d0565b92505081905550826001600160a01b0316846001600160a01b03166000805160206113dd83398151915284604051610dba91815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051610dfa9190611340565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b03821660009081526001602052604090205481811015610ede5760405162461bcd60e51b815260206004820152601b60248201527a4275726e20616d6f756e7420657863656564732062616c616e636560281b6044820152606401610450565b610ee88282611284565b6001600160a01b03841660009081526001602052604081209190915560048054849290610f16908490611284565b90915550506040518281526000906001600160a01b038516906000805160206113dd83398151915290602001610bc6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000815180845260005b81811015610fbd57602081850181015186830182015201610fa1565b81811115610fcf576000602083870101525b50601f01601f19169290920160200192915050565b60208152600061047e6020830184610f97565b80356001600160a01b038116811461100e57600080fd5b919050565b6000806040838503121561102657600080fd5b61102f83610ff7565b946020939093013593505050565b60008060006060848603121561105257600080fd5b61105b84610ff7565b925061106960208501610ff7565b9150604084013590509250925092565b60006020828403121561108b57600080fd5b5035919050565b6000602082840312156110a457600080fd5b61047e82610ff7565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156110d857600080fd5b6110e184610ff7565b92506020840135915060408401356001600160401b038082111561110457600080fd5b818601915086601f83011261111857600080fd5b81358181111561112a5761112a6110ad565b604051601f8201601f19908116603f01168101908382118183101715611152576111526110ad565b8160405282815289602084870101111561116b57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a0312156111a857600080fd5b6111b188610ff7565b96506111bf60208901610ff7565b95506040880135945060608801359350608088013560ff811681146111e357600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561121357600080fd5b61121c83610ff7565b915061122a60208401610ff7565b90509250929050565b600181811c9082168061124757607f821691505b6020821081141561126857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000828210156112965761129661126e565b500390565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156112e3576112e361126e565b500190565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061131b90830184610f97565b9695505050505050565b60006000198214156113395761133961126e565b5060010190565b600080835481600182811c91508083168061135c57607f831692505b602080841082141561137c57634e487b7160e01b86526022600452602486fd5b81801561139057600181146113a1576113ce565b60ff198616895284890196506113ce565b60008a81526020902060005b868110156113c65781548b8201529085019083016113ad565b505084890196505b50949897505050505050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9a264697066735822122047c32e1d9a7b0fc2ebfc1d9640afe15da74720b8dcecc5347a0f70c5543ef46064736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101125760003560e01c806306fdde0314610117578063095ea7b31461013557806318160ddd1461015857806323b872dd1461016f57806330adf81f14610182578063313ce567146101975780633644e515146101b157806340c10f19146101b957806342966c68146101ce57806370a08231146101e157806370ae92d214610201578063715018a614610221578063771da5c51461022957806379cc6790146102505780638da5cb5b1461026357806395d89b4114610283578063a9059cbb1461028b578063b4f94b2e1461029e578063cae9ca51146102c5578063d505accf146102d8578063dd62ed3e146102eb578063f2fde38b14610316575b600080fd5b61011f610329565b60405161012c9190610fe4565b60405180910390f35b610148610143366004611013565b6103b7565b604051901515815260200161012c565b61016160045481565b60405190815260200161012c565b61014861017d36600461103d565b6103cd565b6101616000805160206113fd83398151915281565b61019f601281565b60405160ff909116815260200161012c565b610161610485565b6101cc6101c7366004611013565b6104e1565b005b6101cc6101dc366004611079565b6105d8565b6101616101ef366004611092565b60016020526000908152604090205481565b61016161020f366004611092565b60036020526000908152604090205481565b6101cc6105e5565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101cc61025e366004611013565b610620565b61026b6106bb565b6040516001600160a01b03909116815260200161012c565b61011f6106ca565b610148610299366004611013565b6106d7565b6101617f000000000000000000000000000000000000000000000000000000000000000081565b6101486102d33660046110c3565b6106e4565b6101cc6102e636600461118d565b61076c565b6101616102f9366004611200565b600260209081526000928352604080842090915290825290205481565b6101cc610324366004611092565b610a2a565b6005805461033690611233565b80601f016020809104026020016040519081016040528092919081815260200182805461036290611233565b80156103af5780601f10610384576101008083540402835291602001916103af565b820191906000526020600020905b81548152906001019060200180831161039257829003601f168201915b505050505081565b60006103c4338484610ac7565b50600192915050565b6001600160a01b0383166000908152600260209081526040808320338452909152812054600019811461046d57828110156104595760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636044820152606560f81b60648201526084015b60405180910390fd5b61046d85336104688685611284565b610ac7565b610478858585610bd3565b60019150505b9392505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614156104d457507f000000000000000000000000000000000000000000000000000000000000000090565b6104dc610dc8565b905090565b336104ea6106bb565b6001600160a01b0316146105105760405162461bcd60e51b81526004016104509061129b565b6001600160a01b0382166105615760405162461bcd60e51b81526020600482015260186024820152774d696e7420746f20746865207a65726f206164647265737360401b6044820152606401610450565b806004600082825461057391906112d0565b90915550506001600160a01b038216600090815260016020526040812080548392906105a09084906112d0565b90915550506040518181526001600160a01b038316906000906000805160206113dd8339815191529060200160405180910390a35050565b6105e23382610e77565b50565b336105ee6106bb565b6001600160a01b0316146106145760405162461bcd60e51b81526004016104509061129b565b61061e6000610f47565b565b6001600160a01b038216600090815260026020908152604080832033845290915290205460001981146106ac578181101561069d5760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e63650000006044820152606401610450565b6106ac83336104688585611284565b6106b68383610e77565b505050565b6000546001600160a01b031690565b6006805461033690611233565b60006103c4338484610bd3565b60006106f084846103b7565b1561076257604051638f4ffcb160e01b81526001600160a01b03851690638f4ffcb1906107279033908790309088906004016112e8565b600060405180830381600087803b15801561074157600080fd5b505af1158015610755573d6000803e3d6000fd5b505050506001905061047e565b5060009392505050565b428410156107b15760405162461bcd60e51b815260206004820152601260248201527114195c9b5a5cdcda5bdb88195e1c1a5c995960721b6044820152606401610450565b6fa2a8918ca85bafe22016d0b997e4df60600160ff1b038111156108155760405162461bcd60e51b815260206004820152601b60248201527a496e76616c6964207369676e6174757265202773272076616c756560281b6044820152606401610450565b8260ff16601b148061082a57508260ff16601c145b6108745760405162461bcd60e51b815260206004820152601b60248201527a496e76616c6964207369676e6174757265202776272076616c756560281b6044820152606401610450565b600061087e610485565b6001600160a01b038916600090815260036020526040812080546000805160206113fd833981519152928c928c928c929091906108ba83611325565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e0016040516020818303038152906040528051906020012060405160200161093392919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa15801561099e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906109d45750886001600160a01b0316816001600160a01b0316145b610a145760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b6044820152606401610450565b610a1f898989610ac7565b505050505050505050565b33610a336106bb565b6001600160a01b031614610a595760405162461bcd60e51b81526004016104509061129b565b6001600160a01b038116610abe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610450565b6105e281610f47565b6001600160a01b038316610b1d5760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f20616464726573730000006044820152606401610450565b6001600160a01b038216610b715760405162461bcd60e51b815260206004820152601b60248201527a417070726f766520746f20746865207a65726f206164647265737360281b6044820152606401610450565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b038316610c295760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f206164647265737300006044820152606401610450565b6001600160a01b038216610c7e5760405162461bcd60e51b815260206004820152601c60248201527b5472616e7366657220746f20746865207a65726f206164647265737360201b6044820152606401610450565b6001600160a01b038216301415610cd75760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e20616464726573730000006044820152606401610450565b6001600160a01b03831660009081526001602052604090205481811015610d405760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e6365006044820152606401610450565b610d4a8282611284565b6001600160a01b038086166000908152600160205260408082209390935590851681529081208054849290610d809084906112d0565b92505081905550826001600160a01b0316846001600160a01b03166000805160206113dd83398151915284604051610dba91815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051610dfa9190611340565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b03821660009081526001602052604090205481811015610ede5760405162461bcd60e51b815260206004820152601b60248201527a4275726e20616d6f756e7420657863656564732062616c616e636560281b6044820152606401610450565b610ee88282611284565b6001600160a01b03841660009081526001602052604081209190915560048054849290610f16908490611284565b90915550506040518281526000906001600160a01b038516906000805160206113dd83398151915290602001610bc6565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000815180845260005b81811015610fbd57602081850181015186830182015201610fa1565b81811115610fcf576000602083870101525b50601f01601f19169290920160200192915050565b60208152600061047e6020830184610f97565b80356001600160a01b038116811461100e57600080fd5b919050565b6000806040838503121561102657600080fd5b61102f83610ff7565b946020939093013593505050565b60008060006060848603121561105257600080fd5b61105b84610ff7565b925061106960208501610ff7565b9150604084013590509250925092565b60006020828403121561108b57600080fd5b5035919050565b6000602082840312156110a457600080fd5b61047e82610ff7565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156110d857600080fd5b6110e184610ff7565b92506020840135915060408401356001600160401b038082111561110457600080fd5b818601915086601f83011261111857600080fd5b81358181111561112a5761112a6110ad565b604051601f8201601f19908116603f01168101908382118183101715611152576111526110ad565b8160405282815289602084870101111561116b57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a0312156111a857600080fd5b6111b188610ff7565b96506111bf60208901610ff7565b95506040880135945060608801359350608088013560ff811681146111e357600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561121357600080fd5b61121c83610ff7565b915061122a60208401610ff7565b90509250929050565b600181811c9082168061124757607f821691505b6020821081141561126857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000828210156112965761129661126e565b500390565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156112e3576112e361126e565b500190565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061131b90830184610f97565b9695505050505050565b60006000198214156113395761133961126e565b5060010190565b600080835481600182811c91508083168061135c57607f831692505b602080841082141561137c57634e487b7160e01b86526022600452602486fd5b81801561139057600181146113a1576113ce565b60ff198616895284890196506113ce565b60008a81526020902060005b868110156113c65781548b8201529085019083016113ad565b505084890196505b50949897505050505050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9a264697066735822122047c32e1d9a7b0fc2ebfc1d9640afe15da74720b8dcecc5347a0f70c5543ef46064736f6c63430008090033", diff --git a/src/threshold-ts/utils/contract.ts b/src/threshold-ts/utils/contract.ts index 708b61ee1..ddc4d2133 100644 --- a/src/threshold-ts/utils/contract.ts +++ b/src/threshold-ts/utils/contract.ts @@ -18,23 +18,23 @@ import VendingMachineKeepMainnet from "../vending-machine/mainnet-artifacts/Vend import VendingMachineNuCypherMainnet from "../vending-machine/mainnet-artifacts/VendingMachineNuCypher.json" import WalletRegistryArtifactMainnet from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/mainnet/WalletRegistry.json" -import BridgeArtifactGoerli from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/goerli/Bridge.json" -import NuCypherStakingEscrowGoerli from "../staking/goerli-artifacts/NuCypherStakingEscrow.json" -import NuCypherTokenGoerli from "../tokens/goerli-artifacts/NuCypherToken.json" -import TbtcTokenArtifactGoerli from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/goerli/TBTC.json" -import TbtcVaultArtifactGoerli from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/goerli/TBTCVault.json" -import VendingMachineKeepGoerli from "../vending-machine/goerli-artifacts/VendingMachineKeep.json" -import VendingMachineNuCypherGoerli from "../vending-machine/goerli-artifacts/VendingMachineNuCypher.json" -import WalletRegistryArtifactGoerli from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/goerli/WalletRegistry.json" +import BridgeArtifactSepolia from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/sepolia/Bridge.json" +import NuCypherStakingEscrowSepolia from "../staking/sepolia-artifacts/NuCypherStakingEscrow.json" +import NuCypherTokenSepolia from "../tokens/sepolia-artifacts/NuCypherToken.json" +import TbtcTokenArtifactSepolia from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/sepolia/TBTC.json" +import TbtcVaultArtifactSepolia from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/sepolia/TBTCVault.json" +import VendingMachineKeepSepolia from "../vending-machine/sepolia-artifacts/VendingMachineKeep.json" +import VendingMachineNuCypherSepolia from "../vending-machine/sepolia-artifacts/VendingMachineNuCypher.json" +import WalletRegistryArtifactSepolia from "@keep-network/tbtc-v2.ts/src/lib/ethereum/artifacts/sepolia/WalletRegistry.json" -import BridgeArtifactDappDevelopmentGoerli from "../tbtc/dapp-development-goerli-artifacts/Bridge.json" -import NuCypherStakingEscrowDappDevelopmentGoerli from "../staking/dapp-development-goerli-artifacts/NuCypherStakingEscrow.json" -import NuCypherTokenDappDevelopmentGoerli from "../tokens/dapp-development-goerli-artifacts/NuCypherToken.json" -import TbtcTokenArtifactDappDevelopmentGoerli from "../tbtc/dapp-development-goerli-artifacts/TBTC.json" -import TbtcVaultArtifactDappDevelopmentGoerli from "../tbtc/dapp-development-goerli-artifacts/TBTCVault.json" -import VendingMachineKeepDappDevelopmentGoerli from "../vending-machine/dapp-development-goerli-artifacts/VendingMachineKeep.json" -import VendingMachineNuCypherDappDevelopmentGoerli from "../vending-machine/dapp-development-goerli-artifacts/VendingMachineNuCypher.json" -import WalletRegistryArtifactDappDevelopmentGoerli from "../tbtc/dapp-development-goerli-artifacts/WalletRegistry.json" +import BridgeArtifactDappDevelopmentSepolia from "../tbtc/dapp-development-sepolia-artifacts/Bridge.json" +import NuCypherStakingEscrowDappDevelopmentSepolia from "../staking/dapp-development-sepolia-artifacts/NuCypherStakingEscrow.json" +import NuCypherTokenDappDevelopmentSepolia from "../tokens/dapp-development-sepolia-artifacts/NuCypherToken.json" +import TbtcTokenArtifactDappDevelopmentSepolia from "../tbtc/dapp-development-sepolia-artifacts/TBTC.json" +import TbtcVaultArtifactDappDevelopmentSepolia from "../tbtc/dapp-development-sepolia-artifacts/TBTCVault.json" +import VendingMachineKeepDappDevelopmentSepolia from "../vending-machine/dapp-development-sepolia-artifacts/VendingMachineKeep.json" +import VendingMachineNuCypherDappDevelopmentSepolia from "../vending-machine/dapp-development-sepolia-artifacts/VendingMachineNuCypher.json" +import WalletRegistryArtifactDappDevelopmentSepolia from "../tbtc/dapp-development-sepolia-artifacts/WalletRegistry.json" type ArtifactNameType = | "Bridge" @@ -62,24 +62,24 @@ const mainnetArtifacts = new Map([ ["VendingMachineNuCypher", VendingMachineNuCypherMainnet], ]) const testnetArtifacts = new Map([ - ["Bridge", BridgeArtifactGoerli], - ["NuCypherStakingEscrow", NuCypherStakingEscrowGoerli], - ["NuCypherToken", NuCypherTokenGoerli], - ["TBTCVault", TbtcVaultArtifactGoerli], - ["TBTC", TbtcTokenArtifactGoerli], - ["WalletRegistry", WalletRegistryArtifactGoerli], - ["VendingMachineKeep", VendingMachineKeepGoerli], - ["VendingMachineNuCypher", VendingMachineNuCypherGoerli], + ["Bridge", BridgeArtifactSepolia], + ["NuCypherStakingEscrow", NuCypherStakingEscrowSepolia], + ["NuCypherToken", NuCypherTokenSepolia], + ["TBTCVault", TbtcVaultArtifactSepolia], + ["TBTC", TbtcTokenArtifactSepolia], + ["WalletRegistry", WalletRegistryArtifactSepolia], + ["VendingMachineKeep", VendingMachineKeepSepolia], + ["VendingMachineNuCypher", VendingMachineNuCypherSepolia], ]) const testnetDevelopmentArtifacts = new Map([ - ["Bridge", BridgeArtifactDappDevelopmentGoerli], - ["NuCypherStakingEscrow", NuCypherStakingEscrowDappDevelopmentGoerli], - ["NuCypherToken", NuCypherTokenDappDevelopmentGoerli], - ["TBTCVault", TbtcVaultArtifactDappDevelopmentGoerli], - ["TBTC", TbtcTokenArtifactDappDevelopmentGoerli], - ["WalletRegistry", WalletRegistryArtifactDappDevelopmentGoerli], - ["VendingMachineKeep", VendingMachineKeepDappDevelopmentGoerli], - ["VendingMachineNuCypher", VendingMachineNuCypherDappDevelopmentGoerli], + ["Bridge", BridgeArtifactDappDevelopmentSepolia], + ["NuCypherStakingEscrow", NuCypherStakingEscrowDappDevelopmentSepolia], + ["NuCypherToken", NuCypherTokenDappDevelopmentSepolia], + ["TBTCVault", TbtcVaultArtifactDappDevelopmentSepolia], + ["TBTC", TbtcTokenArtifactDappDevelopmentSepolia], + ["WalletRegistry", WalletRegistryArtifactDappDevelopmentSepolia], + ["VendingMachineKeep", VendingMachineKeepDappDevelopmentSepolia], + ["VendingMachineNuCypher", VendingMachineNuCypherDappDevelopmentSepolia], ]) // account is not optional @@ -154,8 +154,10 @@ export const getArtifact = ( ): ArtifactType => { switch (chainId.toString()) { case "1": + // Ethereum mainnet. return mainnetArtifacts.get(artifactName)! - case "5": + case "11155111": + // Ethereum Sepolia testnet. const artifacts = shouldUseTestnetDevelopmentContracts ? testnetDevelopmentArtifacts : testnetArtifacts @@ -165,24 +167,24 @@ export const getArtifact = ( } } -export const getGoerliDevelopmentContracts = ( +export const getSepoliaDevelopmentContracts = ( signerOrProvider: Signer | providers.Provider ): TBTCContracts => { return { bridge: new EthereumBridge({ - address: BridgeArtifactDappDevelopmentGoerli.address, + address: BridgeArtifactDappDevelopmentSepolia.address, signerOrProvider, }), tbtcToken: new EthereumTBTCToken({ - address: TbtcTokenArtifactDappDevelopmentGoerli.address, + address: TbtcTokenArtifactDappDevelopmentSepolia.address, signerOrProvider, }), tbtcVault: new EthereumTBTCVault({ - address: TbtcVaultArtifactDappDevelopmentGoerli.address, + address: TbtcVaultArtifactDappDevelopmentSepolia.address, signerOrProvider, }), walletRegistry: new EthereumWalletRegistry({ - address: WalletRegistryArtifactDappDevelopmentGoerli.address, + address: WalletRegistryArtifactDappDevelopmentSepolia.address, signerOrProvider, }), } diff --git a/src/threshold-ts/vending-machine/goerli-artifacts/VendingMachineKeep.json b/src/threshold-ts/vending-machine/dapp-development-sepolia-artifacts/VendingMachineKeep.json similarity index 99% rename from src/threshold-ts/vending-machine/goerli-artifacts/VendingMachineKeep.json rename to src/threshold-ts/vending-machine/dapp-development-sepolia-artifacts/VendingMachineKeep.json index ea3ac94ac..bb334a749 100644 --- a/src/threshold-ts/vending-machine/goerli-artifacts/VendingMachineKeep.json +++ b/src/threshold-ts/vending-machine/dapp-development-sepolia-artifacts/VendingMachineKeep.json @@ -1,5 +1,5 @@ { - "address": "0x8d1EDfee0510537E1081a28Fa4A94769Cfa3969a", + "address": "0x0CeDD8265D65Bf770198746707a21C997252b5B1", "abi": [ { "inputs": [ @@ -264,30 +264,30 @@ "type": "function" } ], - "transactionHash": "0xa831d9780d9548b50065942286afa4c8e852ec68b0d879cc112c0e5e9ca2a471", + "transactionHash": "0x4e5ff34f1217a4c962054e95654a2297c304c61c6712f11ea390c5cf4e3e3378", "receipt": { "to": null, "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", - "contractAddress": "0x8d1EDfee0510537E1081a28Fa4A94769Cfa3969a", - "transactionIndex": 49, - "gasUsed": "804148", + "contractAddress": "0x0CeDD8265D65Bf770198746707a21C997252b5B1", + "transactionIndex": 11, + "gasUsed": "804422", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xbc9fcb88590d4bb2f75fc5b9afe7962dc56f32d6508b938aa613d5c6b3a28daa", - "transactionHash": "0xa831d9780d9548b50065942286afa4c8e852ec68b0d879cc112c0e5e9ca2a471", + "blockHash": "0x29a647e9cbf56ffe4af98711dda4a9ea0f8c890ac18a299ad8b58ac646399308", + "transactionHash": "0x4e5ff34f1217a4c962054e95654a2297c304c61c6712f11ea390c5cf4e3e3378", "logs": [], - "blockNumber": 7681416, - "cumulativeGasUsed": "11686374", + "blockNumber": 4648092, + "cumulativeGasUsed": "2492961", "status": 1, "byzantium": true }, "args": [ - "0x22647FfAe391540d584599818CA22fdF18890753", - "0x3f16380656cAE45D3f80D8833682d2b606eD094A", + "0xa07f4E37C2E7089Ea3AFffbe51A6A281833a4D14", + "0xce68Cea51c7e91aE6b663b0b178e7E72Da408dD2", "940795010800000000000000000", "4500000000000000000000000000" ], "numDeployments": 1, - "solcInputHash": "c42403a734f7dc0bc16cac52ab22d6ca", + "solcInputHash": "8933389a43c675e66679c9f606d83ebd", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_wrappedToken\",\"type\":\"address\"},{\"internalType\":\"contract T\",\"name\":\"_tToken\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"_wrappedTokenAllocation\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"_tTokenAllocation\",\"type\":\"uint96\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wrappedTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Unwrapped\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wrappedTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Wrapped\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FLOATING_POINT_DIVISOR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WRAPPED_TOKEN_CONVERSION_PRECISION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"conversionFromT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"wrappedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tRemainder\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"conversionToT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"tAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"wrappedRemainder\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ratio\",\"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\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tToken\",\"outputs\":[{\"internalType\":\"contract T\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unwrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"wrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Multiplications in this contract can't overflow uint256 as we restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\",\"params\":{\"_tToken\":\"Address of T token\",\"_tTokenAllocation\":\"The allocation of T this instance of Vending Machine will receive\",\"_wrappedToken\":\"Address to ERC20 token that will be wrapped to T\",\"_wrappedTokenAllocation\":\"The total supply of the token that will be wrapped to T\"}},\"receiveApproval(address,uint256,address,bytes)\":{\"params\":{\"amount\":\"The amount of KEEP/NU to be wrapped\",\"from\":\"Caller's address, must be the same as `wrappedToken` field\",\"token\":\"Token's address, must be the same as `wrappedToken` field\"}},\"unwrap(uint256)\":{\"params\":{\"amount\":\"The amount of T to unwrap back to the collateral (KEEP/NU)\"}},\"wrap(uint256)\":{\"params\":{\"amount\":\"The amount of KEEP/NU to be wrapped\"}}},\"title\":\"T token vending machine\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"FLOATING_POINT_DIVISOR()\":{\"notice\":\"Divisor for precision purposes, used to represent fractions.\"},\"WRAPPED_TOKEN_CONVERSION_PRECISION()\":{\"notice\":\"Number of decimal places of precision in conversion to/from wrapped tokens (assuming typical ERC20 token with 18 decimals). This implies that amounts of wrapped tokens below this precision won't take part in the conversion. E.g., for a value of 3, then for a conversion of 1.123456789 wrapped tokens, only 1.123 is convertible (i.e., 3 decimal places), and 0.000456789 is left.\"},\"constructor\":{\"notice\":\"Sets the reference to `wrappedToken` and `tToken`. Initializes conversion `ratio` between wrapped token and T based on the provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\"},\"conversionFromT(uint256)\":{\"notice\":\"The amount of wrapped tokens (KEEP/NU) that's obtained from `amount` T tokens, and the remainder that can't be downgraded.\"},\"conversionToT(uint256)\":{\"notice\":\"Returns the T token amount that's obtained from `amount` wrapped tokens (KEEP/NU), and the remainder that can't be upgraded.\"},\"ratio()\":{\"notice\":\"The ratio with which T token is converted based on the provided token being wrapped (KEEP/NU), expressed in 1e18 precision. When wrapping: x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR When unwrapping: x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Wraps up to the given amount of the token (KEEP/NU) and releases T token proportionally to the amount being wrapped with respect to the wrap ratio. This is a shortcut to `wrap` function that avoids a separate approval transaction. Only KEEP/NU token is allowed as a caller, so please call this function via token's `approveAndCall`.\"},\"tToken()\":{\"notice\":\"T token contract.\"},\"unwrap(uint256)\":{\"notice\":\"Unwraps up to the given `amount` of T back to the legacy token (KEEP/NU) according to the wrap ratio. It can only be called by a token holder who previously wrapped their tokens in this vending machine contract. The token holder can't unwrap more tokens than they originally wrapped. The token holder needs to have at least the given amount of T tokens approved to transfer to the Vending Machine before calling this function.\"},\"wrap(uint256)\":{\"notice\":\"Wraps up to the the given `amount` of the token (KEEP/NU) and releases T token proportionally to the amount being wrapped with respect to the wrap ratio. The token holder needs to have at least the given amount of the wrapped token (KEEP/NU) approved to transfer to the Vending Machine before calling this function.\"},\"wrappedBalance(address)\":{\"notice\":\"The total balance of wrapped tokens for the given holder account. Only holders that have previously wrapped KEEP/NU to T can unwrap, up to the amount previously wrapped.\"},\"wrappedToken()\":{\"notice\":\"The token being wrapped to T (KEEP/NU).\"}},\"notice\":\"Contract implements a special update protocol to enable KEEP/NU token holders to wrap their tokens and obtain T tokens according to a fixed ratio. This will go on indefinitely and enable NU and KEEP token holders to join T network without needing to buy or sell any assets. Logistically, anyone holding NU or KEEP can wrap those assets in order to upgrade to T. They can also unwrap T in order to downgrade back to the underlying asset. There is a separate instance of this contract deployed for KEEP holders and a separate instance of this contract deployed for NU holders.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/vending/VendingMachine.sol\":\"VendingMachine\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"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 v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.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 /**\\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\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\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 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 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 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 /**\\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\",\"keccak256\":\"0x516a22876c1fab47f49b1bc22b4614491cd05338af8bd2e7b382da090a079990\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.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 SafeCast {\\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\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"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\"},\"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/token/T.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 \\\"../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\",\"keccak256\":\"0x6265416225fd15b1108fce13d570b53a862a5d256ba2e6329bccf658eccac430\",\"license\":\"GPL-3.0-or-later\"},\"contracts/vending/VendingMachine.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 \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\nimport \\\"../token/T.sol\\\";\\n\\n/// @title T token vending machine\\n/// @notice Contract implements a special update protocol to enable KEEP/NU\\n/// token holders to wrap their tokens and obtain T tokens according\\n/// to a fixed ratio. This will go on indefinitely and enable NU and\\n/// KEEP token holders to join T network without needing to buy or\\n/// sell any assets. Logistically, anyone holding NU or KEEP can wrap\\n/// those assets in order to upgrade to T. They can also unwrap T in\\n/// order to downgrade back to the underlying asset. There is a separate\\n/// instance of this contract deployed for KEEP holders and a separate\\n/// instance of this contract deployed for NU holders.\\ncontract VendingMachine is IReceiveApproval {\\n using SafeERC20 for IERC20;\\n using SafeERC20 for T;\\n\\n /// @notice Number of decimal places of precision in conversion to/from\\n /// wrapped tokens (assuming typical ERC20 token with 18 decimals).\\n /// This implies that amounts of wrapped tokens below this precision\\n /// won't take part in the conversion. E.g., for a value of 3, then\\n /// for a conversion of 1.123456789 wrapped tokens, only 1.123 is\\n /// convertible (i.e., 3 decimal places), and 0.000456789 is left.\\n uint256 public constant WRAPPED_TOKEN_CONVERSION_PRECISION = 3;\\n\\n /// @notice Divisor for precision purposes, used to represent fractions.\\n uint256 public constant FLOATING_POINT_DIVISOR =\\n 10**(18 - WRAPPED_TOKEN_CONVERSION_PRECISION);\\n\\n /// @notice The token being wrapped to T (KEEP/NU).\\n IERC20 public immutable wrappedToken;\\n\\n /// @notice T token contract.\\n T public immutable tToken;\\n\\n /// @notice The ratio with which T token is converted based on the provided\\n /// token being wrapped (KEEP/NU), expressed in 1e18 precision.\\n ///\\n /// When wrapping:\\n /// x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR\\n ///\\n /// When unwrapping:\\n /// x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\\n uint256 public immutable ratio;\\n\\n /// @notice The total balance of wrapped tokens for the given holder\\n /// account. Only holders that have previously wrapped KEEP/NU to T\\n /// can unwrap, up to the amount previously wrapped.\\n mapping(address => uint256) public wrappedBalance;\\n\\n event Wrapped(\\n address indexed recipient,\\n uint256 wrappedTokenAmount,\\n uint256 tTokenAmount\\n );\\n event Unwrapped(\\n address indexed recipient,\\n uint256 tTokenAmount,\\n uint256 wrappedTokenAmount\\n );\\n\\n /// @notice Sets the reference to `wrappedToken` and `tToken`. Initializes\\n /// conversion `ratio` between wrapped token and T based on the\\n /// provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\\n /// @param _wrappedToken Address to ERC20 token that will be wrapped to T\\n /// @param _tToken Address of T token\\n /// @param _wrappedTokenAllocation The total supply of the token that will be\\n /// wrapped to T\\n /// @param _tTokenAllocation The allocation of T this instance of Vending\\n /// Machine will receive\\n /// @dev Multiplications in this contract can't overflow uint256 as we\\n /// restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to\\n /// 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\\n constructor(\\n IERC20 _wrappedToken,\\n T _tToken,\\n uint96 _wrappedTokenAllocation,\\n uint96 _tTokenAllocation\\n ) {\\n wrappedToken = _wrappedToken;\\n tToken = _tToken;\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n\\n /// @notice Wraps up to the the given `amount` of the token (KEEP/NU) and\\n /// releases T token proportionally to the amount being wrapped with\\n /// respect to the wrap ratio. The token holder needs to have at\\n /// least the given amount of the wrapped token (KEEP/NU) approved\\n /// to transfer to the Vending Machine before calling this function.\\n /// @param amount The amount of KEEP/NU to be wrapped\\n function wrap(uint256 amount) external {\\n _wrap(msg.sender, amount);\\n }\\n\\n /// @notice Wraps up to the given amount of the token (KEEP/NU) and releases\\n /// T token proportionally to the amount being wrapped with respect\\n /// to the wrap ratio. This is a shortcut to `wrap` function that\\n /// avoids a separate approval transaction. Only KEEP/NU token\\n /// is allowed as a caller, so please call this function via\\n /// token's `approveAndCall`.\\n /// @param from Caller's address, must be the same as `wrappedToken` field\\n /// @param amount The amount of KEEP/NU to be wrapped\\n /// @param token Token's address, must be the same as `wrappedToken` field\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(\\n token == address(wrappedToken),\\n \\\"Token is not the wrapped token\\\"\\n );\\n require(\\n msg.sender == address(wrappedToken),\\n \\\"Only wrapped token caller allowed\\\"\\n );\\n _wrap(from, amount);\\n }\\n\\n /// @notice Unwraps up to the given `amount` of T back to the legacy token\\n /// (KEEP/NU) according to the wrap ratio. It can only be called by\\n /// a token holder who previously wrapped their tokens in this\\n /// vending machine contract. The token holder can't unwrap more\\n /// tokens than they originally wrapped. The token holder needs to\\n /// have at least the given amount of T tokens approved to transfer\\n /// to the Vending Machine before calling this function.\\n /// @param amount The amount of T to unwrap back to the collateral (KEEP/NU)\\n function unwrap(uint256 amount) external {\\n _unwrap(msg.sender, amount);\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` wrapped\\n /// tokens (KEEP/NU), and the remainder that can't be upgraded.\\n function conversionToT(uint256 amount)\\n public\\n view\\n returns (uint256 tAmount, uint256 wrappedRemainder)\\n {\\n wrappedRemainder = amount % FLOATING_POINT_DIVISOR;\\n uint256 convertibleAmount = amount - wrappedRemainder;\\n tAmount = (convertibleAmount * ratio) / FLOATING_POINT_DIVISOR;\\n }\\n\\n /// @notice The amount of wrapped tokens (KEEP/NU) that's obtained from\\n /// `amount` T tokens, and the remainder that can't be downgraded.\\n function conversionFromT(uint256 amount)\\n public\\n view\\n returns (uint256 wrappedAmount, uint256 tRemainder)\\n {\\n tRemainder = amount % ratio;\\n uint256 convertibleAmount = amount - tRemainder;\\n wrappedAmount = (convertibleAmount * FLOATING_POINT_DIVISOR) / ratio;\\n }\\n\\n function _wrap(address tokenHolder, uint256 wrappedTokenAmount) internal {\\n (uint256 tTokenAmount, uint256 remainder) = conversionToT(\\n wrappedTokenAmount\\n );\\n wrappedTokenAmount -= remainder;\\n require(wrappedTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n emit Wrapped(tokenHolder, wrappedTokenAmount, tTokenAmount);\\n\\n wrappedBalance[tokenHolder] += wrappedTokenAmount;\\n wrappedToken.safeTransferFrom(\\n tokenHolder,\\n address(this),\\n wrappedTokenAmount\\n );\\n tToken.safeTransfer(tokenHolder, tTokenAmount);\\n }\\n\\n function _unwrap(address tokenHolder, uint256 tTokenAmount) internal {\\n (uint256 wrappedTokenAmount, uint256 remainder) = conversionFromT(\\n tTokenAmount\\n );\\n tTokenAmount -= remainder;\\n require(tTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n require(\\n wrappedBalance[tokenHolder] >= wrappedTokenAmount,\\n \\\"Can not unwrap more than previously wrapped\\\"\\n );\\n\\n emit Unwrapped(tokenHolder, tTokenAmount, wrappedTokenAmount);\\n wrappedBalance[tokenHolder] -= wrappedTokenAmount;\\n tToken.safeTransferFrom(tokenHolder, address(this), tTokenAmount);\\n wrappedToken.safeTransfer(tokenHolder, wrappedTokenAmount);\\n }\\n}\\n\",\"keccak256\":\"0xa4e7de5a9063db09b32ca97fa0fb5d8d1cc7b539387d1b44d74d15d3c2ed4134\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", "bytecode": "0x60e06040523480156200001157600080fd5b506040516200108f3803806200108f8339810160408190526200003491620000cc565b6001600160a01b03808516608052831660a0526001600160601b03808316908216620000636003601262000144565b6200007090600a6200025d565b6200007c919062000272565b62000088919062000294565b60c05250620002b792505050565b6001600160a01b0381168114620000ac57600080fd5b50565b80516001600160601b0381168114620000c757600080fd5b919050565b60008060008060808587031215620000e357600080fd5b8451620000f08162000096565b6020860151909450620001038162000096565b92506200011360408601620000af565b91506200012360608601620000af565b905092959194509250565b634e487b7160e01b600052601160045260246000fd5b6000828210156200015957620001596200012e565b500390565b600181815b808511156200019f5781600019048211156200018357620001836200012e565b808516156200019157918102915b93841c939080029062000163565b509250929050565b600082620001b85750600162000257565b81620001c75750600062000257565b8160018114620001e05760028114620001eb576200020b565b600191505062000257565b60ff841115620001ff57620001ff6200012e565b50506001821b62000257565b5060208310610133831016604e8410600b841016171562000230575081810a62000257565b6200023c83836200015e565b80600019048211156200025357620002536200012e565b0290505b92915050565b60006200026b8383620001a7565b9392505050565b60008160001904831182151516156200028f576200028f6200012e565b500290565b600082620002b257634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c051610d6a620003256000396000818160e601528181610234015281816103a601526103dd0152600081816101810152818161052101526106860152600081816101420152818161028701528181610316015281816104ec01526106bb0152610d6a6000f3fe608060405234801561001057600080fd5b50600436106100995760003560e01c80631c060cbe1461009e57806351b83ebc146100cb57806371ca337d146100e15780637a93f256146101085780638f4ffcb114610128578063996c6cc31461013d578063c35d64ea1461017c578063cff0eac5146101a3578063de0e9a3e146101b6578063ea598cb0146101c9578063f4fc2f47146101dc575b600080fd5b6100b16100ac3660046109d7565b6101e4565b604080519283526020830191909152015b60405180910390f35b6100d361026b565b6040519081526020016100c2565b6100d37f000000000000000000000000000000000000000000000000000000000000000081565b6100d3610116366004610a0c565b60006020819052908152604090205481565b61013b610136366004610a27565b610285565b005b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6100b16101b13660046109d7565b61039e565b61013b6101c43660046109d7565b61041d565b61013b6101d73660046109d7565b61042a565b6100d3600381565b6000806101f360036012610ad7565b6101fe90600a610bd4565b6102089084610bf6565b905060006102168285610ad7565b905061022460036012610ad7565b61022f90600a610bd4565b6102597f000000000000000000000000000000000000000000000000000000000000000083610c0a565b6102639190610c29565b925050915091565b61027760036012610ad7565b61028290600a610bd4565b81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461030b5760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e206973206e6f7420746865207772617070656420746f6b656e000060448201526064015b60405180910390fd5b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461038d5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207772617070656420746f6b656e2063616c6c657220616c6c6f77656044820152601960fa1b6064820152608401610302565b6103978585610430565b5050505050565b6000806103cb7f000000000000000000000000000000000000000000000000000000000000000084610bf6565b905060006103d98285610ad7565b90507f000000000000000000000000000000000000000000000000000000000000000061040860036012610ad7565b61041390600a610bd4565b6102599083610c0a565b610427338261054e565b50565b61042733825b60008061043c836101e4565b909250905061044b8184610ad7565b92506000831161046d5760405162461bcd60e51b815260040161030290610c3d565b60408051848152602081018490526001600160a01b038616917f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a938910160405180910390a26001600160a01b038416600090815260208190526040812080548592906104d9908490610c7f565b9091555061051490506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b50505050565b60008061055a8361039e565b90925090506105698184610ad7565b92506000831161058b5760405162461bcd60e51b815260040161030290610c3d565b6001600160a01b0384166000908152602081905260409020548211156106075760405162461bcd60e51b815260206004820152602b60248201527f43616e206e6f7420756e77726170206d6f7265207468616e2070726576696f7560448201526a1cdb1e481ddc985c1c195960aa1b6064820152608401610302565b60408051848152602081018490526001600160a01b038616917ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b910160405180910390a26001600160a01b03841660009081526020819052604081208054849290610673908490610ad7565b909155506106ae90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b6040516001600160a01b03808516602483015283166044820152606481018290526105489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610782565b6040516001600160a01b03831660248201526044810182905261077d90849063a9059cbb60e01b90606401610716565b505050565b60006107d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b80519091501561077d57808060200190518101906107f59190610c97565b61077d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610302565b6060610863848460008561086d565b90505b9392505050565b6060824710156108ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610302565b6001600160a01b0385163b6109255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610302565b600080866001600160a01b031685876040516109419190610ce5565b60006040518083038185875af1925050503d806000811461097e576040519150601f19603f3d011682016040523d82523d6000602084013e610983565b606091505b509150915061099382828661099e565b979650505050505050565b606083156109ad575081610866565b8251156109bd5782518084602001fd5b8160405162461bcd60e51b81526004016103029190610d01565b6000602082840312156109e957600080fd5b5035919050565b80356001600160a01b0381168114610a0757600080fd5b919050565b600060208284031215610a1e57600080fd5b610866826109f0565b600080600080600060808688031215610a3f57600080fd5b610a48866109f0565b945060208601359350610a5d604087016109f0565b925060608601356001600160401b0380821115610a7957600080fd5b818801915088601f830112610a8d57600080fd5b813581811115610a9c57600080fd5b896020828501011115610aae57600080fd5b9699959850939650602001949392505050565b634e487b7160e01b600052601160045260246000fd5b600082821015610ae957610ae9610ac1565b500390565b600181815b80851115610b29578160001904821115610b0f57610b0f610ac1565b80851615610b1c57918102915b93841c9390800290610af3565b509250929050565b600082610b4057506001610bce565b81610b4d57506000610bce565b8160018114610b635760028114610b6d57610b89565b6001915050610bce565b60ff841115610b7e57610b7e610ac1565b50506001821b610bce565b5060208310610133831016604e8410600b8410161715610bac575081810a610bce565b610bb68383610aee565b8060001904821115610bca57610bca610ac1565b0290505b92915050565b60006108668383610b31565b634e487b7160e01b600052601260045260246000fd5b600082610c0557610c05610be0565b500690565b6000816000190483118215151615610c2457610c24610ac1565b500290565b600082610c3857610c38610be0565b500490565b60208082526022908201527f446973616c6c6f7720636f6e76657273696f6e73206f66207a65726f2076616c604082015261756560f01b606082015260800190565b60008219821115610c9257610c92610ac1565b500190565b600060208284031215610ca957600080fd5b8151801515811461086657600080fd5b60005b83811015610cd4578181015183820152602001610cbc565b838111156105485750506000910152565b60008251610cf7818460208701610cb9565b9190910192915050565b6020815260008251806020840152610d20816040850160208701610cb9565b601f01601f1916919091016040019291505056fea2646970667358221220bb936fa870b05584f089c820f52c7f9fc6a018385c068e4f388d00bc8bb67c2564736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100995760003560e01c80631c060cbe1461009e57806351b83ebc146100cb57806371ca337d146100e15780637a93f256146101085780638f4ffcb114610128578063996c6cc31461013d578063c35d64ea1461017c578063cff0eac5146101a3578063de0e9a3e146101b6578063ea598cb0146101c9578063f4fc2f47146101dc575b600080fd5b6100b16100ac3660046109d7565b6101e4565b604080519283526020830191909152015b60405180910390f35b6100d361026b565b6040519081526020016100c2565b6100d37f000000000000000000000000000000000000000000000000000000000000000081565b6100d3610116366004610a0c565b60006020819052908152604090205481565b61013b610136366004610a27565b610285565b005b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6100b16101b13660046109d7565b61039e565b61013b6101c43660046109d7565b61041d565b61013b6101d73660046109d7565b61042a565b6100d3600381565b6000806101f360036012610ad7565b6101fe90600a610bd4565b6102089084610bf6565b905060006102168285610ad7565b905061022460036012610ad7565b61022f90600a610bd4565b6102597f000000000000000000000000000000000000000000000000000000000000000083610c0a565b6102639190610c29565b925050915091565b61027760036012610ad7565b61028290600a610bd4565b81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461030b5760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e206973206e6f7420746865207772617070656420746f6b656e000060448201526064015b60405180910390fd5b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461038d5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207772617070656420746f6b656e2063616c6c657220616c6c6f77656044820152601960fa1b6064820152608401610302565b6103978585610430565b5050505050565b6000806103cb7f000000000000000000000000000000000000000000000000000000000000000084610bf6565b905060006103d98285610ad7565b90507f000000000000000000000000000000000000000000000000000000000000000061040860036012610ad7565b61041390600a610bd4565b6102599083610c0a565b610427338261054e565b50565b61042733825b60008061043c836101e4565b909250905061044b8184610ad7565b92506000831161046d5760405162461bcd60e51b815260040161030290610c3d565b60408051848152602081018490526001600160a01b038616917f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a938910160405180910390a26001600160a01b038416600090815260208190526040812080548592906104d9908490610c7f565b9091555061051490506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b50505050565b60008061055a8361039e565b90925090506105698184610ad7565b92506000831161058b5760405162461bcd60e51b815260040161030290610c3d565b6001600160a01b0384166000908152602081905260409020548211156106075760405162461bcd60e51b815260206004820152602b60248201527f43616e206e6f7420756e77726170206d6f7265207468616e2070726576696f7560448201526a1cdb1e481ddc985c1c195960aa1b6064820152608401610302565b60408051848152602081018490526001600160a01b038616917ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b910160405180910390a26001600160a01b03841660009081526020819052604081208054849290610673908490610ad7565b909155506106ae90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b6040516001600160a01b03808516602483015283166044820152606481018290526105489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610782565b6040516001600160a01b03831660248201526044810182905261077d90849063a9059cbb60e01b90606401610716565b505050565b60006107d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b80519091501561077d57808060200190518101906107f59190610c97565b61077d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610302565b6060610863848460008561086d565b90505b9392505050565b6060824710156108ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610302565b6001600160a01b0385163b6109255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610302565b600080866001600160a01b031685876040516109419190610ce5565b60006040518083038185875af1925050503d806000811461097e576040519150601f19603f3d011682016040523d82523d6000602084013e610983565b606091505b509150915061099382828661099e565b979650505050505050565b606083156109ad575081610866565b8251156109bd5782518084602001fd5b8160405162461bcd60e51b81526004016103029190610d01565b6000602082840312156109e957600080fd5b5035919050565b80356001600160a01b0381168114610a0757600080fd5b919050565b600060208284031215610a1e57600080fd5b610866826109f0565b600080600080600060808688031215610a3f57600080fd5b610a48866109f0565b945060208601359350610a5d604087016109f0565b925060608601356001600160401b0380821115610a7957600080fd5b818801915088601f830112610a8d57600080fd5b813581811115610a9c57600080fd5b896020828501011115610aae57600080fd5b9699959850939650602001949392505050565b634e487b7160e01b600052601160045260246000fd5b600082821015610ae957610ae9610ac1565b500390565b600181815b80851115610b29578160001904821115610b0f57610b0f610ac1565b80851615610b1c57918102915b93841c9390800290610af3565b509250929050565b600082610b4057506001610bce565b81610b4d57506000610bce565b8160018114610b635760028114610b6d57610b89565b6001915050610bce565b60ff841115610b7e57610b7e610ac1565b50506001821b610bce565b5060208310610133831016604e8410600b8410161715610bac575081810a610bce565b610bb68383610aee565b8060001904821115610bca57610bca610ac1565b0290505b92915050565b60006108668383610b31565b634e487b7160e01b600052601260045260246000fd5b600082610c0557610c05610be0565b500690565b6000816000190483118215151615610c2457610c24610ac1565b500290565b600082610c3857610c38610be0565b500490565b60208082526022908201527f446973616c6c6f7720636f6e76657273696f6e73206f66207a65726f2076616c604082015261756560f01b606082015260800190565b60008219821115610c9257610c92610ac1565b500190565b600060208284031215610ca957600080fd5b8151801515811461086657600080fd5b60005b83811015610cd4578181015183820152602001610cbc565b838111156105485750506000910152565b60008251610cf7818460208701610cb9565b9190910192915050565b6020815260008251806020840152610d20816040850160208701610cb9565b601f01601f1916919091016040019291505056fea2646970667358221220bb936fa870b05584f089c820f52c7f9fc6a018385c068e4f388d00bc8bb67c2564736f6c63430008090033", @@ -370,7 +370,7 @@ "storageLayout": { "storage": [ { - "astId": 18594, + "astId": 18568, "contract": "contracts/vending/VendingMachine.sol:VendingMachine", "label": "wrappedBalance", "offset": 0, diff --git a/src/threshold-ts/vending-machine/goerli-artifacts/VendingMachineNuCypher.json b/src/threshold-ts/vending-machine/dapp-development-sepolia-artifacts/VendingMachineNuCypher.json similarity index 99% rename from src/threshold-ts/vending-machine/goerli-artifacts/VendingMachineNuCypher.json rename to src/threshold-ts/vending-machine/dapp-development-sepolia-artifacts/VendingMachineNuCypher.json index 1dcf236c1..9c43d75a4 100644 --- a/src/threshold-ts/vending-machine/goerli-artifacts/VendingMachineNuCypher.json +++ b/src/threshold-ts/vending-machine/dapp-development-sepolia-artifacts/VendingMachineNuCypher.json @@ -1,5 +1,5 @@ { - "address": "0x8D4Ccc04D17d055b88fbaB8634C7F0611d8Aa946", + "address": "0x189F188436b3b6d53F33ca68BffEF77548DC328d", "abi": [ { "inputs": [ @@ -264,30 +264,30 @@ "type": "function" } ], - "transactionHash": "0x78d6dee1f9f22d794ca70d96008a11a8a81878ab037105786de12df0e1f5bd29", + "transactionHash": "0xb36e04e39aa0c86ddff7daa7035012dc0d09a1ac227990b90247fbca19dfd6c9", "receipt": { "to": null, "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", - "contractAddress": "0x8D4Ccc04D17d055b88fbaB8634C7F0611d8Aa946", - "transactionIndex": 44, - "gasUsed": "804160", + "contractAddress": "0x189F188436b3b6d53F33ca68BffEF77548DC328d", + "transactionIndex": 72, + "gasUsed": "804434", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xd03d79ad76cc97ecad7af6b9ad8c369a9f3414603de1fddb05f6352fd278c658", - "transactionHash": "0x78d6dee1f9f22d794ca70d96008a11a8a81878ab037105786de12df0e1f5bd29", + "blockHash": "0xd58d11182e4588083959d4c7e4f229537555874b97d8d4b6dcc91d949073a823", + "transactionHash": "0xb36e04e39aa0c86ddff7daa7035012dc0d09a1ac227990b90247fbca19dfd6c9", "logs": [], - "blockNumber": 7681417, - "cumulativeGasUsed": "11213131", + "blockNumber": 4648094, + "cumulativeGasUsed": "13587596", "status": 1, "byzantium": true }, "args": [ - "0x26bDc8Cb2D4F55Af3B43568069b65B435bCdc32c", - "0x3f16380656cAE45D3f80D8833682d2b606eD094A", + "0x1943A53B7E43421373f6a72c9aC7B939c197ccFc", + "0xce68Cea51c7e91aE6b663b0b178e7E72Da408dD2", "1380688920644254727736959922", "4500000000000000000000000000" ], "numDeployments": 1, - "solcInputHash": "c42403a734f7dc0bc16cac52ab22d6ca", + "solcInputHash": "8933389a43c675e66679c9f606d83ebd", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_wrappedToken\",\"type\":\"address\"},{\"internalType\":\"contract T\",\"name\":\"_tToken\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"_wrappedTokenAllocation\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"_tTokenAllocation\",\"type\":\"uint96\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wrappedTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Unwrapped\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wrappedTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Wrapped\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FLOATING_POINT_DIVISOR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WRAPPED_TOKEN_CONVERSION_PRECISION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"conversionFromT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"wrappedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tRemainder\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"conversionToT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"tAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"wrappedRemainder\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ratio\",\"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\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tToken\",\"outputs\":[{\"internalType\":\"contract T\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unwrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"wrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Multiplications in this contract can't overflow uint256 as we restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\",\"params\":{\"_tToken\":\"Address of T token\",\"_tTokenAllocation\":\"The allocation of T this instance of Vending Machine will receive\",\"_wrappedToken\":\"Address to ERC20 token that will be wrapped to T\",\"_wrappedTokenAllocation\":\"The total supply of the token that will be wrapped to T\"}},\"receiveApproval(address,uint256,address,bytes)\":{\"params\":{\"amount\":\"The amount of KEEP/NU to be wrapped\",\"from\":\"Caller's address, must be the same as `wrappedToken` field\",\"token\":\"Token's address, must be the same as `wrappedToken` field\"}},\"unwrap(uint256)\":{\"params\":{\"amount\":\"The amount of T to unwrap back to the collateral (KEEP/NU)\"}},\"wrap(uint256)\":{\"params\":{\"amount\":\"The amount of KEEP/NU to be wrapped\"}}},\"title\":\"T token vending machine\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"FLOATING_POINT_DIVISOR()\":{\"notice\":\"Divisor for precision purposes, used to represent fractions.\"},\"WRAPPED_TOKEN_CONVERSION_PRECISION()\":{\"notice\":\"Number of decimal places of precision in conversion to/from wrapped tokens (assuming typical ERC20 token with 18 decimals). This implies that amounts of wrapped tokens below this precision won't take part in the conversion. E.g., for a value of 3, then for a conversion of 1.123456789 wrapped tokens, only 1.123 is convertible (i.e., 3 decimal places), and 0.000456789 is left.\"},\"constructor\":{\"notice\":\"Sets the reference to `wrappedToken` and `tToken`. Initializes conversion `ratio` between wrapped token and T based on the provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\"},\"conversionFromT(uint256)\":{\"notice\":\"The amount of wrapped tokens (KEEP/NU) that's obtained from `amount` T tokens, and the remainder that can't be downgraded.\"},\"conversionToT(uint256)\":{\"notice\":\"Returns the T token amount that's obtained from `amount` wrapped tokens (KEEP/NU), and the remainder that can't be upgraded.\"},\"ratio()\":{\"notice\":\"The ratio with which T token is converted based on the provided token being wrapped (KEEP/NU), expressed in 1e18 precision. When wrapping: x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR When unwrapping: x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Wraps up to the given amount of the token (KEEP/NU) and releases T token proportionally to the amount being wrapped with respect to the wrap ratio. This is a shortcut to `wrap` function that avoids a separate approval transaction. Only KEEP/NU token is allowed as a caller, so please call this function via token's `approveAndCall`.\"},\"tToken()\":{\"notice\":\"T token contract.\"},\"unwrap(uint256)\":{\"notice\":\"Unwraps up to the given `amount` of T back to the legacy token (KEEP/NU) according to the wrap ratio. It can only be called by a token holder who previously wrapped their tokens in this vending machine contract. The token holder can't unwrap more tokens than they originally wrapped. The token holder needs to have at least the given amount of T tokens approved to transfer to the Vending Machine before calling this function.\"},\"wrap(uint256)\":{\"notice\":\"Wraps up to the the given `amount` of the token (KEEP/NU) and releases T token proportionally to the amount being wrapped with respect to the wrap ratio. The token holder needs to have at least the given amount of the wrapped token (KEEP/NU) approved to transfer to the Vending Machine before calling this function.\"},\"wrappedBalance(address)\":{\"notice\":\"The total balance of wrapped tokens for the given holder account. Only holders that have previously wrapped KEEP/NU to T can unwrap, up to the amount previously wrapped.\"},\"wrappedToken()\":{\"notice\":\"The token being wrapped to T (KEEP/NU).\"}},\"notice\":\"Contract implements a special update protocol to enable KEEP/NU token holders to wrap their tokens and obtain T tokens according to a fixed ratio. This will go on indefinitely and enable NU and KEEP token holders to join T network without needing to buy or sell any assets. Logistically, anyone holding NU or KEEP can wrap those assets in order to upgrade to T. They can also unwrap T in order to downgrade back to the underlying asset. There is a separate instance of this contract deployed for KEEP holders and a separate instance of this contract deployed for NU holders.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/vending/VendingMachine.sol\":\"VendingMachine\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"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 v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.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 /**\\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\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\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 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 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 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 /**\\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\",\"keccak256\":\"0x516a22876c1fab47f49b1bc22b4614491cd05338af8bd2e7b382da090a079990\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.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 SafeCast {\\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\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"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\"},\"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/token/T.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 \\\"../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\",\"keccak256\":\"0x6265416225fd15b1108fce13d570b53a862a5d256ba2e6329bccf658eccac430\",\"license\":\"GPL-3.0-or-later\"},\"contracts/vending/VendingMachine.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 \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\nimport \\\"../token/T.sol\\\";\\n\\n/// @title T token vending machine\\n/// @notice Contract implements a special update protocol to enable KEEP/NU\\n/// token holders to wrap their tokens and obtain T tokens according\\n/// to a fixed ratio. This will go on indefinitely and enable NU and\\n/// KEEP token holders to join T network without needing to buy or\\n/// sell any assets. Logistically, anyone holding NU or KEEP can wrap\\n/// those assets in order to upgrade to T. They can also unwrap T in\\n/// order to downgrade back to the underlying asset. There is a separate\\n/// instance of this contract deployed for KEEP holders and a separate\\n/// instance of this contract deployed for NU holders.\\ncontract VendingMachine is IReceiveApproval {\\n using SafeERC20 for IERC20;\\n using SafeERC20 for T;\\n\\n /// @notice Number of decimal places of precision in conversion to/from\\n /// wrapped tokens (assuming typical ERC20 token with 18 decimals).\\n /// This implies that amounts of wrapped tokens below this precision\\n /// won't take part in the conversion. E.g., for a value of 3, then\\n /// for a conversion of 1.123456789 wrapped tokens, only 1.123 is\\n /// convertible (i.e., 3 decimal places), and 0.000456789 is left.\\n uint256 public constant WRAPPED_TOKEN_CONVERSION_PRECISION = 3;\\n\\n /// @notice Divisor for precision purposes, used to represent fractions.\\n uint256 public constant FLOATING_POINT_DIVISOR =\\n 10**(18 - WRAPPED_TOKEN_CONVERSION_PRECISION);\\n\\n /// @notice The token being wrapped to T (KEEP/NU).\\n IERC20 public immutable wrappedToken;\\n\\n /// @notice T token contract.\\n T public immutable tToken;\\n\\n /// @notice The ratio with which T token is converted based on the provided\\n /// token being wrapped (KEEP/NU), expressed in 1e18 precision.\\n ///\\n /// When wrapping:\\n /// x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR\\n ///\\n /// When unwrapping:\\n /// x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\\n uint256 public immutable ratio;\\n\\n /// @notice The total balance of wrapped tokens for the given holder\\n /// account. Only holders that have previously wrapped KEEP/NU to T\\n /// can unwrap, up to the amount previously wrapped.\\n mapping(address => uint256) public wrappedBalance;\\n\\n event Wrapped(\\n address indexed recipient,\\n uint256 wrappedTokenAmount,\\n uint256 tTokenAmount\\n );\\n event Unwrapped(\\n address indexed recipient,\\n uint256 tTokenAmount,\\n uint256 wrappedTokenAmount\\n );\\n\\n /// @notice Sets the reference to `wrappedToken` and `tToken`. Initializes\\n /// conversion `ratio` between wrapped token and T based on the\\n /// provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\\n /// @param _wrappedToken Address to ERC20 token that will be wrapped to T\\n /// @param _tToken Address of T token\\n /// @param _wrappedTokenAllocation The total supply of the token that will be\\n /// wrapped to T\\n /// @param _tTokenAllocation The allocation of T this instance of Vending\\n /// Machine will receive\\n /// @dev Multiplications in this contract can't overflow uint256 as we\\n /// restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to\\n /// 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\\n constructor(\\n IERC20 _wrappedToken,\\n T _tToken,\\n uint96 _wrappedTokenAllocation,\\n uint96 _tTokenAllocation\\n ) {\\n wrappedToken = _wrappedToken;\\n tToken = _tToken;\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n\\n /// @notice Wraps up to the the given `amount` of the token (KEEP/NU) and\\n /// releases T token proportionally to the amount being wrapped with\\n /// respect to the wrap ratio. The token holder needs to have at\\n /// least the given amount of the wrapped token (KEEP/NU) approved\\n /// to transfer to the Vending Machine before calling this function.\\n /// @param amount The amount of KEEP/NU to be wrapped\\n function wrap(uint256 amount) external {\\n _wrap(msg.sender, amount);\\n }\\n\\n /// @notice Wraps up to the given amount of the token (KEEP/NU) and releases\\n /// T token proportionally to the amount being wrapped with respect\\n /// to the wrap ratio. This is a shortcut to `wrap` function that\\n /// avoids a separate approval transaction. Only KEEP/NU token\\n /// is allowed as a caller, so please call this function via\\n /// token's `approveAndCall`.\\n /// @param from Caller's address, must be the same as `wrappedToken` field\\n /// @param amount The amount of KEEP/NU to be wrapped\\n /// @param token Token's address, must be the same as `wrappedToken` field\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(\\n token == address(wrappedToken),\\n \\\"Token is not the wrapped token\\\"\\n );\\n require(\\n msg.sender == address(wrappedToken),\\n \\\"Only wrapped token caller allowed\\\"\\n );\\n _wrap(from, amount);\\n }\\n\\n /// @notice Unwraps up to the given `amount` of T back to the legacy token\\n /// (KEEP/NU) according to the wrap ratio. It can only be called by\\n /// a token holder who previously wrapped their tokens in this\\n /// vending machine contract. The token holder can't unwrap more\\n /// tokens than they originally wrapped. The token holder needs to\\n /// have at least the given amount of T tokens approved to transfer\\n /// to the Vending Machine before calling this function.\\n /// @param amount The amount of T to unwrap back to the collateral (KEEP/NU)\\n function unwrap(uint256 amount) external {\\n _unwrap(msg.sender, amount);\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` wrapped\\n /// tokens (KEEP/NU), and the remainder that can't be upgraded.\\n function conversionToT(uint256 amount)\\n public\\n view\\n returns (uint256 tAmount, uint256 wrappedRemainder)\\n {\\n wrappedRemainder = amount % FLOATING_POINT_DIVISOR;\\n uint256 convertibleAmount = amount - wrappedRemainder;\\n tAmount = (convertibleAmount * ratio) / FLOATING_POINT_DIVISOR;\\n }\\n\\n /// @notice The amount of wrapped tokens (KEEP/NU) that's obtained from\\n /// `amount` T tokens, and the remainder that can't be downgraded.\\n function conversionFromT(uint256 amount)\\n public\\n view\\n returns (uint256 wrappedAmount, uint256 tRemainder)\\n {\\n tRemainder = amount % ratio;\\n uint256 convertibleAmount = amount - tRemainder;\\n wrappedAmount = (convertibleAmount * FLOATING_POINT_DIVISOR) / ratio;\\n }\\n\\n function _wrap(address tokenHolder, uint256 wrappedTokenAmount) internal {\\n (uint256 tTokenAmount, uint256 remainder) = conversionToT(\\n wrappedTokenAmount\\n );\\n wrappedTokenAmount -= remainder;\\n require(wrappedTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n emit Wrapped(tokenHolder, wrappedTokenAmount, tTokenAmount);\\n\\n wrappedBalance[tokenHolder] += wrappedTokenAmount;\\n wrappedToken.safeTransferFrom(\\n tokenHolder,\\n address(this),\\n wrappedTokenAmount\\n );\\n tToken.safeTransfer(tokenHolder, tTokenAmount);\\n }\\n\\n function _unwrap(address tokenHolder, uint256 tTokenAmount) internal {\\n (uint256 wrappedTokenAmount, uint256 remainder) = conversionFromT(\\n tTokenAmount\\n );\\n tTokenAmount -= remainder;\\n require(tTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n require(\\n wrappedBalance[tokenHolder] >= wrappedTokenAmount,\\n \\\"Can not unwrap more than previously wrapped\\\"\\n );\\n\\n emit Unwrapped(tokenHolder, tTokenAmount, wrappedTokenAmount);\\n wrappedBalance[tokenHolder] -= wrappedTokenAmount;\\n tToken.safeTransferFrom(tokenHolder, address(this), tTokenAmount);\\n wrappedToken.safeTransfer(tokenHolder, wrappedTokenAmount);\\n }\\n}\\n\",\"keccak256\":\"0xa4e7de5a9063db09b32ca97fa0fb5d8d1cc7b539387d1b44d74d15d3c2ed4134\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", "bytecode": "0x60e06040523480156200001157600080fd5b506040516200108f3803806200108f8339810160408190526200003491620000cc565b6001600160a01b03808516608052831660a0526001600160601b03808316908216620000636003601262000144565b6200007090600a6200025d565b6200007c919062000272565b62000088919062000294565b60c05250620002b792505050565b6001600160a01b0381168114620000ac57600080fd5b50565b80516001600160601b0381168114620000c757600080fd5b919050565b60008060008060808587031215620000e357600080fd5b8451620000f08162000096565b6020860151909450620001038162000096565b92506200011360408601620000af565b91506200012360608601620000af565b905092959194509250565b634e487b7160e01b600052601160045260246000fd5b6000828210156200015957620001596200012e565b500390565b600181815b808511156200019f5781600019048211156200018357620001836200012e565b808516156200019157918102915b93841c939080029062000163565b509250929050565b600082620001b85750600162000257565b81620001c75750600062000257565b8160018114620001e05760028114620001eb576200020b565b600191505062000257565b60ff841115620001ff57620001ff6200012e565b50506001821b62000257565b5060208310610133831016604e8410600b841016171562000230575081810a62000257565b6200023c83836200015e565b80600019048211156200025357620002536200012e565b0290505b92915050565b60006200026b8383620001a7565b9392505050565b60008160001904831182151516156200028f576200028f6200012e565b500290565b600082620002b257634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c051610d6a620003256000396000818160e601528181610234015281816103a601526103dd0152600081816101810152818161052101526106860152600081816101420152818161028701528181610316015281816104ec01526106bb0152610d6a6000f3fe608060405234801561001057600080fd5b50600436106100995760003560e01c80631c060cbe1461009e57806351b83ebc146100cb57806371ca337d146100e15780637a93f256146101085780638f4ffcb114610128578063996c6cc31461013d578063c35d64ea1461017c578063cff0eac5146101a3578063de0e9a3e146101b6578063ea598cb0146101c9578063f4fc2f47146101dc575b600080fd5b6100b16100ac3660046109d7565b6101e4565b604080519283526020830191909152015b60405180910390f35b6100d361026b565b6040519081526020016100c2565b6100d37f000000000000000000000000000000000000000000000000000000000000000081565b6100d3610116366004610a0c565b60006020819052908152604090205481565b61013b610136366004610a27565b610285565b005b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6100b16101b13660046109d7565b61039e565b61013b6101c43660046109d7565b61041d565b61013b6101d73660046109d7565b61042a565b6100d3600381565b6000806101f360036012610ad7565b6101fe90600a610bd4565b6102089084610bf6565b905060006102168285610ad7565b905061022460036012610ad7565b61022f90600a610bd4565b6102597f000000000000000000000000000000000000000000000000000000000000000083610c0a565b6102639190610c29565b925050915091565b61027760036012610ad7565b61028290600a610bd4565b81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461030b5760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e206973206e6f7420746865207772617070656420746f6b656e000060448201526064015b60405180910390fd5b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461038d5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207772617070656420746f6b656e2063616c6c657220616c6c6f77656044820152601960fa1b6064820152608401610302565b6103978585610430565b5050505050565b6000806103cb7f000000000000000000000000000000000000000000000000000000000000000084610bf6565b905060006103d98285610ad7565b90507f000000000000000000000000000000000000000000000000000000000000000061040860036012610ad7565b61041390600a610bd4565b6102599083610c0a565b610427338261054e565b50565b61042733825b60008061043c836101e4565b909250905061044b8184610ad7565b92506000831161046d5760405162461bcd60e51b815260040161030290610c3d565b60408051848152602081018490526001600160a01b038616917f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a938910160405180910390a26001600160a01b038416600090815260208190526040812080548592906104d9908490610c7f565b9091555061051490506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b50505050565b60008061055a8361039e565b90925090506105698184610ad7565b92506000831161058b5760405162461bcd60e51b815260040161030290610c3d565b6001600160a01b0384166000908152602081905260409020548211156106075760405162461bcd60e51b815260206004820152602b60248201527f43616e206e6f7420756e77726170206d6f7265207468616e2070726576696f7560448201526a1cdb1e481ddc985c1c195960aa1b6064820152608401610302565b60408051848152602081018490526001600160a01b038616917ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b910160405180910390a26001600160a01b03841660009081526020819052604081208054849290610673908490610ad7565b909155506106ae90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b6040516001600160a01b03808516602483015283166044820152606481018290526105489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610782565b6040516001600160a01b03831660248201526044810182905261077d90849063a9059cbb60e01b90606401610716565b505050565b60006107d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b80519091501561077d57808060200190518101906107f59190610c97565b61077d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610302565b6060610863848460008561086d565b90505b9392505050565b6060824710156108ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610302565b6001600160a01b0385163b6109255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610302565b600080866001600160a01b031685876040516109419190610ce5565b60006040518083038185875af1925050503d806000811461097e576040519150601f19603f3d011682016040523d82523d6000602084013e610983565b606091505b509150915061099382828661099e565b979650505050505050565b606083156109ad575081610866565b8251156109bd5782518084602001fd5b8160405162461bcd60e51b81526004016103029190610d01565b6000602082840312156109e957600080fd5b5035919050565b80356001600160a01b0381168114610a0757600080fd5b919050565b600060208284031215610a1e57600080fd5b610866826109f0565b600080600080600060808688031215610a3f57600080fd5b610a48866109f0565b945060208601359350610a5d604087016109f0565b925060608601356001600160401b0380821115610a7957600080fd5b818801915088601f830112610a8d57600080fd5b813581811115610a9c57600080fd5b896020828501011115610aae57600080fd5b9699959850939650602001949392505050565b634e487b7160e01b600052601160045260246000fd5b600082821015610ae957610ae9610ac1565b500390565b600181815b80851115610b29578160001904821115610b0f57610b0f610ac1565b80851615610b1c57918102915b93841c9390800290610af3565b509250929050565b600082610b4057506001610bce565b81610b4d57506000610bce565b8160018114610b635760028114610b6d57610b89565b6001915050610bce565b60ff841115610b7e57610b7e610ac1565b50506001821b610bce565b5060208310610133831016604e8410600b8410161715610bac575081810a610bce565b610bb68383610aee565b8060001904821115610bca57610bca610ac1565b0290505b92915050565b60006108668383610b31565b634e487b7160e01b600052601260045260246000fd5b600082610c0557610c05610be0565b500690565b6000816000190483118215151615610c2457610c24610ac1565b500290565b600082610c3857610c38610be0565b500490565b60208082526022908201527f446973616c6c6f7720636f6e76657273696f6e73206f66207a65726f2076616c604082015261756560f01b606082015260800190565b60008219821115610c9257610c92610ac1565b500190565b600060208284031215610ca957600080fd5b8151801515811461086657600080fd5b60005b83811015610cd4578181015183820152602001610cbc565b838111156105485750506000910152565b60008251610cf7818460208701610cb9565b9190910192915050565b6020815260008251806020840152610d20816040850160208701610cb9565b601f01601f1916919091016040019291505056fea2646970667358221220bb936fa870b05584f089c820f52c7f9fc6a018385c068e4f388d00bc8bb67c2564736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100995760003560e01c80631c060cbe1461009e57806351b83ebc146100cb57806371ca337d146100e15780637a93f256146101085780638f4ffcb114610128578063996c6cc31461013d578063c35d64ea1461017c578063cff0eac5146101a3578063de0e9a3e146101b6578063ea598cb0146101c9578063f4fc2f47146101dc575b600080fd5b6100b16100ac3660046109d7565b6101e4565b604080519283526020830191909152015b60405180910390f35b6100d361026b565b6040519081526020016100c2565b6100d37f000000000000000000000000000000000000000000000000000000000000000081565b6100d3610116366004610a0c565b60006020819052908152604090205481565b61013b610136366004610a27565b610285565b005b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6100b16101b13660046109d7565b61039e565b61013b6101c43660046109d7565b61041d565b61013b6101d73660046109d7565b61042a565b6100d3600381565b6000806101f360036012610ad7565b6101fe90600a610bd4565b6102089084610bf6565b905060006102168285610ad7565b905061022460036012610ad7565b61022f90600a610bd4565b6102597f000000000000000000000000000000000000000000000000000000000000000083610c0a565b6102639190610c29565b925050915091565b61027760036012610ad7565b61028290600a610bd4565b81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461030b5760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e206973206e6f7420746865207772617070656420746f6b656e000060448201526064015b60405180910390fd5b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461038d5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207772617070656420746f6b656e2063616c6c657220616c6c6f77656044820152601960fa1b6064820152608401610302565b6103978585610430565b5050505050565b6000806103cb7f000000000000000000000000000000000000000000000000000000000000000084610bf6565b905060006103d98285610ad7565b90507f000000000000000000000000000000000000000000000000000000000000000061040860036012610ad7565b61041390600a610bd4565b6102599083610c0a565b610427338261054e565b50565b61042733825b60008061043c836101e4565b909250905061044b8184610ad7565b92506000831161046d5760405162461bcd60e51b815260040161030290610c3d565b60408051848152602081018490526001600160a01b038616917f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a938910160405180910390a26001600160a01b038416600090815260208190526040812080548592906104d9908490610c7f565b9091555061051490506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b50505050565b60008061055a8361039e565b90925090506105698184610ad7565b92506000831161058b5760405162461bcd60e51b815260040161030290610c3d565b6001600160a01b0384166000908152602081905260409020548211156106075760405162461bcd60e51b815260206004820152602b60248201527f43616e206e6f7420756e77726170206d6f7265207468616e2070726576696f7560448201526a1cdb1e481ddc985c1c195960aa1b6064820152608401610302565b60408051848152602081018490526001600160a01b038616917ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b910160405180910390a26001600160a01b03841660009081526020819052604081208054849290610673908490610ad7565b909155506106ae90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b6040516001600160a01b03808516602483015283166044820152606481018290526105489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610782565b6040516001600160a01b03831660248201526044810182905261077d90849063a9059cbb60e01b90606401610716565b505050565b60006107d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b80519091501561077d57808060200190518101906107f59190610c97565b61077d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610302565b6060610863848460008561086d565b90505b9392505050565b6060824710156108ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610302565b6001600160a01b0385163b6109255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610302565b600080866001600160a01b031685876040516109419190610ce5565b60006040518083038185875af1925050503d806000811461097e576040519150601f19603f3d011682016040523d82523d6000602084013e610983565b606091505b509150915061099382828661099e565b979650505050505050565b606083156109ad575081610866565b8251156109bd5782518084602001fd5b8160405162461bcd60e51b81526004016103029190610d01565b6000602082840312156109e957600080fd5b5035919050565b80356001600160a01b0381168114610a0757600080fd5b919050565b600060208284031215610a1e57600080fd5b610866826109f0565b600080600080600060808688031215610a3f57600080fd5b610a48866109f0565b945060208601359350610a5d604087016109f0565b925060608601356001600160401b0380821115610a7957600080fd5b818801915088601f830112610a8d57600080fd5b813581811115610a9c57600080fd5b896020828501011115610aae57600080fd5b9699959850939650602001949392505050565b634e487b7160e01b600052601160045260246000fd5b600082821015610ae957610ae9610ac1565b500390565b600181815b80851115610b29578160001904821115610b0f57610b0f610ac1565b80851615610b1c57918102915b93841c9390800290610af3565b509250929050565b600082610b4057506001610bce565b81610b4d57506000610bce565b8160018114610b635760028114610b6d57610b89565b6001915050610bce565b60ff841115610b7e57610b7e610ac1565b50506001821b610bce565b5060208310610133831016604e8410600b8410161715610bac575081810a610bce565b610bb68383610aee565b8060001904821115610bca57610bca610ac1565b0290505b92915050565b60006108668383610b31565b634e487b7160e01b600052601260045260246000fd5b600082610c0557610c05610be0565b500690565b6000816000190483118215151615610c2457610c24610ac1565b500290565b600082610c3857610c38610be0565b500490565b60208082526022908201527f446973616c6c6f7720636f6e76657273696f6e73206f66207a65726f2076616c604082015261756560f01b606082015260800190565b60008219821115610c9257610c92610ac1565b500190565b600060208284031215610ca957600080fd5b8151801515811461086657600080fd5b60005b83811015610cd4578181015183820152602001610cbc565b838111156105485750506000910152565b60008251610cf7818460208701610cb9565b9190910192915050565b6020815260008251806020840152610d20816040850160208701610cb9565b601f01601f1916919091016040019291505056fea2646970667358221220bb936fa870b05584f089c820f52c7f9fc6a018385c068e4f388d00bc8bb67c2564736f6c63430008090033", @@ -370,7 +370,7 @@ "storageLayout": { "storage": [ { - "astId": 18594, + "astId": 18568, "contract": "contracts/vending/VendingMachine.sol:VendingMachine", "label": "wrappedBalance", "offset": 0, diff --git a/src/threshold-ts/vending-machine/dapp-development-goerli-artifacts/VendingMachineKeep.json b/src/threshold-ts/vending-machine/sepolia-artifacts/VendingMachineKeep.json similarity index 99% rename from src/threshold-ts/vending-machine/dapp-development-goerli-artifacts/VendingMachineKeep.json rename to src/threshold-ts/vending-machine/sepolia-artifacts/VendingMachineKeep.json index a00912086..883443da6 100644 --- a/src/threshold-ts/vending-machine/dapp-development-goerli-artifacts/VendingMachineKeep.json +++ b/src/threshold-ts/vending-machine/sepolia-artifacts/VendingMachineKeep.json @@ -1,5 +1,5 @@ { - "address": "0x5e30623a5ba0Cc5D278bC855a693190e205cc4B7", + "address": "0x02326F0b6DB4C99aa044E1230959c5C4b3342814", "abi": [ { "inputs": [ @@ -264,30 +264,30 @@ "type": "function" } ], - "transactionHash": "0xfd1bb897c07515645a76faca66549cad68649f497d07a36006b6292c503cdbde", + "transactionHash": "0xf315243b253a64545a5ad89a268af3863660c086f0e19e0c829c0d507e8679ea", "receipt": { "to": null, - "from": "0xfd42E065d5b128a65d752F11A1dA089f74DBf49A", - "contractAddress": "0x5e30623a5ba0Cc5D278bC855a693190e205cc4B7", - "transactionIndex": 43, - "gasUsed": "804148", + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x02326F0b6DB4C99aa044E1230959c5C4b3342814", + "transactionIndex": 29, + "gasUsed": "804410", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xe06ce87f48f8fc5220a493422541705e4961ffe08699b825db56d8fe10edfa61", - "transactionHash": "0xfd1bb897c07515645a76faca66549cad68649f497d07a36006b6292c503cdbde", + "blockHash": "0x70ac87539686fc36eb1fda78e310b811d68957ab09605d5bf32aef959027b6a2", + "transactionHash": "0xf315243b253a64545a5ad89a268af3863660c086f0e19e0c829c0d507e8679ea", "logs": [], - "blockNumber": 8259802, - "cumulativeGasUsed": "8438897", + "blockNumber": 4320496, + "cumulativeGasUsed": "4340885", "status": 1, "byzantium": true }, "args": [ - "0x22647FfAe391540d584599818CA22fdF18890753", - "0x0Be9F8916612C9Dd30B1eF3953A270A3a8b49127", + "0xa07f4E37C2E7089Ea3AFffbe51A6A281833a4D14", + "0x46abDF5aD1726ba700794539C3dB8fE591854729", "940795010800000000000000000", "4500000000000000000000000000" ], "numDeployments": 1, - "solcInputHash": "fa4158cdf7ba30d8892d97237acdb9a6", + "solcInputHash": "3e22d437f05c26959c9fff55c53befb8", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_wrappedToken\",\"type\":\"address\"},{\"internalType\":\"contract T\",\"name\":\"_tToken\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"_wrappedTokenAllocation\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"_tTokenAllocation\",\"type\":\"uint96\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wrappedTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Unwrapped\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wrappedTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Wrapped\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FLOATING_POINT_DIVISOR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WRAPPED_TOKEN_CONVERSION_PRECISION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"conversionFromT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"wrappedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tRemainder\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"conversionToT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"tAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"wrappedRemainder\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ratio\",\"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\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tToken\",\"outputs\":[{\"internalType\":\"contract T\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unwrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"wrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Multiplications in this contract can't overflow uint256 as we restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\",\"params\":{\"_tToken\":\"Address of T token\",\"_tTokenAllocation\":\"The allocation of T this instance of Vending Machine will receive\",\"_wrappedToken\":\"Address to ERC20 token that will be wrapped to T\",\"_wrappedTokenAllocation\":\"The total supply of the token that will be wrapped to T\"}},\"receiveApproval(address,uint256,address,bytes)\":{\"params\":{\"amount\":\"The amount of KEEP/NU to be wrapped\",\"from\":\"Caller's address, must be the same as `wrappedToken` field\",\"token\":\"Token's address, must be the same as `wrappedToken` field\"}},\"unwrap(uint256)\":{\"params\":{\"amount\":\"The amount of T to unwrap back to the collateral (KEEP/NU)\"}},\"wrap(uint256)\":{\"params\":{\"amount\":\"The amount of KEEP/NU to be wrapped\"}}},\"title\":\"T token vending machine\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"FLOATING_POINT_DIVISOR()\":{\"notice\":\"Divisor for precision purposes, used to represent fractions.\"},\"WRAPPED_TOKEN_CONVERSION_PRECISION()\":{\"notice\":\"Number of decimal places of precision in conversion to/from wrapped tokens (assuming typical ERC20 token with 18 decimals). This implies that amounts of wrapped tokens below this precision won't take part in the conversion. E.g., for a value of 3, then for a conversion of 1.123456789 wrapped tokens, only 1.123 is convertible (i.e., 3 decimal places), and 0.000456789 is left.\"},\"constructor\":{\"notice\":\"Sets the reference to `wrappedToken` and `tToken`. Initializes conversion `ratio` between wrapped token and T based on the provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\"},\"conversionFromT(uint256)\":{\"notice\":\"The amount of wrapped tokens (KEEP/NU) that's obtained from `amount` T tokens, and the remainder that can't be downgraded.\"},\"conversionToT(uint256)\":{\"notice\":\"Returns the T token amount that's obtained from `amount` wrapped tokens (KEEP/NU), and the remainder that can't be upgraded.\"},\"ratio()\":{\"notice\":\"The ratio with which T token is converted based on the provided token being wrapped (KEEP/NU), expressed in 1e18 precision. When wrapping: x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR When unwrapping: x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Wraps up to the given amount of the token (KEEP/NU) and releases T token proportionally to the amount being wrapped with respect to the wrap ratio. This is a shortcut to `wrap` function that avoids a separate approval transaction. Only KEEP/NU token is allowed as a caller, so please call this function via token's `approveAndCall`.\"},\"tToken()\":{\"notice\":\"T token contract.\"},\"unwrap(uint256)\":{\"notice\":\"Unwraps up to the given `amount` of T back to the legacy token (KEEP/NU) according to the wrap ratio. It can only be called by a token holder who previously wrapped their tokens in this vending machine contract. The token holder can't unwrap more tokens than they originally wrapped. The token holder needs to have at least the given amount of T tokens approved to transfer to the Vending Machine before calling this function.\"},\"wrap(uint256)\":{\"notice\":\"Wraps up to the the given `amount` of the token (KEEP/NU) and releases T token proportionally to the amount being wrapped with respect to the wrap ratio. The token holder needs to have at least the given amount of the wrapped token (KEEP/NU) approved to transfer to the Vending Machine before calling this function.\"},\"wrappedBalance(address)\":{\"notice\":\"The total balance of wrapped tokens for the given holder account. Only holders that have previously wrapped KEEP/NU to T can unwrap, up to the amount previously wrapped.\"},\"wrappedToken()\":{\"notice\":\"The token being wrapped to T (KEEP/NU).\"}},\"notice\":\"Contract implements a special update protocol to enable KEEP/NU token holders to wrap their tokens and obtain T tokens according to a fixed ratio. This will go on indefinitely and enable NU and KEEP token holders to join T network without needing to buy or sell any assets. Logistically, anyone holding NU or KEEP can wrap those assets in order to upgrade to T. They can also unwrap T in order to downgrade back to the underlying asset. There is a separate instance of this contract deployed for KEEP holders and a separate instance of this contract deployed for NU holders.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/vending/VendingMachine.sol\":\"VendingMachine\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"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 v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.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 /**\\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\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\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 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 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 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 /**\\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\",\"keccak256\":\"0x516a22876c1fab47f49b1bc22b4614491cd05338af8bd2e7b382da090a079990\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.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 SafeCast {\\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\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"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\"},\"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/token/T.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 \\\"../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\",\"keccak256\":\"0x6265416225fd15b1108fce13d570b53a862a5d256ba2e6329bccf658eccac430\",\"license\":\"GPL-3.0-or-later\"},\"contracts/vending/VendingMachine.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 \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\nimport \\\"../token/T.sol\\\";\\n\\n/// @title T token vending machine\\n/// @notice Contract implements a special update protocol to enable KEEP/NU\\n/// token holders to wrap their tokens and obtain T tokens according\\n/// to a fixed ratio. This will go on indefinitely and enable NU and\\n/// KEEP token holders to join T network without needing to buy or\\n/// sell any assets. Logistically, anyone holding NU or KEEP can wrap\\n/// those assets in order to upgrade to T. They can also unwrap T in\\n/// order to downgrade back to the underlying asset. There is a separate\\n/// instance of this contract deployed for KEEP holders and a separate\\n/// instance of this contract deployed for NU holders.\\ncontract VendingMachine is IReceiveApproval {\\n using SafeERC20 for IERC20;\\n using SafeERC20 for T;\\n\\n /// @notice Number of decimal places of precision in conversion to/from\\n /// wrapped tokens (assuming typical ERC20 token with 18 decimals).\\n /// This implies that amounts of wrapped tokens below this precision\\n /// won't take part in the conversion. E.g., for a value of 3, then\\n /// for a conversion of 1.123456789 wrapped tokens, only 1.123 is\\n /// convertible (i.e., 3 decimal places), and 0.000456789 is left.\\n uint256 public constant WRAPPED_TOKEN_CONVERSION_PRECISION = 3;\\n\\n /// @notice Divisor for precision purposes, used to represent fractions.\\n uint256 public constant FLOATING_POINT_DIVISOR =\\n 10**(18 - WRAPPED_TOKEN_CONVERSION_PRECISION);\\n\\n /// @notice The token being wrapped to T (KEEP/NU).\\n IERC20 public immutable wrappedToken;\\n\\n /// @notice T token contract.\\n T public immutable tToken;\\n\\n /// @notice The ratio with which T token is converted based on the provided\\n /// token being wrapped (KEEP/NU), expressed in 1e18 precision.\\n ///\\n /// When wrapping:\\n /// x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR\\n ///\\n /// When unwrapping:\\n /// x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\\n uint256 public immutable ratio;\\n\\n /// @notice The total balance of wrapped tokens for the given holder\\n /// account. Only holders that have previously wrapped KEEP/NU to T\\n /// can unwrap, up to the amount previously wrapped.\\n mapping(address => uint256) public wrappedBalance;\\n\\n event Wrapped(\\n address indexed recipient,\\n uint256 wrappedTokenAmount,\\n uint256 tTokenAmount\\n );\\n event Unwrapped(\\n address indexed recipient,\\n uint256 tTokenAmount,\\n uint256 wrappedTokenAmount\\n );\\n\\n /// @notice Sets the reference to `wrappedToken` and `tToken`. Initializes\\n /// conversion `ratio` between wrapped token and T based on the\\n /// provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\\n /// @param _wrappedToken Address to ERC20 token that will be wrapped to T\\n /// @param _tToken Address of T token\\n /// @param _wrappedTokenAllocation The total supply of the token that will be\\n /// wrapped to T\\n /// @param _tTokenAllocation The allocation of T this instance of Vending\\n /// Machine will receive\\n /// @dev Multiplications in this contract can't overflow uint256 as we\\n /// restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to\\n /// 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\\n constructor(\\n IERC20 _wrappedToken,\\n T _tToken,\\n uint96 _wrappedTokenAllocation,\\n uint96 _tTokenAllocation\\n ) {\\n wrappedToken = _wrappedToken;\\n tToken = _tToken;\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n\\n /// @notice Wraps up to the the given `amount` of the token (KEEP/NU) and\\n /// releases T token proportionally to the amount being wrapped with\\n /// respect to the wrap ratio. The token holder needs to have at\\n /// least the given amount of the wrapped token (KEEP/NU) approved\\n /// to transfer to the Vending Machine before calling this function.\\n /// @param amount The amount of KEEP/NU to be wrapped\\n function wrap(uint256 amount) external {\\n _wrap(msg.sender, amount);\\n }\\n\\n /// @notice Wraps up to the given amount of the token (KEEP/NU) and releases\\n /// T token proportionally to the amount being wrapped with respect\\n /// to the wrap ratio. This is a shortcut to `wrap` function that\\n /// avoids a separate approval transaction. Only KEEP/NU token\\n /// is allowed as a caller, so please call this function via\\n /// token's `approveAndCall`.\\n /// @param from Caller's address, must be the same as `wrappedToken` field\\n /// @param amount The amount of KEEP/NU to be wrapped\\n /// @param token Token's address, must be the same as `wrappedToken` field\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(\\n token == address(wrappedToken),\\n \\\"Token is not the wrapped token\\\"\\n );\\n require(\\n msg.sender == address(wrappedToken),\\n \\\"Only wrapped token caller allowed\\\"\\n );\\n _wrap(from, amount);\\n }\\n\\n /// @notice Unwraps up to the given `amount` of T back to the legacy token\\n /// (KEEP/NU) according to the wrap ratio. It can only be called by\\n /// a token holder who previously wrapped their tokens in this\\n /// vending machine contract. The token holder can't unwrap more\\n /// tokens than they originally wrapped. The token holder needs to\\n /// have at least the given amount of T tokens approved to transfer\\n /// to the Vending Machine before calling this function.\\n /// @param amount The amount of T to unwrap back to the collateral (KEEP/NU)\\n function unwrap(uint256 amount) external {\\n _unwrap(msg.sender, amount);\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` wrapped\\n /// tokens (KEEP/NU), and the remainder that can't be upgraded.\\n function conversionToT(uint256 amount)\\n public\\n view\\n returns (uint256 tAmount, uint256 wrappedRemainder)\\n {\\n wrappedRemainder = amount % FLOATING_POINT_DIVISOR;\\n uint256 convertibleAmount = amount - wrappedRemainder;\\n tAmount = (convertibleAmount * ratio) / FLOATING_POINT_DIVISOR;\\n }\\n\\n /// @notice The amount of wrapped tokens (KEEP/NU) that's obtained from\\n /// `amount` T tokens, and the remainder that can't be downgraded.\\n function conversionFromT(uint256 amount)\\n public\\n view\\n returns (uint256 wrappedAmount, uint256 tRemainder)\\n {\\n tRemainder = amount % ratio;\\n uint256 convertibleAmount = amount - tRemainder;\\n wrappedAmount = (convertibleAmount * FLOATING_POINT_DIVISOR) / ratio;\\n }\\n\\n function _wrap(address tokenHolder, uint256 wrappedTokenAmount) internal {\\n (uint256 tTokenAmount, uint256 remainder) = conversionToT(\\n wrappedTokenAmount\\n );\\n wrappedTokenAmount -= remainder;\\n require(wrappedTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n emit Wrapped(tokenHolder, wrappedTokenAmount, tTokenAmount);\\n\\n wrappedBalance[tokenHolder] += wrappedTokenAmount;\\n wrappedToken.safeTransferFrom(\\n tokenHolder,\\n address(this),\\n wrappedTokenAmount\\n );\\n tToken.safeTransfer(tokenHolder, tTokenAmount);\\n }\\n\\n function _unwrap(address tokenHolder, uint256 tTokenAmount) internal {\\n (uint256 wrappedTokenAmount, uint256 remainder) = conversionFromT(\\n tTokenAmount\\n );\\n tTokenAmount -= remainder;\\n require(tTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n require(\\n wrappedBalance[tokenHolder] >= wrappedTokenAmount,\\n \\\"Can not unwrap more than previously wrapped\\\"\\n );\\n\\n emit Unwrapped(tokenHolder, tTokenAmount, wrappedTokenAmount);\\n wrappedBalance[tokenHolder] -= wrappedTokenAmount;\\n tToken.safeTransferFrom(tokenHolder, address(this), tTokenAmount);\\n wrappedToken.safeTransfer(tokenHolder, wrappedTokenAmount);\\n }\\n}\\n\",\"keccak256\":\"0xa4e7de5a9063db09b32ca97fa0fb5d8d1cc7b539387d1b44d74d15d3c2ed4134\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", "bytecode": "0x60e06040523480156200001157600080fd5b506040516200108f3803806200108f8339810160408190526200003491620000cc565b6001600160a01b03808516608052831660a0526001600160601b03808316908216620000636003601262000144565b6200007090600a6200025d565b6200007c919062000272565b62000088919062000294565b60c05250620002b792505050565b6001600160a01b0381168114620000ac57600080fd5b50565b80516001600160601b0381168114620000c757600080fd5b919050565b60008060008060808587031215620000e357600080fd5b8451620000f08162000096565b6020860151909450620001038162000096565b92506200011360408601620000af565b91506200012360608601620000af565b905092959194509250565b634e487b7160e01b600052601160045260246000fd5b6000828210156200015957620001596200012e565b500390565b600181815b808511156200019f5781600019048211156200018357620001836200012e565b808516156200019157918102915b93841c939080029062000163565b509250929050565b600082620001b85750600162000257565b81620001c75750600062000257565b8160018114620001e05760028114620001eb576200020b565b600191505062000257565b60ff841115620001ff57620001ff6200012e565b50506001821b62000257565b5060208310610133831016604e8410600b841016171562000230575081810a62000257565b6200023c83836200015e565b80600019048211156200025357620002536200012e565b0290505b92915050565b60006200026b8383620001a7565b9392505050565b60008160001904831182151516156200028f576200028f6200012e565b500290565b600082620002b257634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c051610d6a620003256000396000818160e601528181610234015281816103a601526103dd0152600081816101810152818161052101526106860152600081816101420152818161028701528181610316015281816104ec01526106bb0152610d6a6000f3fe608060405234801561001057600080fd5b50600436106100995760003560e01c80631c060cbe1461009e57806351b83ebc146100cb57806371ca337d146100e15780637a93f256146101085780638f4ffcb114610128578063996c6cc31461013d578063c35d64ea1461017c578063cff0eac5146101a3578063de0e9a3e146101b6578063ea598cb0146101c9578063f4fc2f47146101dc575b600080fd5b6100b16100ac3660046109d7565b6101e4565b604080519283526020830191909152015b60405180910390f35b6100d361026b565b6040519081526020016100c2565b6100d37f000000000000000000000000000000000000000000000000000000000000000081565b6100d3610116366004610a0c565b60006020819052908152604090205481565b61013b610136366004610a27565b610285565b005b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6100b16101b13660046109d7565b61039e565b61013b6101c43660046109d7565b61041d565b61013b6101d73660046109d7565b61042a565b6100d3600381565b6000806101f360036012610ad7565b6101fe90600a610bd4565b6102089084610bf6565b905060006102168285610ad7565b905061022460036012610ad7565b61022f90600a610bd4565b6102597f000000000000000000000000000000000000000000000000000000000000000083610c0a565b6102639190610c29565b925050915091565b61027760036012610ad7565b61028290600a610bd4565b81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461030b5760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e206973206e6f7420746865207772617070656420746f6b656e000060448201526064015b60405180910390fd5b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461038d5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207772617070656420746f6b656e2063616c6c657220616c6c6f77656044820152601960fa1b6064820152608401610302565b6103978585610430565b5050505050565b6000806103cb7f000000000000000000000000000000000000000000000000000000000000000084610bf6565b905060006103d98285610ad7565b90507f000000000000000000000000000000000000000000000000000000000000000061040860036012610ad7565b61041390600a610bd4565b6102599083610c0a565b610427338261054e565b50565b61042733825b60008061043c836101e4565b909250905061044b8184610ad7565b92506000831161046d5760405162461bcd60e51b815260040161030290610c3d565b60408051848152602081018490526001600160a01b038616917f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a938910160405180910390a26001600160a01b038416600090815260208190526040812080548592906104d9908490610c7f565b9091555061051490506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b50505050565b60008061055a8361039e565b90925090506105698184610ad7565b92506000831161058b5760405162461bcd60e51b815260040161030290610c3d565b6001600160a01b0384166000908152602081905260409020548211156106075760405162461bcd60e51b815260206004820152602b60248201527f43616e206e6f7420756e77726170206d6f7265207468616e2070726576696f7560448201526a1cdb1e481ddc985c1c195960aa1b6064820152608401610302565b60408051848152602081018490526001600160a01b038616917ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b910160405180910390a26001600160a01b03841660009081526020819052604081208054849290610673908490610ad7565b909155506106ae90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b6040516001600160a01b03808516602483015283166044820152606481018290526105489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610782565b6040516001600160a01b03831660248201526044810182905261077d90849063a9059cbb60e01b90606401610716565b505050565b60006107d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b80519091501561077d57808060200190518101906107f59190610c97565b61077d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610302565b6060610863848460008561086d565b90505b9392505050565b6060824710156108ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610302565b6001600160a01b0385163b6109255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610302565b600080866001600160a01b031685876040516109419190610ce5565b60006040518083038185875af1925050503d806000811461097e576040519150601f19603f3d011682016040523d82523d6000602084013e610983565b606091505b509150915061099382828661099e565b979650505050505050565b606083156109ad575081610866565b8251156109bd5782518084602001fd5b8160405162461bcd60e51b81526004016103029190610d01565b6000602082840312156109e957600080fd5b5035919050565b80356001600160a01b0381168114610a0757600080fd5b919050565b600060208284031215610a1e57600080fd5b610866826109f0565b600080600080600060808688031215610a3f57600080fd5b610a48866109f0565b945060208601359350610a5d604087016109f0565b925060608601356001600160401b0380821115610a7957600080fd5b818801915088601f830112610a8d57600080fd5b813581811115610a9c57600080fd5b896020828501011115610aae57600080fd5b9699959850939650602001949392505050565b634e487b7160e01b600052601160045260246000fd5b600082821015610ae957610ae9610ac1565b500390565b600181815b80851115610b29578160001904821115610b0f57610b0f610ac1565b80851615610b1c57918102915b93841c9390800290610af3565b509250929050565b600082610b4057506001610bce565b81610b4d57506000610bce565b8160018114610b635760028114610b6d57610b89565b6001915050610bce565b60ff841115610b7e57610b7e610ac1565b50506001821b610bce565b5060208310610133831016604e8410600b8410161715610bac575081810a610bce565b610bb68383610aee565b8060001904821115610bca57610bca610ac1565b0290505b92915050565b60006108668383610b31565b634e487b7160e01b600052601260045260246000fd5b600082610c0557610c05610be0565b500690565b6000816000190483118215151615610c2457610c24610ac1565b500290565b600082610c3857610c38610be0565b500490565b60208082526022908201527f446973616c6c6f7720636f6e76657273696f6e73206f66207a65726f2076616c604082015261756560f01b606082015260800190565b60008219821115610c9257610c92610ac1565b500190565b600060208284031215610ca957600080fd5b8151801515811461086657600080fd5b60005b83811015610cd4578181015183820152602001610cbc565b838111156105485750506000910152565b60008251610cf7818460208701610cb9565b9190910192915050565b6020815260008251806020840152610d20816040850160208701610cb9565b601f01601f1916919091016040019291505056fea2646970667358221220bb936fa870b05584f089c820f52c7f9fc6a018385c068e4f388d00bc8bb67c2564736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100995760003560e01c80631c060cbe1461009e57806351b83ebc146100cb57806371ca337d146100e15780637a93f256146101085780638f4ffcb114610128578063996c6cc31461013d578063c35d64ea1461017c578063cff0eac5146101a3578063de0e9a3e146101b6578063ea598cb0146101c9578063f4fc2f47146101dc575b600080fd5b6100b16100ac3660046109d7565b6101e4565b604080519283526020830191909152015b60405180910390f35b6100d361026b565b6040519081526020016100c2565b6100d37f000000000000000000000000000000000000000000000000000000000000000081565b6100d3610116366004610a0c565b60006020819052908152604090205481565b61013b610136366004610a27565b610285565b005b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6100b16101b13660046109d7565b61039e565b61013b6101c43660046109d7565b61041d565b61013b6101d73660046109d7565b61042a565b6100d3600381565b6000806101f360036012610ad7565b6101fe90600a610bd4565b6102089084610bf6565b905060006102168285610ad7565b905061022460036012610ad7565b61022f90600a610bd4565b6102597f000000000000000000000000000000000000000000000000000000000000000083610c0a565b6102639190610c29565b925050915091565b61027760036012610ad7565b61028290600a610bd4565b81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461030b5760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e206973206e6f7420746865207772617070656420746f6b656e000060448201526064015b60405180910390fd5b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461038d5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207772617070656420746f6b656e2063616c6c657220616c6c6f77656044820152601960fa1b6064820152608401610302565b6103978585610430565b5050505050565b6000806103cb7f000000000000000000000000000000000000000000000000000000000000000084610bf6565b905060006103d98285610ad7565b90507f000000000000000000000000000000000000000000000000000000000000000061040860036012610ad7565b61041390600a610bd4565b6102599083610c0a565b610427338261054e565b50565b61042733825b60008061043c836101e4565b909250905061044b8184610ad7565b92506000831161046d5760405162461bcd60e51b815260040161030290610c3d565b60408051848152602081018490526001600160a01b038616917f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a938910160405180910390a26001600160a01b038416600090815260208190526040812080548592906104d9908490610c7f565b9091555061051490506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b50505050565b60008061055a8361039e565b90925090506105698184610ad7565b92506000831161058b5760405162461bcd60e51b815260040161030290610c3d565b6001600160a01b0384166000908152602081905260409020548211156106075760405162461bcd60e51b815260206004820152602b60248201527f43616e206e6f7420756e77726170206d6f7265207468616e2070726576696f7560448201526a1cdb1e481ddc985c1c195960aa1b6064820152608401610302565b60408051848152602081018490526001600160a01b038616917ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b910160405180910390a26001600160a01b03841660009081526020819052604081208054849290610673908490610ad7565b909155506106ae90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b6040516001600160a01b03808516602483015283166044820152606481018290526105489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610782565b6040516001600160a01b03831660248201526044810182905261077d90849063a9059cbb60e01b90606401610716565b505050565b60006107d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b80519091501561077d57808060200190518101906107f59190610c97565b61077d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610302565b6060610863848460008561086d565b90505b9392505050565b6060824710156108ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610302565b6001600160a01b0385163b6109255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610302565b600080866001600160a01b031685876040516109419190610ce5565b60006040518083038185875af1925050503d806000811461097e576040519150601f19603f3d011682016040523d82523d6000602084013e610983565b606091505b509150915061099382828661099e565b979650505050505050565b606083156109ad575081610866565b8251156109bd5782518084602001fd5b8160405162461bcd60e51b81526004016103029190610d01565b6000602082840312156109e957600080fd5b5035919050565b80356001600160a01b0381168114610a0757600080fd5b919050565b600060208284031215610a1e57600080fd5b610866826109f0565b600080600080600060808688031215610a3f57600080fd5b610a48866109f0565b945060208601359350610a5d604087016109f0565b925060608601356001600160401b0380821115610a7957600080fd5b818801915088601f830112610a8d57600080fd5b813581811115610a9c57600080fd5b896020828501011115610aae57600080fd5b9699959850939650602001949392505050565b634e487b7160e01b600052601160045260246000fd5b600082821015610ae957610ae9610ac1565b500390565b600181815b80851115610b29578160001904821115610b0f57610b0f610ac1565b80851615610b1c57918102915b93841c9390800290610af3565b509250929050565b600082610b4057506001610bce565b81610b4d57506000610bce565b8160018114610b635760028114610b6d57610b89565b6001915050610bce565b60ff841115610b7e57610b7e610ac1565b50506001821b610bce565b5060208310610133831016604e8410600b8410161715610bac575081810a610bce565b610bb68383610aee565b8060001904821115610bca57610bca610ac1565b0290505b92915050565b60006108668383610b31565b634e487b7160e01b600052601260045260246000fd5b600082610c0557610c05610be0565b500690565b6000816000190483118215151615610c2457610c24610ac1565b500290565b600082610c3857610c38610be0565b500490565b60208082526022908201527f446973616c6c6f7720636f6e76657273696f6e73206f66207a65726f2076616c604082015261756560f01b606082015260800190565b60008219821115610c9257610c92610ac1565b500190565b600060208284031215610ca957600080fd5b8151801515811461086657600080fd5b60005b83811015610cd4578181015183820152602001610cbc565b838111156105485750506000910152565b60008251610cf7818460208701610cb9565b9190910192915050565b6020815260008251806020840152610d20816040850160208701610cb9565b601f01601f1916919091016040019291505056fea2646970667358221220bb936fa870b05584f089c820f52c7f9fc6a018385c068e4f388d00bc8bb67c2564736f6c63430008090033", @@ -370,7 +370,7 @@ "storageLayout": { "storage": [ { - "astId": 18594, + "astId": 18568, "contract": "contracts/vending/VendingMachine.sol:VendingMachine", "label": "wrappedBalance", "offset": 0, diff --git a/src/threshold-ts/vending-machine/dapp-development-goerli-artifacts/VendingMachineNuCypher.json b/src/threshold-ts/vending-machine/sepolia-artifacts/VendingMachineNuCypher.json similarity index 99% rename from src/threshold-ts/vending-machine/dapp-development-goerli-artifacts/VendingMachineNuCypher.json rename to src/threshold-ts/vending-machine/sepolia-artifacts/VendingMachineNuCypher.json index d493d35ae..3474288d6 100644 --- a/src/threshold-ts/vending-machine/dapp-development-goerli-artifacts/VendingMachineNuCypher.json +++ b/src/threshold-ts/vending-machine/sepolia-artifacts/VendingMachineNuCypher.json @@ -1,5 +1,5 @@ { - "address": "0x0b71401e9B151e737F9dC03dd4F53fAD6F4c0D0b", + "address": "0x62aFAAcD5375B52F9e50485AD52309C0C1673185", "abi": [ { "inputs": [ @@ -264,30 +264,30 @@ "type": "function" } ], - "transactionHash": "0x30c4661a684631f95a7ffcbc49cf5079ff2d57b680304ff1fb38157769974fb2", + "transactionHash": "0x4a54f7db5286c5fb50eee764ec7780fdeded58879cb8c6cf2589e29725fc6657", "receipt": { "to": null, - "from": "0xfd42E065d5b128a65d752F11A1dA089f74DBf49A", - "contractAddress": "0x0b71401e9B151e737F9dC03dd4F53fAD6F4c0D0b", - "transactionIndex": 166, - "gasUsed": "804160", + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x62aFAAcD5375B52F9e50485AD52309C0C1673185", + "transactionIndex": 78, + "gasUsed": "804422", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc7b570be747af7972cf1105bc179bce5101ca4bc223207ea72ed0c4a57fbb88a", - "transactionHash": "0x30c4661a684631f95a7ffcbc49cf5079ff2d57b680304ff1fb38157769974fb2", + "blockHash": "0x9917911254dbb95cb9f714dc73fae0b109449ae74037c69bb59b87e953afc6a1", + "transactionHash": "0x4a54f7db5286c5fb50eee764ec7780fdeded58879cb8c6cf2589e29725fc6657", "logs": [], - "blockNumber": 8259804, - "cumulativeGasUsed": "11144075", + "blockNumber": 4320498, + "cumulativeGasUsed": "15762613", "status": 1, "byzantium": true }, "args": [ - "0x0aCB1570e4a17C8A4d41A29906E2e2FD4670148c", - "0x0Be9F8916612C9Dd30B1eF3953A270A3a8b49127", + "0x805ff4312f99f01F8CC4138858D62c10f35eA4DF", + "0x46abDF5aD1726ba700794539C3dB8fE591854729", "1380688920644254727736959922", "4500000000000000000000000000" ], "numDeployments": 1, - "solcInputHash": "fa4158cdf7ba30d8892d97237acdb9a6", + "solcInputHash": "3e22d437f05c26959c9fff55c53befb8", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_wrappedToken\",\"type\":\"address\"},{\"internalType\":\"contract T\",\"name\":\"_tToken\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"_wrappedTokenAllocation\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"_tTokenAllocation\",\"type\":\"uint96\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wrappedTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Unwrapped\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wrappedTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tTokenAmount\",\"type\":\"uint256\"}],\"name\":\"Wrapped\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FLOATING_POINT_DIVISOR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WRAPPED_TOKEN_CONVERSION_PRECISION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"conversionFromT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"wrappedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tRemainder\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"conversionToT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"tAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"wrappedRemainder\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ratio\",\"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\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tToken\",\"outputs\":[{\"internalType\":\"contract T\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unwrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"wrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Multiplications in this contract can't overflow uint256 as we restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\",\"params\":{\"_tToken\":\"Address of T token\",\"_tTokenAllocation\":\"The allocation of T this instance of Vending Machine will receive\",\"_wrappedToken\":\"Address to ERC20 token that will be wrapped to T\",\"_wrappedTokenAllocation\":\"The total supply of the token that will be wrapped to T\"}},\"receiveApproval(address,uint256,address,bytes)\":{\"params\":{\"amount\":\"The amount of KEEP/NU to be wrapped\",\"from\":\"Caller's address, must be the same as `wrappedToken` field\",\"token\":\"Token's address, must be the same as `wrappedToken` field\"}},\"unwrap(uint256)\":{\"params\":{\"amount\":\"The amount of T to unwrap back to the collateral (KEEP/NU)\"}},\"wrap(uint256)\":{\"params\":{\"amount\":\"The amount of KEEP/NU to be wrapped\"}}},\"title\":\"T token vending machine\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"FLOATING_POINT_DIVISOR()\":{\"notice\":\"Divisor for precision purposes, used to represent fractions.\"},\"WRAPPED_TOKEN_CONVERSION_PRECISION()\":{\"notice\":\"Number of decimal places of precision in conversion to/from wrapped tokens (assuming typical ERC20 token with 18 decimals). This implies that amounts of wrapped tokens below this precision won't take part in the conversion. E.g., for a value of 3, then for a conversion of 1.123456789 wrapped tokens, only 1.123 is convertible (i.e., 3 decimal places), and 0.000456789 is left.\"},\"constructor\":{\"notice\":\"Sets the reference to `wrappedToken` and `tToken`. Initializes conversion `ratio` between wrapped token and T based on the provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\"},\"conversionFromT(uint256)\":{\"notice\":\"The amount of wrapped tokens (KEEP/NU) that's obtained from `amount` T tokens, and the remainder that can't be downgraded.\"},\"conversionToT(uint256)\":{\"notice\":\"Returns the T token amount that's obtained from `amount` wrapped tokens (KEEP/NU), and the remainder that can't be upgraded.\"},\"ratio()\":{\"notice\":\"The ratio with which T token is converted based on the provided token being wrapped (KEEP/NU), expressed in 1e18 precision. When wrapping: x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR When unwrapping: x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Wraps up to the given amount of the token (KEEP/NU) and releases T token proportionally to the amount being wrapped with respect to the wrap ratio. This is a shortcut to `wrap` function that avoids a separate approval transaction. Only KEEP/NU token is allowed as a caller, so please call this function via token's `approveAndCall`.\"},\"tToken()\":{\"notice\":\"T token contract.\"},\"unwrap(uint256)\":{\"notice\":\"Unwraps up to the given `amount` of T back to the legacy token (KEEP/NU) according to the wrap ratio. It can only be called by a token holder who previously wrapped their tokens in this vending machine contract. The token holder can't unwrap more tokens than they originally wrapped. The token holder needs to have at least the given amount of T tokens approved to transfer to the Vending Machine before calling this function.\"},\"wrap(uint256)\":{\"notice\":\"Wraps up to the the given `amount` of the token (KEEP/NU) and releases T token proportionally to the amount being wrapped with respect to the wrap ratio. The token holder needs to have at least the given amount of the wrapped token (KEEP/NU) approved to transfer to the Vending Machine before calling this function.\"},\"wrappedBalance(address)\":{\"notice\":\"The total balance of wrapped tokens for the given holder account. Only holders that have previously wrapped KEEP/NU to T can unwrap, up to the amount previously wrapped.\"},\"wrappedToken()\":{\"notice\":\"The token being wrapped to T (KEEP/NU).\"}},\"notice\":\"Contract implements a special update protocol to enable KEEP/NU token holders to wrap their tokens and obtain T tokens according to a fixed ratio. This will go on indefinitely and enable NU and KEEP token holders to join T network without needing to buy or sell any assets. Logistically, anyone holding NU or KEEP can wrap those assets in order to upgrade to T. They can also unwrap T in order to downgrade back to the underlying asset. There is a separate instance of this contract deployed for KEEP holders and a separate instance of this contract deployed for NU holders.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/vending/VendingMachine.sol\":\"VendingMachine\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10},\"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 v4.4.1 (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 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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\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\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 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 /**\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"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/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.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 /**\\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\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\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 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 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 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 /**\\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\",\"keccak256\":\"0x516a22876c1fab47f49b1bc22b4614491cd05338af8bd2e7b382da090a079990\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, \\\"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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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\\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}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"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/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\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.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 SafeCast {\\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\":\"0x5c6caab697d302ad7eb59c234a4d2dbc965c1bae87709bd2850060b7695b28c7\",\"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\"},\"@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\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"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\"},\"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/token/T.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 \\\"../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\",\"keccak256\":\"0x6265416225fd15b1108fce13d570b53a862a5d256ba2e6329bccf658eccac430\",\"license\":\"GPL-3.0-or-later\"},\"contracts/vending/VendingMachine.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 \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\nimport \\\"../token/T.sol\\\";\\n\\n/// @title T token vending machine\\n/// @notice Contract implements a special update protocol to enable KEEP/NU\\n/// token holders to wrap their tokens and obtain T tokens according\\n/// to a fixed ratio. This will go on indefinitely and enable NU and\\n/// KEEP token holders to join T network without needing to buy or\\n/// sell any assets. Logistically, anyone holding NU or KEEP can wrap\\n/// those assets in order to upgrade to T. They can also unwrap T in\\n/// order to downgrade back to the underlying asset. There is a separate\\n/// instance of this contract deployed for KEEP holders and a separate\\n/// instance of this contract deployed for NU holders.\\ncontract VendingMachine is IReceiveApproval {\\n using SafeERC20 for IERC20;\\n using SafeERC20 for T;\\n\\n /// @notice Number of decimal places of precision in conversion to/from\\n /// wrapped tokens (assuming typical ERC20 token with 18 decimals).\\n /// This implies that amounts of wrapped tokens below this precision\\n /// won't take part in the conversion. E.g., for a value of 3, then\\n /// for a conversion of 1.123456789 wrapped tokens, only 1.123 is\\n /// convertible (i.e., 3 decimal places), and 0.000456789 is left.\\n uint256 public constant WRAPPED_TOKEN_CONVERSION_PRECISION = 3;\\n\\n /// @notice Divisor for precision purposes, used to represent fractions.\\n uint256 public constant FLOATING_POINT_DIVISOR =\\n 10**(18 - WRAPPED_TOKEN_CONVERSION_PRECISION);\\n\\n /// @notice The token being wrapped to T (KEEP/NU).\\n IERC20 public immutable wrappedToken;\\n\\n /// @notice T token contract.\\n T public immutable tToken;\\n\\n /// @notice The ratio with which T token is converted based on the provided\\n /// token being wrapped (KEEP/NU), expressed in 1e18 precision.\\n ///\\n /// When wrapping:\\n /// x [T] = amount [KEEP/NU] * ratio / FLOATING_POINT_DIVISOR\\n ///\\n /// When unwrapping:\\n /// x [KEEP/NU] = amount [T] * FLOATING_POINT_DIVISOR / ratio\\n uint256 public immutable ratio;\\n\\n /// @notice The total balance of wrapped tokens for the given holder\\n /// account. Only holders that have previously wrapped KEEP/NU to T\\n /// can unwrap, up to the amount previously wrapped.\\n mapping(address => uint256) public wrappedBalance;\\n\\n event Wrapped(\\n address indexed recipient,\\n uint256 wrappedTokenAmount,\\n uint256 tTokenAmount\\n );\\n event Unwrapped(\\n address indexed recipient,\\n uint256 tTokenAmount,\\n uint256 wrappedTokenAmount\\n );\\n\\n /// @notice Sets the reference to `wrappedToken` and `tToken`. Initializes\\n /// conversion `ratio` between wrapped token and T based on the\\n /// provided `_tTokenAllocation` and `_wrappedTokenAllocation`.\\n /// @param _wrappedToken Address to ERC20 token that will be wrapped to T\\n /// @param _tToken Address of T token\\n /// @param _wrappedTokenAllocation The total supply of the token that will be\\n /// wrapped to T\\n /// @param _tTokenAllocation The allocation of T this instance of Vending\\n /// Machine will receive\\n /// @dev Multiplications in this contract can't overflow uint256 as we\\n /// restrict `_wrappedTokenAllocation` and `_tTokenAllocation` to\\n /// 96 bits and FLOATING_POINT_DIVISOR fits in less than 60 bits.\\n constructor(\\n IERC20 _wrappedToken,\\n T _tToken,\\n uint96 _wrappedTokenAllocation,\\n uint96 _tTokenAllocation\\n ) {\\n wrappedToken = _wrappedToken;\\n tToken = _tToken;\\n ratio =\\n (FLOATING_POINT_DIVISOR * _tTokenAllocation) /\\n _wrappedTokenAllocation;\\n }\\n\\n /// @notice Wraps up to the the given `amount` of the token (KEEP/NU) and\\n /// releases T token proportionally to the amount being wrapped with\\n /// respect to the wrap ratio. The token holder needs to have at\\n /// least the given amount of the wrapped token (KEEP/NU) approved\\n /// to transfer to the Vending Machine before calling this function.\\n /// @param amount The amount of KEEP/NU to be wrapped\\n function wrap(uint256 amount) external {\\n _wrap(msg.sender, amount);\\n }\\n\\n /// @notice Wraps up to the given amount of the token (KEEP/NU) and releases\\n /// T token proportionally to the amount being wrapped with respect\\n /// to the wrap ratio. This is a shortcut to `wrap` function that\\n /// avoids a separate approval transaction. Only KEEP/NU token\\n /// is allowed as a caller, so please call this function via\\n /// token's `approveAndCall`.\\n /// @param from Caller's address, must be the same as `wrappedToken` field\\n /// @param amount The amount of KEEP/NU to be wrapped\\n /// @param token Token's address, must be the same as `wrappedToken` field\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(\\n token == address(wrappedToken),\\n \\\"Token is not the wrapped token\\\"\\n );\\n require(\\n msg.sender == address(wrappedToken),\\n \\\"Only wrapped token caller allowed\\\"\\n );\\n _wrap(from, amount);\\n }\\n\\n /// @notice Unwraps up to the given `amount` of T back to the legacy token\\n /// (KEEP/NU) according to the wrap ratio. It can only be called by\\n /// a token holder who previously wrapped their tokens in this\\n /// vending machine contract. The token holder can't unwrap more\\n /// tokens than they originally wrapped. The token holder needs to\\n /// have at least the given amount of T tokens approved to transfer\\n /// to the Vending Machine before calling this function.\\n /// @param amount The amount of T to unwrap back to the collateral (KEEP/NU)\\n function unwrap(uint256 amount) external {\\n _unwrap(msg.sender, amount);\\n }\\n\\n /// @notice Returns the T token amount that's obtained from `amount` wrapped\\n /// tokens (KEEP/NU), and the remainder that can't be upgraded.\\n function conversionToT(uint256 amount)\\n public\\n view\\n returns (uint256 tAmount, uint256 wrappedRemainder)\\n {\\n wrappedRemainder = amount % FLOATING_POINT_DIVISOR;\\n uint256 convertibleAmount = amount - wrappedRemainder;\\n tAmount = (convertibleAmount * ratio) / FLOATING_POINT_DIVISOR;\\n }\\n\\n /// @notice The amount of wrapped tokens (KEEP/NU) that's obtained from\\n /// `amount` T tokens, and the remainder that can't be downgraded.\\n function conversionFromT(uint256 amount)\\n public\\n view\\n returns (uint256 wrappedAmount, uint256 tRemainder)\\n {\\n tRemainder = amount % ratio;\\n uint256 convertibleAmount = amount - tRemainder;\\n wrappedAmount = (convertibleAmount * FLOATING_POINT_DIVISOR) / ratio;\\n }\\n\\n function _wrap(address tokenHolder, uint256 wrappedTokenAmount) internal {\\n (uint256 tTokenAmount, uint256 remainder) = conversionToT(\\n wrappedTokenAmount\\n );\\n wrappedTokenAmount -= remainder;\\n require(wrappedTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n emit Wrapped(tokenHolder, wrappedTokenAmount, tTokenAmount);\\n\\n wrappedBalance[tokenHolder] += wrappedTokenAmount;\\n wrappedToken.safeTransferFrom(\\n tokenHolder,\\n address(this),\\n wrappedTokenAmount\\n );\\n tToken.safeTransfer(tokenHolder, tTokenAmount);\\n }\\n\\n function _unwrap(address tokenHolder, uint256 tTokenAmount) internal {\\n (uint256 wrappedTokenAmount, uint256 remainder) = conversionFromT(\\n tTokenAmount\\n );\\n tTokenAmount -= remainder;\\n require(tTokenAmount > 0, \\\"Disallow conversions of zero value\\\");\\n require(\\n wrappedBalance[tokenHolder] >= wrappedTokenAmount,\\n \\\"Can not unwrap more than previously wrapped\\\"\\n );\\n\\n emit Unwrapped(tokenHolder, tTokenAmount, wrappedTokenAmount);\\n wrappedBalance[tokenHolder] -= wrappedTokenAmount;\\n tToken.safeTransferFrom(tokenHolder, address(this), tTokenAmount);\\n wrappedToken.safeTransfer(tokenHolder, wrappedTokenAmount);\\n }\\n}\\n\",\"keccak256\":\"0xa4e7de5a9063db09b32ca97fa0fb5d8d1cc7b539387d1b44d74d15d3c2ed4134\",\"license\":\"GPL-3.0-or-later\"}},\"version\":1}", "bytecode": "0x60e06040523480156200001157600080fd5b506040516200108f3803806200108f8339810160408190526200003491620000cc565b6001600160a01b03808516608052831660a0526001600160601b03808316908216620000636003601262000144565b6200007090600a6200025d565b6200007c919062000272565b62000088919062000294565b60c05250620002b792505050565b6001600160a01b0381168114620000ac57600080fd5b50565b80516001600160601b0381168114620000c757600080fd5b919050565b60008060008060808587031215620000e357600080fd5b8451620000f08162000096565b6020860151909450620001038162000096565b92506200011360408601620000af565b91506200012360608601620000af565b905092959194509250565b634e487b7160e01b600052601160045260246000fd5b6000828210156200015957620001596200012e565b500390565b600181815b808511156200019f5781600019048211156200018357620001836200012e565b808516156200019157918102915b93841c939080029062000163565b509250929050565b600082620001b85750600162000257565b81620001c75750600062000257565b8160018114620001e05760028114620001eb576200020b565b600191505062000257565b60ff841115620001ff57620001ff6200012e565b50506001821b62000257565b5060208310610133831016604e8410600b841016171562000230575081810a62000257565b6200023c83836200015e565b80600019048211156200025357620002536200012e565b0290505b92915050565b60006200026b8383620001a7565b9392505050565b60008160001904831182151516156200028f576200028f6200012e565b500290565b600082620002b257634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05160c051610d6a620003256000396000818160e601528181610234015281816103a601526103dd0152600081816101810152818161052101526106860152600081816101420152818161028701528181610316015281816104ec01526106bb0152610d6a6000f3fe608060405234801561001057600080fd5b50600436106100995760003560e01c80631c060cbe1461009e57806351b83ebc146100cb57806371ca337d146100e15780637a93f256146101085780638f4ffcb114610128578063996c6cc31461013d578063c35d64ea1461017c578063cff0eac5146101a3578063de0e9a3e146101b6578063ea598cb0146101c9578063f4fc2f47146101dc575b600080fd5b6100b16100ac3660046109d7565b6101e4565b604080519283526020830191909152015b60405180910390f35b6100d361026b565b6040519081526020016100c2565b6100d37f000000000000000000000000000000000000000000000000000000000000000081565b6100d3610116366004610a0c565b60006020819052908152604090205481565b61013b610136366004610a27565b610285565b005b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6100b16101b13660046109d7565b61039e565b61013b6101c43660046109d7565b61041d565b61013b6101d73660046109d7565b61042a565b6100d3600381565b6000806101f360036012610ad7565b6101fe90600a610bd4565b6102089084610bf6565b905060006102168285610ad7565b905061022460036012610ad7565b61022f90600a610bd4565b6102597f000000000000000000000000000000000000000000000000000000000000000083610c0a565b6102639190610c29565b925050915091565b61027760036012610ad7565b61028290600a610bd4565b81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461030b5760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e206973206e6f7420746865207772617070656420746f6b656e000060448201526064015b60405180910390fd5b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461038d5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207772617070656420746f6b656e2063616c6c657220616c6c6f77656044820152601960fa1b6064820152608401610302565b6103978585610430565b5050505050565b6000806103cb7f000000000000000000000000000000000000000000000000000000000000000084610bf6565b905060006103d98285610ad7565b90507f000000000000000000000000000000000000000000000000000000000000000061040860036012610ad7565b61041390600a610bd4565b6102599083610c0a565b610427338261054e565b50565b61042733825b60008061043c836101e4565b909250905061044b8184610ad7565b92506000831161046d5760405162461bcd60e51b815260040161030290610c3d565b60408051848152602081018490526001600160a01b038616917f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a938910160405180910390a26001600160a01b038416600090815260208190526040812080548592906104d9908490610c7f565b9091555061051490506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b50505050565b60008061055a8361039e565b90925090506105698184610ad7565b92506000831161058b5760405162461bcd60e51b815260040161030290610c3d565b6001600160a01b0384166000908152602081905260409020548211156106075760405162461bcd60e51b815260206004820152602b60248201527f43616e206e6f7420756e77726170206d6f7265207468616e2070726576696f7560448201526a1cdb1e481ddc985c1c195960aa1b6064820152608401610302565b60408051848152602081018490526001600160a01b038616917ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b910160405180910390a26001600160a01b03841660009081526020819052604081208054849290610673908490610ad7565b909155506106ae90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b6040516001600160a01b03808516602483015283166044820152606481018290526105489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610782565b6040516001600160a01b03831660248201526044810182905261077d90849063a9059cbb60e01b90606401610716565b505050565b60006107d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b80519091501561077d57808060200190518101906107f59190610c97565b61077d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610302565b6060610863848460008561086d565b90505b9392505050565b6060824710156108ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610302565b6001600160a01b0385163b6109255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610302565b600080866001600160a01b031685876040516109419190610ce5565b60006040518083038185875af1925050503d806000811461097e576040519150601f19603f3d011682016040523d82523d6000602084013e610983565b606091505b509150915061099382828661099e565b979650505050505050565b606083156109ad575081610866565b8251156109bd5782518084602001fd5b8160405162461bcd60e51b81526004016103029190610d01565b6000602082840312156109e957600080fd5b5035919050565b80356001600160a01b0381168114610a0757600080fd5b919050565b600060208284031215610a1e57600080fd5b610866826109f0565b600080600080600060808688031215610a3f57600080fd5b610a48866109f0565b945060208601359350610a5d604087016109f0565b925060608601356001600160401b0380821115610a7957600080fd5b818801915088601f830112610a8d57600080fd5b813581811115610a9c57600080fd5b896020828501011115610aae57600080fd5b9699959850939650602001949392505050565b634e487b7160e01b600052601160045260246000fd5b600082821015610ae957610ae9610ac1565b500390565b600181815b80851115610b29578160001904821115610b0f57610b0f610ac1565b80851615610b1c57918102915b93841c9390800290610af3565b509250929050565b600082610b4057506001610bce565b81610b4d57506000610bce565b8160018114610b635760028114610b6d57610b89565b6001915050610bce565b60ff841115610b7e57610b7e610ac1565b50506001821b610bce565b5060208310610133831016604e8410600b8410161715610bac575081810a610bce565b610bb68383610aee565b8060001904821115610bca57610bca610ac1565b0290505b92915050565b60006108668383610b31565b634e487b7160e01b600052601260045260246000fd5b600082610c0557610c05610be0565b500690565b6000816000190483118215151615610c2457610c24610ac1565b500290565b600082610c3857610c38610be0565b500490565b60208082526022908201527f446973616c6c6f7720636f6e76657273696f6e73206f66207a65726f2076616c604082015261756560f01b606082015260800190565b60008219821115610c9257610c92610ac1565b500190565b600060208284031215610ca957600080fd5b8151801515811461086657600080fd5b60005b83811015610cd4578181015183820152602001610cbc565b838111156105485750506000910152565b60008251610cf7818460208701610cb9565b9190910192915050565b6020815260008251806020840152610d20816040850160208701610cb9565b601f01601f1916919091016040019291505056fea2646970667358221220bb936fa870b05584f089c820f52c7f9fc6a018385c068e4f388d00bc8bb67c2564736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100995760003560e01c80631c060cbe1461009e57806351b83ebc146100cb57806371ca337d146100e15780637a93f256146101085780638f4ffcb114610128578063996c6cc31461013d578063c35d64ea1461017c578063cff0eac5146101a3578063de0e9a3e146101b6578063ea598cb0146101c9578063f4fc2f47146101dc575b600080fd5b6100b16100ac3660046109d7565b6101e4565b604080519283526020830191909152015b60405180910390f35b6100d361026b565b6040519081526020016100c2565b6100d37f000000000000000000000000000000000000000000000000000000000000000081565b6100d3610116366004610a0c565b60006020819052908152604090205481565b61013b610136366004610a27565b610285565b005b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b6100b16101b13660046109d7565b61039e565b61013b6101c43660046109d7565b61041d565b61013b6101d73660046109d7565b61042a565b6100d3600381565b6000806101f360036012610ad7565b6101fe90600a610bd4565b6102089084610bf6565b905060006102168285610ad7565b905061022460036012610ad7565b61022f90600a610bd4565b6102597f000000000000000000000000000000000000000000000000000000000000000083610c0a565b6102639190610c29565b925050915091565b61027760036012610ad7565b61028290600a610bd4565b81565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461030b5760405162461bcd60e51b815260206004820152601e60248201527f546f6b656e206973206e6f7420746865207772617070656420746f6b656e000060448201526064015b60405180910390fd5b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461038d5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207772617070656420746f6b656e2063616c6c657220616c6c6f77656044820152601960fa1b6064820152608401610302565b6103978585610430565b5050505050565b6000806103cb7f000000000000000000000000000000000000000000000000000000000000000084610bf6565b905060006103d98285610ad7565b90507f000000000000000000000000000000000000000000000000000000000000000061040860036012610ad7565b61041390600a610bd4565b6102599083610c0a565b610427338261054e565b50565b61042733825b60008061043c836101e4565b909250905061044b8184610ad7565b92506000831161046d5760405162461bcd60e51b815260040161030290610c3d565b60408051848152602081018490526001600160a01b038616917f727200b48f3c812bfb404b578574e1c03694edb122d80fa6dcb352a9e4f8a938910160405180910390a26001600160a01b038416600090815260208190526040812080548592906104d9908490610c7f565b9091555061051490506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b50505050565b60008061055a8361039e565b90925090506105698184610ad7565b92506000831161058b5760405162461bcd60e51b815260040161030290610c3d565b6001600160a01b0384166000908152602081905260409020548211156106075760405162461bcd60e51b815260206004820152602b60248201527f43616e206e6f7420756e77726170206d6f7265207468616e2070726576696f7560448201526a1cdb1e481ddc985c1c195960aa1b6064820152608401610302565b60408051848152602081018490526001600160a01b038616917ff64ae1cc3e0e07da9c895b3225439175cab5838aca24c4e74852704858c96a7b910160405180910390a26001600160a01b03841660009081526020819052604081208054849290610673908490610ad7565b909155506106ae90506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168530866106e2565b6105486001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858461074d565b6040516001600160a01b03808516602483015283166044820152606481018290526105489085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610782565b6040516001600160a01b03831660248201526044810182905261077d90849063a9059cbb60e01b90606401610716565b505050565b60006107d7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108549092919063ffffffff16565b80519091501561077d57808060200190518101906107f59190610c97565b61077d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610302565b6060610863848460008561086d565b90505b9392505050565b6060824710156108ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610302565b6001600160a01b0385163b6109255760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610302565b600080866001600160a01b031685876040516109419190610ce5565b60006040518083038185875af1925050503d806000811461097e576040519150601f19603f3d011682016040523d82523d6000602084013e610983565b606091505b509150915061099382828661099e565b979650505050505050565b606083156109ad575081610866565b8251156109bd5782518084602001fd5b8160405162461bcd60e51b81526004016103029190610d01565b6000602082840312156109e957600080fd5b5035919050565b80356001600160a01b0381168114610a0757600080fd5b919050565b600060208284031215610a1e57600080fd5b610866826109f0565b600080600080600060808688031215610a3f57600080fd5b610a48866109f0565b945060208601359350610a5d604087016109f0565b925060608601356001600160401b0380821115610a7957600080fd5b818801915088601f830112610a8d57600080fd5b813581811115610a9c57600080fd5b896020828501011115610aae57600080fd5b9699959850939650602001949392505050565b634e487b7160e01b600052601160045260246000fd5b600082821015610ae957610ae9610ac1565b500390565b600181815b80851115610b29578160001904821115610b0f57610b0f610ac1565b80851615610b1c57918102915b93841c9390800290610af3565b509250929050565b600082610b4057506001610bce565b81610b4d57506000610bce565b8160018114610b635760028114610b6d57610b89565b6001915050610bce565b60ff841115610b7e57610b7e610ac1565b50506001821b610bce565b5060208310610133831016604e8410600b8410161715610bac575081810a610bce565b610bb68383610aee565b8060001904821115610bca57610bca610ac1565b0290505b92915050565b60006108668383610b31565b634e487b7160e01b600052601260045260246000fd5b600082610c0557610c05610be0565b500690565b6000816000190483118215151615610c2457610c24610ac1565b500290565b600082610c3857610c38610be0565b500490565b60208082526022908201527f446973616c6c6f7720636f6e76657273696f6e73206f66207a65726f2076616c604082015261756560f01b606082015260800190565b60008219821115610c9257610c92610ac1565b500190565b600060208284031215610ca957600080fd5b8151801515811461086657600080fd5b60005b83811015610cd4578181015183820152602001610cbc565b838111156105485750506000910152565b60008251610cf7818460208701610cb9565b9190910192915050565b6020815260008251806020840152610d20816040850160208701610cb9565b601f01601f1916919091016040019291505056fea2646970667358221220bb936fa870b05584f089c820f52c7f9fc6a018385c068e4f388d00bc8bb67c2564736f6c63430008090033", @@ -370,7 +370,7 @@ "storageLayout": { "storage": [ { - "astId": 18594, + "astId": 18568, "contract": "contracts/vending/VendingMachine.sol:VendingMachine", "label": "wrappedBalance", "offset": 0, diff --git a/src/utils/chainIdToNetworkName.ts b/src/utils/chainIdToNetworkName.ts index 48b615d5e..1067d29e5 100644 --- a/src/utils/chainIdToNetworkName.ts +++ b/src/utils/chainIdToNetworkName.ts @@ -6,10 +6,7 @@ type NetworkMap = { const networkMap: NetworkMap = { [ChainID.Ethereum]: "Ethereum", - // [ChainID.Ropsten]: "Ropsten Test", - // 4: "Rinkeby", - [ChainID.Goerli]: "Goerli Test", - // 42: "Kovan", + [ChainID.Sepolia]: "Sepolia Test", [ChainID.Localhost]: "Localhost", } diff --git a/src/utils/createEtherscanLink.ts b/src/utils/createEtherscanLink.ts index a5be02ab6..78e9a0373 100644 --- a/src/utils/createEtherscanLink.ts +++ b/src/utils/createEtherscanLink.ts @@ -1,9 +1,6 @@ const ETHERSCAN_PREFIXES: { [chainId: number]: string } = { 1: "", - 3: "ropsten.", - 4: "rinkeby.", - 5: "goerli.", - 42: "kovan.", + 11155111: "sepolia.", } export enum ExplorerDataType { diff --git a/src/utils/getThresholdLib.ts b/src/utils/getThresholdLib.ts index fa05a4680..c49153e7a 100644 --- a/src/utils/getThresholdLib.ts +++ b/src/utils/getThresholdLib.ts @@ -22,7 +22,7 @@ function getInitialEthereumConfig( chainId: supportedChainId, providerOrSigner: providerOrSigner || getDefaultThresholdLibProvider(), shouldUseTestnetDevelopmentContracts: - supportedChainId === ChainID.Goerli.toString() && + supportedChainId === ChainID.Sepolia.toString() && shouldUseTestnetDevelopmentContracts, } } diff --git a/src/web3/hooks/useMerkleDropContract.ts b/src/web3/hooks/useMerkleDropContract.ts index 5fd7f30cb..abdf09f57 100644 --- a/src/web3/hooks/useMerkleDropContract.ts +++ b/src/web3/hooks/useMerkleDropContract.ts @@ -10,9 +10,9 @@ const CONTRACT_ADDRESSESS = { // https://etherscan.io/address/0xea7ca290c7811d1cc2e79f8d706bd05d8280bd37 [ChainID.Ethereum.valueOf().toString()]: "0xeA7CA290c7811d1cC2e79f8d706bD05d8280BD37", - // https://goerli.etherscan.io/address/0x55F836777302CE096CC7770142a8262A2627E2e9 - [ChainID.Goerli.valueOf().toString()]: - "0x55F836777302CE096CC7770142a8262A2627E2e9", + // https://sepolia.etherscan.io/address/0x4621a14bbB5a53f79Ea532bdc032b8ACc383B153 + [ChainID.Sepolia.valueOf().toString()]: + "0x4621a14bbB5a53f79Ea532bdc032b8ACc383B153", // TODO: Set local address- how to resolve it in local network? [ChainID.Localhost.valueOf().toString()]: AddressZero, } as Record diff --git a/src/web3/hooks/useMulticallContract.ts b/src/web3/hooks/useMulticallContract.ts index 1ae537768..26e9ecddc 100644 --- a/src/web3/hooks/useMulticallContract.ts +++ b/src/web3/hooks/useMulticallContract.ts @@ -12,7 +12,10 @@ const MULTICALL_ABI = [ // https://github.com/makerdao/multicall#multicall-contract-addresses const MULTICALL_ADDRESSESS = { [ChainID.Ethereum.valueOf()]: "0xeefba1e63905ef1d7acba5a8513c70307c1ce441", - [ChainID.Goerli.valueOf()]: "0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e", + // The `makerdao/multicall` repo is deprecated and there is a third-party + // fork that deployed Multicall3: + // https://github.com/mds1/multicall#existing-deployments. + [ChainID.Sepolia.valueOf()]: "0xcA11bde05977b3631167028862bE2a173976CA11", [ChainID.Localhost.valueOf()]: process.env.REACT_APP_MULTICALL_ADDRESS || AddressZero, } as Record diff --git a/src/web3/hooks/usePREContract.ts b/src/web3/hooks/usePREContract.ts index 16de6d4c0..c23e5bf5f 100644 --- a/src/web3/hooks/usePREContract.ts +++ b/src/web3/hooks/usePREContract.ts @@ -10,11 +10,11 @@ const PRE_ADDRESSESS = { // https://etherscan.io/address/0x7E01c9c03FD3737294dbD7630a34845B0F70E5Dd [ChainID.Ethereum.valueOf().toString()]: "0x7E01c9c03FD3737294dbD7630a34845B0F70E5Dd", - // https://goerli.etherscan.io/address/0x829fdCDf6Be747FEA37518fBd83dF70EE371fCf2 - // As NuCypher hasn't depoyed the `SimplePreApplication` contract on Goerli, + // https://sepolia.etherscan.io/address/0x471EA40981D278fb3Cb55587e94ac549aad1ACA9 + // As NuCypher hasn't depoyed the `SimplePreApplication` contract on Sepolia, // we're using a stub contract. - [ChainID.Goerli.valueOf().toString()]: - "0x829fdCDf6Be747FEA37518fBd83dF70EE371fCf2", + [ChainID.Sepolia.valueOf().toString()]: + "0x471EA40981D278fb3Cb55587e94ac549aad1ACA9", // Set the correct `SimplePREApplication` contract address. If you deployed // the `@threshold-network/solidity-contracts` to your local chain and linked // package using `yarn link @threshold-network/solidity-contracts` you can