diff --git a/contracts/ERC20SimpleSwap.sol b/contracts/ERC20SimpleSwap.sol index c2b7218..0aefc9e 100755 --- a/contracts/ERC20SimpleSwap.sol +++ b/contracts/ERC20SimpleSwap.sol @@ -1,8 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity =0.8.19; -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +pragma solidity =0.7.6; +pragma abicoder v2; +import "@openzeppelin/contracts/math/SafeMath.sol"; +import "@openzeppelin/contracts/math/Math.sol"; +import "@openzeppelin/contracts/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol"; + /** @title Chequebook contract without waivers @@ -13,6 +17,8 @@ Furthermore, solvency can be guaranteed via hardDeposits as a beneficiary, we should always take into account the possibility that a cheque bounces (when no hardDeposits are assigned) */ contract ERC20SimpleSwap { + using SafeMath for uint; + event ChequeCashed( address indexed beneficiary, address indexed recipient, @@ -56,11 +62,15 @@ contract ERC20SimpleSwap { ); // the EIP712 domain this contract uses - function domain() internal view returns (EIP712Domain memory) { + function domain() internal pure returns (EIP712Domain memory) { + uint256 chainId; + assembly { + chainId := chainid() + } return EIP712Domain({ name: "Chequebook", version: "1.0", - chainId: block.chainid + chainId: chainId }); } @@ -75,7 +85,7 @@ contract ERC20SimpleSwap { } // recover a signature with the EIP712 signing scheme - function recoverEIP712(bytes32 hash, bytes memory sig) internal view returns (address) { + function recoverEIP712(bytes32 hash, bytes memory sig) internal pure returns (address) { bytes32 digest = keccak256(abi.encodePacked( "\x19\x01", domainSeparator(domain()), @@ -85,7 +95,7 @@ contract ERC20SimpleSwap { } /* The token against which this chequebook writes cheques */ - IERC20 public token; + ERC20 public token; /* associates every beneficiary with how much has been paid out to them */ mapping (address => uint) public paidOut; /* total amount paid out */ @@ -110,7 +120,7 @@ contract ERC20SimpleSwap { require(_issuer != address(0), "invalid issuer"); require(issuer == address(0), "already initialized"); issuer = _issuer; - token = IERC20(_token); + token = ERC20(_token); defaultHardDepositTimeout = _defaultHardDepositTimeout; } @@ -120,12 +130,12 @@ contract ERC20SimpleSwap { } /// @return the part of the balance that is not covered by hard deposits function liquidBalance() public view returns(uint) { - return balance() - totalHardDeposit; + return balance().sub(totalHardDeposit); } /// @return the part of the balance available for a specific beneficiary function liquidBalanceFor(address beneficiary) public view returns(uint) { - return liquidBalance() + hardDeposits[beneficiary].amount; + return liquidBalance().add(hardDeposits[beneficiary].amount); } /** @dev internal function responsible for checking the issuerSignature, updating hardDeposit balances and doing transfers. @@ -148,7 +158,7 @@ contract ERC20SimpleSwap { "invalid issuer signature"); } /* the requestPayout is the amount requested for payment processing */ - uint requestPayout = cumulativePayout - paidOut[beneficiary]; + uint requestPayout = cumulativePayout.sub(paidOut[beneficiary]); /* calculates acutal payout */ uint totalPayout = Math.min(requestPayout, liquidBalanceFor(beneficiary)); /* calculates hard-deposit usage */ @@ -156,12 +166,13 @@ contract ERC20SimpleSwap { require(totalPayout >= callerPayout, "SimpleSwap: cannot pay caller"); /* if there are some of the hard deposit used, update hardDeposits*/ if (hardDepositUsage != 0) { - hardDeposits[beneficiary].amount = hardDeposits[beneficiary].amount - hardDepositUsage; - totalHardDeposit = totalHardDeposit - hardDepositUsage; + hardDeposits[beneficiary].amount = hardDeposits[beneficiary].amount.sub(hardDepositUsage); + + totalHardDeposit = totalHardDeposit.sub(hardDepositUsage); } /* increase the stored paidOut amount to avoid double payout */ - paidOut[beneficiary] = paidOut[beneficiary] + totalPayout; - totalPaidOut = totalPaidOut + totalPayout; + paidOut[beneficiary] = paidOut[beneficiary].add(totalPayout); + totalPaidOut = totalPaidOut.add(totalPayout); /* let the world know that the issuer has over-promised on outstanding cheques */ if (requestPayout != totalPayout) { @@ -173,7 +184,7 @@ contract ERC20SimpleSwap { /* do a transfer to the caller if specified*/ require(token.transfer(msg.sender, callerPayout), "transfer failed"); /* do the actual payment */ - require(token.transfer(recipient, totalPayout - callerPayout), "transfer failed"); + require(token.transfer(recipient, totalPayout.sub(callerPayout)), "transfer failed"); } else { /* do the actual payment */ require(token.transfer(recipient, totalPayout), "transfer failed"); @@ -250,11 +261,11 @@ contract ERC20SimpleSwap { require(block.timestamp >= hardDeposit.canBeDecreasedAt && hardDeposit.canBeDecreasedAt != 0, "deposit not yet timed out"); /* this throws if decreaseAmount > amount */ //TODO: if there is a cash-out in between prepareDecreaseHardDeposit and decreaseHardDeposit, decreaseHardDeposit will throw and reducing hard-deposits is impossible. - hardDeposit.amount = hardDeposit.amount - hardDeposit.decreaseAmount; + hardDeposit.amount = hardDeposit.amount.sub(hardDeposit.decreaseAmount); /* reset the canBeDecreasedAt to avoid a double decrease */ hardDeposit.canBeDecreasedAt = 0; /* keep totalDeposit in sync */ - totalHardDeposit = totalHardDeposit - hardDeposit.decreaseAmount; + totalHardDeposit = totalHardDeposit.sub(hardDeposit.decreaseAmount); emit HardDepositAmountChanged(beneficiary, hardDeposit.amount); } @@ -266,12 +277,12 @@ contract ERC20SimpleSwap { function increaseHardDeposit(address beneficiary, uint amount) public { require(msg.sender == issuer, "SimpleSwap: not issuer"); /* ensure hard deposits don't exceed the global balance */ - require(totalHardDeposit + amount <= balance(), "hard deposit exceeds balance"); + require(totalHardDeposit.add(amount) <= balance(), "hard deposit exceeds balance"); HardDeposit storage hardDeposit = hardDeposits[beneficiary]; - hardDeposit.amount = hardDeposit.amount + amount; + hardDeposit.amount = hardDeposit.amount.add(amount); // we don't explicitely set hardDepositTimout, as zero means using defaultHardDepositTimeout - totalHardDeposit = totalHardDeposit + amount; + totalHardDeposit = totalHardDeposit.add(amount); /* disable any pending decrease */ hardDeposit.canBeDecreasedAt = 0; emit HardDepositAmountChanged(beneficiary, hardDeposit.amount); @@ -340,6 +351,4 @@ contract ERC20SimpleSwap { decreaseTimeout )); } -} - - +} \ No newline at end of file diff --git a/contracts/SimpleSwapFactory.sol b/contracts/SimpleSwapFactory.sol index 07859de..298ba7f 100755 --- a/contracts/SimpleSwapFactory.sol +++ b/contracts/SimpleSwapFactory.sol @@ -1,5 +1,6 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity =0.8.19; +pragma solidity =0.7.6; +pragma abicoder v2; import "./ERC20SimpleSwap.sol"; import "@openzeppelin/contracts/proxy/Clones.sol"; diff --git a/contracts/TestToken.sol b/contracts/TestToken.sol index c0ed726..a437c48 100755 --- a/contracts/TestToken.sol +++ b/contracts/TestToken.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity =0.8.19; +pragma solidity =0.7.6; -import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; +import "@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol"; contract TestToken is ERC20PresetMinterPauser { constructor() ERC20PresetMinterPauser("Test", "TST") { } -} +} \ No newline at end of file diff --git a/deploy/000_deploy.js b/deploy/000_deploy.js index 3eddbac..7b74834 100755 --- a/deploy/000_deploy.js +++ b/deploy/000_deploy.js @@ -10,7 +10,7 @@ module.exports = async ({ getNamedAccounts, deployments }) => { log("----------------------------------------------------"); // sBZZ token address - const arguments = ["0x543dDb01Ba47acB11de34891cD86B675F04840db"]; + const arguments = ["0x543ddb01ba47acb11de34891cd86b675f04840db"]; const factory = await deploy("SimpleSwapFactory", { from: deployer, args: arguments, diff --git a/deployments/testnet/SimpleSwapFactory.json b/deployments/testnet/SimpleSwapFactory.json index ed744a2..219567f 100755 --- a/deployments/testnet/SimpleSwapFactory.json +++ b/deployments/testnet/SimpleSwapFactory.json @@ -1,5 +1,5 @@ { - "address": "0x989F4d301d7333249362B2484BeE0D501AB01DCa", + "address": "0x0fF044F6bB4F684a5A149B46D7eC03ea659F98A1", "abi": [ { "inputs": [ @@ -100,30 +100,30 @@ "type": "function" } ], - "transactionHash": "0xaf0128de8da27d35e66064afd471839ae6a061515ce384f60bc3ffd22d2713bd", + "transactionHash": "0xecdf92fa02e7274c0957b1196ca815f559dddaeb03a4947dddcc8b093c018545", "receipt": { "to": null, "from": "0xb1C7F17Ed88189Abf269Bf68A3B2Ed83C5276aAe", - "contractAddress": "0x989F4d301d7333249362B2484BeE0D501AB01DCa", - "transactionIndex": 35, - "gasUsed": "1718730", + "contractAddress": "0x0fF044F6bB4F684a5A149B46D7eC03ea659F98A1", + "transactionIndex": 31, + "gasUsed": "1734222", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x99969a57df70b3137f1d94c9d7335b615c04b05444744715a5c7ff74e5805c97", - "transactionHash": "0xaf0128de8da27d35e66064afd471839ae6a061515ce384f60bc3ffd22d2713bd", + "blockHash": "0x66be8c4225abf06f33cd17953bab32a0ba1647588b41644754c63bc1dd160715", + "transactionHash": "0xecdf92fa02e7274c0957b1196ca815f559dddaeb03a4947dddcc8b093c018545", "logs": [], - "blockNumber": 4595399, - "cumulativeGasUsed": "7675910", + "blockNumber": 4752810, + "cumulativeGasUsed": "5077529", "status": 1, "byzantium": true }, "args": [ - "0x543dDb01Ba47acB11de34891cD86B675F04840db" + "0x543ddb01ba47acb11de34891cd86b675f04840db" ], - "numDeployments": 2, - "solcInputHash": "91f5cbb4dd7fedf177ab9b96b0007658", - "metadata": "{\"compiler\":{\"version\":\"0.8.19+commit.7dd6d404\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_ERC20Address\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"}],\"name\":\"SimpleSwapDeployed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"ERC20Address\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"issuer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"defaultHardDepositTimeoutDuration\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"deploySimpleSwap\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"deployedContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"master\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"The Swarm Authors\",\"kind\":\"dev\",\"methods\":{\"deploySimpleSwap(address,uint256,bytes32)\":{\"params\":{\"defaultHardDepositTimeoutDuration\":\"duration in seconds which by default will be used to reduce hardDeposit allocations\",\"issuer\":\"the issuer of cheques for the new chequebook\",\"salt\":\"salt to include in create2 to enable the same address to deploy multiple chequebooks\"}}},\"title\":\"Factory contract for SimpleSwap\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"deploySimpleSwap(address,uint256,bytes32)\":{\"notice\":\"creates a clone of the master SimpleSwap contract\"}},\"notice\":\"This contract deploys SimpleSwap contracts\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/SimpleSwapFactory.sol\":\"SimpleSwapFactory\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/proxy/Clones.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/Clones.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\\n * deploying minimal proxy contracts, also known as \\\"clones\\\".\\n *\\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\\n *\\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\\n * deterministic method.\\n *\\n * _Available since v3.4._\\n */\\nlibrary Clones {\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\\n *\\n * This function uses the create opcode, which should never revert.\\n */\\n function clone(address implementation) internal returns (address instance) {\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, implementation))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create(0, ptr, 0x37)\\n }\\n require(instance != address(0), \\\"ERC1167: create failed\\\");\\n }\\n\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\\n *\\n * This function uses the create2 opcode and a `salt` to deterministically deploy\\n * the clone. Using the same `implementation` and `salt` multiple time will revert, since\\n * the clones cannot be deployed twice at the same address.\\n */\\n function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, implementation))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create2(0, ptr, 0x37, salt)\\n }\\n require(instance != address(0), \\\"ERC1167: create2 failed\\\");\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(\\n address implementation,\\n bytes32 salt,\\n address deployer\\n ) internal pure returns (address predicted) {\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, implementation))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\\n mstore(add(ptr, 0x38), shl(0x60, deployer))\\n mstore(add(ptr, 0x4c), salt)\\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\\n predicted := keccak256(add(ptr, 0x37), 0x55)\\n }\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address implementation, bytes32 salt)\\n internal\\n view\\n returns (address predicted)\\n {\\n return predictDeterministicAddress(implementation, salt, address(this));\\n }\\n}\\n\",\"keccak256\":\"0x1cc0efb01cbf008b768fd7b334786a6e358809198bb7e67f1c530af4957c6a21\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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 `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, 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 `sender` to `recipient` 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 sender,\\n address recipient,\\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\":\"0x61437cb513a887a1bbad006e7b1c8b414478427d33de47c5600af3c748f108da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\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 // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\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 if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\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] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x32c202bd28995dd20c4347b7c6467a6d3241c74c8ad3edcbb610cd9205916c45\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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\\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 } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' 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 // Check the signature length\\n // - case 65: r,s,v signature (standard)\\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\\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 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 if (signature.length == 64) {\\n bytes32 r;\\n bytes32 vs;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n vs := mload(add(signature, 0x40))\\n }\\n return tryRecover(hash, r, vs);\\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;\\n uint8 v;\\n assembly {\\n s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)\\n v := add(shr(255, vs), 27)\\n }\\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 if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\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\":\"0xe9e291de7ffe06e66503c6700b1bb84ff6e0989cbb974653628d8994e7c97f03\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (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 /**\\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\":\"0xfaad496c1c944b6259b7dc70b4865eb1775d6402bc0c81b38a0b24d9f525ae37\",\"license\":\"MIT\"},\"contracts/ERC20SimpleSwap.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity =0.8.19;\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/**\\n@title Chequebook contract without waivers\\n@author The Swarm Authors\\n@notice The chequebook contract allows the issuer of the chequebook to send cheques to an unlimited amount of counterparties.\\nFurthermore, solvency can be guaranteed via hardDeposits\\n@dev as an issuer, no cheques should be send if the cumulative worth of a cheques send is above the cumulative worth of all deposits\\nas a beneficiary, we should always take into account the possibility that a cheque bounces (when no hardDeposits are assigned)\\n*/\\ncontract ERC20SimpleSwap {\\n event ChequeCashed(\\n address indexed beneficiary,\\n address indexed recipient,\\n address indexed caller,\\n uint totalPayout,\\n uint cumulativePayout,\\n uint callerPayout\\n );\\n event ChequeBounced();\\n event HardDepositAmountChanged(address indexed beneficiary, uint amount);\\n event HardDepositDecreasePrepared(address indexed beneficiary, uint decreaseAmount);\\n event HardDepositTimeoutChanged(address indexed beneficiary, uint timeout);\\n event Withdraw(uint amount);\\n\\n uint public defaultHardDepositTimeout;\\n /* structure to keep track of the hard deposits (on-chain guarantee of solvency) per beneficiary*/\\n struct HardDeposit {\\n uint amount; /* hard deposit amount allocated */\\n uint decreaseAmount; /* decreaseAmount substranced from amount when decrease is requested */\\n uint timeout; /* issuer has to wait timeout seconds to decrease hardDeposit, 0 implies applying defaultHardDepositTimeout */\\n uint canBeDecreasedAt; /* point in time after which harddeposit can be decreased*/\\n }\\n\\n struct EIP712Domain {\\n string name;\\n string version;\\n uint256 chainId;\\n }\\n\\n bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId)\\\"\\n );\\n bytes32 public constant CHEQUE_TYPEHASH = keccak256(\\n \\\"Cheque(address chequebook,address beneficiary,uint256 cumulativePayout)\\\"\\n );\\n bytes32 public constant CASHOUT_TYPEHASH = keccak256(\\n \\\"Cashout(address chequebook,address sender,uint256 requestPayout,address recipient,uint256 callerPayout)\\\"\\n );\\n bytes32 public constant CUSTOMDECREASETIMEOUT_TYPEHASH = keccak256(\\n \\\"CustomDecreaseTimeout(address chequebook,address beneficiary,uint256 decreaseTimeout)\\\"\\n );\\n\\n // the EIP712 domain this contract uses\\n function domain() internal view returns (EIP712Domain memory) { \\n return EIP712Domain({\\n name: \\\"Chequebook\\\",\\n version: \\\"1.0\\\",\\n chainId: block.chainid\\n });\\n }\\n\\n // compute the EIP712 domain separator. this cannot be constant because it depends on chainId\\n function domainSeparator(EIP712Domain memory eip712Domain) internal pure returns (bytes32) {\\n return keccak256(abi.encode(\\n EIP712DOMAIN_TYPEHASH,\\n keccak256(bytes(eip712Domain.name)),\\n keccak256(bytes(eip712Domain.version)),\\n eip712Domain.chainId\\n ));\\n }\\n\\n // recover a signature with the EIP712 signing scheme\\n function recoverEIP712(bytes32 hash, bytes memory sig) internal view returns (address) {\\n bytes32 digest = keccak256(abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n domainSeparator(domain()),\\n hash\\n ));\\n return ECDSA.recover(digest, sig);\\n }\\n\\n /* The token against which this chequebook writes cheques */\\n IERC20 public token;\\n /* associates every beneficiary with how much has been paid out to them */\\n mapping (address => uint) public paidOut;\\n /* total amount paid out */\\n uint public totalPaidOut;\\n /* associates every beneficiary with their HardDeposit */\\n mapping (address => HardDeposit) public hardDeposits;\\n /* sum of all hard deposits */\\n uint public totalHardDeposit;\\n /* issuer of the contract, set at construction */\\n address public issuer;\\n /* indicates wether a cheque bounced in the past */\\n bool public bounced;\\n\\n /**\\n @notice sets the issuer, token and the defaultHardDepositTimeout. can only be called once.\\n @param _issuer the issuer of cheques from this chequebook (needed as an argument for \\\"Setting up a chequebook as a payment\\\").\\n _issuer must be an Externally Owned Account, or it must support calling the function cashCheque\\n @param _token the token this chequebook uses\\n @param _defaultHardDepositTimeout duration in seconds which by default will be used to reduce hardDeposit allocations\\n */\\n function init(address _issuer, address _token, uint _defaultHardDepositTimeout) public {\\n require(_issuer != address(0), \\\"invalid issuer\\\");\\n require(issuer == address(0), \\\"already initialized\\\");\\n issuer = _issuer;\\n token = IERC20(_token);\\n defaultHardDepositTimeout = _defaultHardDepositTimeout;\\n }\\n\\n /// @return the balance of the chequebook\\n function balance() public view returns(uint) {\\n return token.balanceOf(address(this));\\n }\\n /// @return the part of the balance that is not covered by hard deposits\\n function liquidBalance() public view returns(uint) {\\n return balance() - totalHardDeposit;\\n }\\n\\n /// @return the part of the balance available for a specific beneficiary\\n function liquidBalanceFor(address beneficiary) public view returns(uint) {\\n return liquidBalance() + hardDeposits[beneficiary].amount;\\n }\\n /**\\n @dev internal function responsible for checking the issuerSignature, updating hardDeposit balances and doing transfers.\\n Called by cashCheque and cashChequeBeneficary\\n @param beneficiary the beneficiary to which cheques were assigned. Beneficiary must be an Externally Owned Account\\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\\n @param cumulativePayout cumulative amount of cheques assigned to beneficiary\\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\\n */\\n function _cashChequeInternal(\\n address beneficiary,\\n address recipient,\\n uint cumulativePayout,\\n uint callerPayout,\\n bytes memory issuerSig\\n ) internal {\\n /* The issuer must have given explicit approval to the cumulativePayout, either by being the caller or by signature*/\\n if (msg.sender != issuer) {\\n require(issuer == recoverEIP712(chequeHash(address(this), beneficiary, cumulativePayout), issuerSig),\\n \\\"invalid issuer signature\\\");\\n }\\n /* the requestPayout is the amount requested for payment processing */\\n uint requestPayout = cumulativePayout - paidOut[beneficiary];\\n /* calculates acutal payout */\\n uint totalPayout = Math.min(requestPayout, liquidBalanceFor(beneficiary));\\n /* calculates hard-deposit usage */\\n uint hardDepositUsage = Math.min(totalPayout, hardDeposits[beneficiary].amount);\\n require(totalPayout >= callerPayout, \\\"SimpleSwap: cannot pay caller\\\");\\n /* if there are some of the hard deposit used, update hardDeposits*/\\n if (hardDepositUsage != 0) {\\n hardDeposits[beneficiary].amount = hardDeposits[beneficiary].amount - hardDepositUsage;\\n totalHardDeposit = totalHardDeposit - hardDepositUsage;\\n }\\n /* increase the stored paidOut amount to avoid double payout */\\n paidOut[beneficiary] = paidOut[beneficiary] + totalPayout;\\n totalPaidOut = totalPaidOut + totalPayout;\\n\\n /* let the world know that the issuer has over-promised on outstanding cheques */\\n if (requestPayout != totalPayout) {\\n bounced = true;\\n emit ChequeBounced();\\n }\\n\\n if (callerPayout != 0) {\\n /* do a transfer to the caller if specified*/\\n require(token.transfer(msg.sender, callerPayout), \\\"transfer failed\\\");\\n /* do the actual payment */\\n require(token.transfer(recipient, totalPayout - callerPayout), \\\"transfer failed\\\");\\n } else {\\n /* do the actual payment */\\n require(token.transfer(recipient, totalPayout), \\\"transfer failed\\\");\\n }\\n\\n emit ChequeCashed(beneficiary, recipient, msg.sender, totalPayout, cumulativePayout, callerPayout);\\n }\\n /**\\n @notice cash a cheque of the beneficiary by a non-beneficiary and reward the sender for doing so with callerPayout\\n @dev a beneficiary must be able to generate signatures (be an Externally Owned Account) to make use of this feature\\n @param beneficiary the beneficiary to which cheques were assigned. Beneficiary must be an Externally Owned Account\\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\\n @param cumulativePayout cumulative amount of cheques assigned to beneficiary\\n @param beneficiarySig beneficiary must have given explicit approval for cashing out the cumulativePayout by the sender and sending the callerPayout\\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\\n @param callerPayout when beneficiary does not have ether yet, he can incentivize other people to cash cheques with help of callerPayout\\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\\n */\\n function cashCheque(\\n address beneficiary,\\n address recipient,\\n uint cumulativePayout,\\n bytes memory beneficiarySig,\\n uint256 callerPayout,\\n bytes memory issuerSig\\n ) public {\\n require(\\n beneficiary == recoverEIP712(\\n cashOutHash(\\n address(this),\\n msg.sender,\\n cumulativePayout,\\n recipient,\\n callerPayout\\n ), beneficiarySig\\n ), \\\"invalid beneficiary signature\\\");\\n _cashChequeInternal(beneficiary, recipient, cumulativePayout, callerPayout, issuerSig);\\n }\\n\\n /**\\n @notice cash a cheque as beneficiary\\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\\n @param cumulativePayout amount requested to pay out\\n @param issuerSig issuer must have given explicit approval on the cumulativePayout to the beneficiary\\n */\\n function cashChequeBeneficiary(address recipient, uint cumulativePayout, bytes memory issuerSig) public {\\n _cashChequeInternal(msg.sender, recipient, cumulativePayout, 0, issuerSig);\\n }\\n\\n /**\\n @notice prepare to decrease the hard deposit\\n @dev decreasing hardDeposits must be done in two steps to allow beneficiaries to cash any uncashed cheques (and make use of the assgined hard-deposits)\\n @param beneficiary beneficiary whose hard deposit should be decreased\\n @param decreaseAmount amount that the deposit is supposed to be decreased by\\n */\\n function prepareDecreaseHardDeposit(address beneficiary, uint decreaseAmount) public {\\n require(msg.sender == issuer, \\\"SimpleSwap: not issuer\\\");\\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\\n /* cannot decrease it by more than the deposit */\\n require(decreaseAmount <= hardDeposit.amount, \\\"hard deposit not sufficient\\\");\\n // if hardDeposit.timeout was never set, apply defaultHardDepositTimeout\\n uint timeout = hardDeposit.timeout == 0 ? defaultHardDepositTimeout : hardDeposit.timeout;\\n hardDeposit.canBeDecreasedAt = block.timestamp + timeout;\\n hardDeposit.decreaseAmount = decreaseAmount;\\n emit HardDepositDecreasePrepared(beneficiary, decreaseAmount);\\n }\\n\\n /**\\n @notice decrease the hard deposit after waiting the necesary amount of time since prepareDecreaseHardDeposit was called\\n @param beneficiary beneficiary whose hard deposit should be decreased\\n */\\n function decreaseHardDeposit(address beneficiary) public {\\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\\n require(block.timestamp >= hardDeposit.canBeDecreasedAt && hardDeposit.canBeDecreasedAt != 0, \\\"deposit not yet timed out\\\");\\n /* this throws if decreaseAmount > amount */\\n //TODO: if there is a cash-out in between prepareDecreaseHardDeposit and decreaseHardDeposit, decreaseHardDeposit will throw and reducing hard-deposits is impossible.\\n hardDeposit.amount = hardDeposit.amount - hardDeposit.decreaseAmount;\\n /* reset the canBeDecreasedAt to avoid a double decrease */\\n hardDeposit.canBeDecreasedAt = 0;\\n /* keep totalDeposit in sync */\\n totalHardDeposit = totalHardDeposit - hardDeposit.decreaseAmount;\\n emit HardDepositAmountChanged(beneficiary, hardDeposit.amount);\\n }\\n\\n /**\\n @notice increase the hard deposit\\n @param beneficiary beneficiary whose hard deposit should be decreased\\n @param amount the new hard deposit\\n */\\n function increaseHardDeposit(address beneficiary, uint amount) public {\\n require(msg.sender == issuer, \\\"SimpleSwap: not issuer\\\");\\n /* ensure hard deposits don't exceed the global balance */\\n require(totalHardDeposit + amount <= balance(), \\\"hard deposit exceeds balance\\\");\\n\\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\\n hardDeposit.amount = hardDeposit.amount + amount;\\n // we don't explicitely set hardDepositTimout, as zero means using defaultHardDepositTimeout\\n totalHardDeposit = totalHardDeposit + amount;\\n /* disable any pending decrease */\\n hardDeposit.canBeDecreasedAt = 0;\\n emit HardDepositAmountChanged(beneficiary, hardDeposit.amount);\\n }\\n\\n /**\\n @notice allows for setting a custom hardDepositDecreaseTimeout per beneficiary\\n @dev this is required when solvency must be guaranteed for a period longer than the defaultHardDepositDecreaseTimeout\\n @param beneficiary beneficiary whose hard deposit decreaseTimeout must be changed\\n @param hardDepositTimeout new hardDeposit.timeout for beneficiary\\n @param beneficiarySig beneficiary must give explicit approval by giving his signature on the new decreaseTimeout\\n */\\n function setCustomHardDepositTimeout(\\n address beneficiary,\\n uint hardDepositTimeout,\\n bytes memory beneficiarySig\\n ) public {\\n require(msg.sender == issuer, \\\"not issuer\\\");\\n require(\\n beneficiary == recoverEIP712(customDecreaseTimeoutHash(address(this), beneficiary, hardDepositTimeout), beneficiarySig),\\n \\\"invalid beneficiary signature\\\"\\n );\\n hardDeposits[beneficiary].timeout = hardDepositTimeout;\\n emit HardDepositTimeoutChanged(beneficiary, hardDepositTimeout);\\n }\\n\\n /// @notice withdraw ether\\n /// @param amount amount to withdraw\\n // solhint-disable-next-line no-simple-event-func-name\\n function withdraw(uint amount) public {\\n /* only issuer can do this */\\n require(msg.sender == issuer, \\\"not issuer\\\");\\n /* ensure we don't take anything from the hard deposit */\\n require(amount <= liquidBalance(), \\\"liquidBalance not sufficient\\\");\\n require(token.transfer(issuer, amount), \\\"transfer failed\\\");\\n }\\n\\n function chequeHash(address chequebook, address beneficiary, uint cumulativePayout)\\n internal pure returns (bytes32) {\\n return keccak256(abi.encode(\\n CHEQUE_TYPEHASH,\\n chequebook,\\n beneficiary,\\n cumulativePayout\\n ));\\n } \\n\\n function cashOutHash(address chequebook, address sender, uint requestPayout, address recipient, uint callerPayout)\\n internal pure returns (bytes32) {\\n return keccak256(abi.encode(\\n CASHOUT_TYPEHASH,\\n chequebook,\\n sender,\\n requestPayout,\\n recipient,\\n callerPayout\\n ));\\n }\\n\\n function customDecreaseTimeoutHash(address chequebook, address beneficiary, uint decreaseTimeout)\\n internal pure returns (bytes32) {\\n return keccak256(abi.encode(\\n CUSTOMDECREASETIMEOUT_TYPEHASH,\\n chequebook,\\n beneficiary,\\n decreaseTimeout\\n ));\\n }\\n}\\n\\n\\n\",\"keccak256\":\"0x2f079c4708c4df6932964be5c2d4a549079ea9a181ad8886cc17975bbd49aceb\",\"license\":\"BSD-3-Clause\"},\"contracts/SimpleSwapFactory.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity =0.8.19;\\nimport \\\"./ERC20SimpleSwap.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/Clones.sol\\\";\\n\\n/**\\n@title Factory contract for SimpleSwap\\n@author The Swarm Authors\\n@notice This contract deploys SimpleSwap contracts\\n*/\\ncontract SimpleSwapFactory {\\n\\n /* event fired on every new SimpleSwap deployment */\\n event SimpleSwapDeployed(address contractAddress);\\n\\n /* mapping to keep track of which contracts were deployed by this factory */\\n mapping (address => bool) public deployedContracts;\\n\\n /* address of the ERC20-token, to be used by the to-be-deployed chequebooks */\\n address public ERC20Address;\\n /* address of the code contract from which all chequebooks are cloned */\\n address public master;\\n\\n constructor(address _ERC20Address) {\\n ERC20Address = _ERC20Address;\\n ERC20SimpleSwap _master = new ERC20SimpleSwap();\\n // set the issuer of the master contract to prevent misuse\\n _master.init(address(1), address(0), 0);\\n master = address(_master);\\n }\\n /**\\n @notice creates a clone of the master SimpleSwap contract\\n @param issuer the issuer of cheques for the new chequebook\\n @param defaultHardDepositTimeoutDuration duration in seconds which by default will be used to reduce hardDeposit allocations\\n @param salt salt to include in create2 to enable the same address to deploy multiple chequebooks\\n */\\n function deploySimpleSwap(address issuer, uint defaultHardDepositTimeoutDuration, bytes32 salt)\\n public returns (address) { \\n address contractAddress = Clones.cloneDeterministic(master, keccak256(abi.encode(msg.sender, salt)));\\n ERC20SimpleSwap(contractAddress).init(issuer, ERC20Address, defaultHardDepositTimeoutDuration);\\n deployedContracts[contractAddress] = true;\\n emit SimpleSwapDeployed(contractAddress);\\n return contractAddress;\\n }\\n}\",\"keccak256\":\"0x116cd540139d505ea4461cd19722ffede13929b9e5a751573200f591e4dff32b\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b50604051611d90380380611d9083398101604081905261002f91610116565b600180546001600160a01b0319166001600160a01b03831617905560405160009061005990610109565b604051809103906000f080158015610075573d6000803e3d6000fd5b506040516343431f6360e11b81526001600482015260006024820181905260448201529091506001600160a01b038216906386863ec690606401600060405180830381600087803b1580156100c957600080fd5b505af11580156100dd573d6000803e3d6000fd5b5050600280546001600160a01b0319166001600160a01b03949094169390931790925550610146915050565b6118ff8061049183390190565b60006020828403121561012857600080fd5b81516001600160a01b038116811461013f57600080fd5b9392505050565b61033c806101556000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806315efd8a714610051578063a6021ace14610081578063c70242ad14610094578063ee97f7f3146100c7575b600080fd5b61006461005f3660046102b1565b6100da565b6040516001600160a01b0390911681526020015b60405180910390f35b600154610064906001600160a01b031681565b6100b76100a23660046102e4565b60006020819052908152604090205460ff1681565b6040519015158152602001610078565b600254610064906001600160a01b031681565b60025460408051336020820152908101839052600091829161011e916001600160a01b031690606001604051602081830303815290604052805190602001206101eb565b6001546040516343431f6360e11b81526001600160a01b0388811660048301529182166024820152604481018790529192508216906386863ec690606401600060405180830381600087803b15801561017657600080fd5b505af115801561018a573d6000803e3d6000fd5b505050506001600160a01b03811660008181526020818152604091829020805460ff1916600117905590519182527fc0ffc525a1c7689549d7f79b49eca900e61ac49b43d977f680bcc3b36224c004910160405180910390a1949350505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528360601b60148201526e5af43d82803e903d91602b57fd5bf360881b6028820152826037826000f59150506001600160a01b03811661028f5760405162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c6564000000000000000000604482015260640160405180910390fd5b92915050565b80356001600160a01b03811681146102ac57600080fd5b919050565b6000806000606084860312156102c657600080fd5b6102cf84610295565b95602085013595506040909401359392505050565b6000602082840312156102f657600080fd5b6102ff82610295565b939250505056fea26469706673582212203f76e42322bce6a35f6ef0357cad6785061a54bbbe936b5cc1a425f13408ffbc64736f6c63430008130033608060405234801561001057600080fd5b506118df806100206000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c8063946f46a2116100c3578063b7ec1a331161007c578063b7ec1a331461033f578063c49f91d314610347578063c76a4d311461036e578063d4c9a8e814610381578063e0bcf13a14610394578063fc0c546a1461039d57600080fd5b8063946f46a214610271578063b6343b0d14610284578063b648b417146102d9578063b69ef8a8146102fd578063b777035014610305578063b79989071461031857600080fd5b80631d143848116101155780631d143848146101c65780632e1a7d4d146101f1578063338f3fed14610204578063488b017c1461021757806381f03fcb1461023e57806386863ec61461025e57600080fd5b80630d5f26591461015257806312101021146101675780631357e1dc1461018357806315c3343f1461018c5780631633fb1d146101b3575b600080fd5b61016561016036600461166b565b6103b0565b005b61017060005481565b6040519081526020015b60405180910390f35b61017060035481565b6101707f48ebe6deff4a5ee645c01506a026031e2a945d6f41f1f4e5098ad65347492c1281565b6101656101c13660046116c2565b6103c3565b6006546101d9906001600160a01b031681565b6040516001600160a01b03909116815260200161017a565b6101656101ff366004611759565b6104b5565b610165610212366004611772565b6105eb565b6101707f7d824962dd0f01520922ea1766c987b1db570cd5db90bdba5ccf5e320607950281565b61017061024c36600461179c565b60026020526000908152604090205481565b61016561026c3660046117b7565b610727565b61016561027f36600461179c565b6107f2565b6102b961029236600461179c565b60046020526000908152604090208054600182015460028301546003909301549192909184565b60408051948552602085019390935291830152606082015260800161017a565b6006546102ed90600160a01b900460ff1681565b604051901515815260200161017a565b6101706108e0565b610165610313366004611772565b610952565b6101707fe95f353750f192082df064ca5142d3a2d6f0bef0f3ffad66d80d8af86b7a749a81565b610170610a86565b6101707fc2f8787176b8ac6bf7215b4adcc1e069bf4ab82d9ab1df05a57a91d425935b6e81565b61017061037c36600461179c565b610a9d565b61016561038f36600461166b565b610ace565b61017060055481565b6001546101d9906001600160a01b031681565b6103be338484600085610bd9565b505050565b604080517f7d824962dd0f01520922ea1766c987b1db570cd5db90bdba5ccf5e32060795026020808301919091523082840152336060830152608082018790526001600160a01b03881660a083015260c08083018690528351808403909101815260e0909201909252805191012061043b9084611023565b6001600160a01b0316866001600160a01b0316146104a05760405162461bcd60e51b815260206004820152601d60248201527f696e76616c69642062656e6566696369617279207369676e617475726500000060448201526064015b60405180910390fd5b6104ad8686868585610bd9565b505050505050565b6006546001600160a01b031633146104fc5760405162461bcd60e51b815260206004820152600a6024820152693737ba1034b9b9bab2b960b11b6044820152606401610497565b610504610a86565b8111156105535760405162461bcd60e51b815260206004820152601c60248201527f6c697175696442616c616e6365206e6f742073756666696369656e74000000006044820152606401610497565b60015460065460405163a9059cbb60e01b81526001600160a01b0391821660048201526024810184905291169063a9059cbb906044016020604051808303816000875af11580156105a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105cc91906117f3565b6105e85760405162461bcd60e51b815260040161049790611815565b50565b6006546001600160a01b0316331461063e5760405162461bcd60e51b815260206004820152601660248201527529b4b6b83632a9bbb0b81d103737ba1034b9b9bab2b960511b6044820152606401610497565b6106466108e0565b816005546106549190611854565b11156106a25760405162461bcd60e51b815260206004820152601c60248201527f68617264206465706f73697420657863656564732062616c616e6365000000006044820152606401610497565b6001600160a01b038216600090815260046020526040902080546106c7908390611854565b81556005546106d7908390611854565b6005556000600382015580546040519081526001600160a01b038416907f2506c43272ded05d095b91dbba876e66e46888157d3e078db5691496e96c5fad906020015b60405180910390a2505050565b6001600160a01b03831661076e5760405162461bcd60e51b815260206004820152600e60248201526d34b73b30b634b21034b9b9bab2b960911b6044820152606401610497565b6006546001600160a01b0316156107bd5760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610497565b600680546001600160a01b039485166001600160a01b0319918216179091556001805493909416921691909117909155600055565b6001600160a01b0381166000908152600460205260409020600381015442108015906108215750600381015415155b61086d5760405162461bcd60e51b815260206004820152601960248201527f6465706f736974206e6f74207965742074696d6564206f7574000000000000006044820152606401610497565b6001810154815461087e9190611867565b81556000600382015560018101546005546108999190611867565b60055580546040519081526001600160a01b038316907f2506c43272ded05d095b91dbba876e66e46888157d3e078db5691496e96c5fad9060200160405180910390a25050565b6001546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610929573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094d919061187a565b905090565b6006546001600160a01b031633146109a55760405162461bcd60e51b815260206004820152601660248201527529b4b6b83632a9bbb0b81d103737ba1034b9b9bab2b960511b6044820152606401610497565b6001600160a01b03821660009081526004602052604090208054821115610a0e5760405162461bcd60e51b815260206004820152601b60248201527f68617264206465706f736974206e6f742073756666696369656e7400000000006044820152606401610497565b60008160020154600014610a26578160020154610a2a565b6000545b9050610a368142611854565b6003830155600182018390556040518381526001600160a01b038516907fc8305077b495025ec4c1d977b176a762c350bb18cad4666ce1ee85c32b78698a9060200160405180910390a250505050565b6000600554610a936108e0565b61094d9190611867565b6001600160a01b038116600090815260046020526040812054610abe610a86565b610ac89190611854565b92915050565b6006546001600160a01b03163314610b155760405162461bcd60e51b815260206004820152600a6024820152693737ba1034b9b9bab2b960b11b6044820152606401610497565b610b29610b233085856110f3565b82611023565b6001600160a01b0316836001600160a01b031614610b895760405162461bcd60e51b815260206004820152601d60248201527f696e76616c69642062656e6566696369617279207369676e61747572650000006044820152606401610497565b6001600160a01b03831660008181526004602052604090819020600201849055517f7b816003a769eb718bd9c66bdbd2dd5827da3f92bc6645276876bd7957b08cf09061071a9085815260200190565b6006546001600160a01b03163314610c5657610bf9610b23308786611164565b6006546001600160a01b03908116911614610c565760405162461bcd60e51b815260206004820152601860248201527f696e76616c696420697373756572207369676e617475726500000000000000006044820152606401610497565b6001600160a01b038516600090815260026020526040812054610c799085611867565b90506000610c8f82610c8a89610a9d565b6111ba565b6001600160a01b03881660009081526004602052604081205491925090610cb79083906111ba565b905084821015610d095760405162461bcd60e51b815260206004820152601d60248201527f53696d706c65537761703a2063616e6e6f74207061792063616c6c65720000006044820152606401610497565b8015610d5e576001600160a01b038816600090815260046020526040902054610d33908290611867565b6001600160a01b038916600090815260046020526040902055600554610d5a908290611867565b6005555b6001600160a01b038816600090815260026020526040902054610d82908390611854565b6001600160a01b038916600090815260026020526040902055600354610da9908390611854565b600355828214610df0576006805460ff60a01b1916600160a01b1790556040517f3f4449c047e11092ec54dc0751b6b4817a9162745de856c893a26e611d18ffc490600090a15b8415610f335760015460405163a9059cbb60e01b8152336004820152602481018790526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015610e47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6b91906117f3565b610e875760405162461bcd60e51b815260040161049790611815565b6001546001600160a01b031663a9059cbb88610ea38886611867565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015610eee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1291906117f3565b610f2e5760405162461bcd60e51b815260040161049790611815565b610fc6565b60015460405163a9059cbb60e01b81526001600160a01b038981166004830152602482018590529091169063a9059cbb906044016020604051808303816000875af1158015610f86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610faa91906117f3565b610fc65760405162461bcd60e51b815260040161049790611815565b604080518381526020810188905290810186905233906001600160a01b0389811691908b16907f950494fc3642fae5221b6c32e0e45765c95ebb382a04a71b160db0843e74c99f9060600160405180910390a45050505050505050565b6000806110a96110316111d2565b805180516020918201208183015180519083012060408085015181517fc2f8787176b8ac6bf7215b4adcc1e069bf4ab82d9ab1df05a57a91d425935b6e95810195909552908401929092526060830152608082015260009060a001604051602081830303815290604052805190602001209050919050565b60405161190160f01b60208201526022810191909152604281018590526062016040516020818303038152906040528051906020012090506110eb8184611248565b949350505050565b604080517fe95f353750f192082df064ca5142d3a2d6f0bef0f3ffad66d80d8af86b7a749a60208201526001600160a01b038086169282019290925290831660608201526080810182905260009060a0015b6040516020818303038152906040528051906020012090509392505050565b604080517f48ebe6deff4a5ee645c01506a026031e2a945d6f41f1f4e5098ad65347492c1260208201526001600160a01b038086169282019290925290831660608201526080810182905260009060a001611145565b60008183106111c957816111cb565b825b9392505050565b6111f660405180606001604052806060815260200160608152602001600081525090565b506040805160a081018252600a6060820190815269436865717565626f6f6b60b01b608083015281528151808301835260038152620312e360ec1b602082810191909152820152469181019190915290565b6000806000611257858561126c565b91509150611264816112da565b509392505050565b60008082516041036112a25760208301516040840151606085015160001a61129687828585611490565b945094505050506112d3565b82516040036112cb57602083015160408401516112c086838361157d565b9350935050506112d3565b506000905060025b9250929050565b60008160048111156112ee576112ee611893565b036112f65750565b600181600481111561130a5761130a611893565b036113575760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610497565b600281600481111561136b5761136b611893565b036113b85760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610497565b60038160048111156113cc576113cc611893565b036114245760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610497565b600481600481111561143857611438611893565b036105e85760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610497565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156114c75750600090506003611574565b8460ff16601b141580156114df57508460ff16601c14155b156114f05750600090506004611574565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611544573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661156d57600060019250925050611574565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b0161159e87828885611490565b935093505050935093915050565b80356001600160a01b03811681146115c357600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126115ef57600080fd5b813567ffffffffffffffff8082111561160a5761160a6115c8565b604051601f8301601f19908116603f01168101908282118183101715611632576116326115c8565b8160405283815286602085880101111561164b57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060006060848603121561168057600080fd5b611689846115ac565b925060208401359150604084013567ffffffffffffffff8111156116ac57600080fd5b6116b8868287016115de565b9150509250925092565b60008060008060008060c087890312156116db57600080fd5b6116e4876115ac565b95506116f2602088016115ac565b945060408701359350606087013567ffffffffffffffff8082111561171657600080fd5b6117228a838b016115de565b94506080890135935060a089013591508082111561173f57600080fd5b5061174c89828a016115de565b9150509295509295509295565b60006020828403121561176b57600080fd5b5035919050565b6000806040838503121561178557600080fd5b61178e836115ac565b946020939093013593505050565b6000602082840312156117ae57600080fd5b6111cb826115ac565b6000806000606084860312156117cc57600080fd5b6117d5846115ac565b92506117e3602085016115ac565b9150604084013590509250925092565b60006020828403121561180557600080fd5b815180151581146111cb57600080fd5b6020808252600f908201526e1d1c985b9cd9995c8819985a5b1959608a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610ac857610ac861183e565b81810381811115610ac857610ac861183e565b60006020828403121561188c57600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220e7a6fb62d773ba85f997655dd2fe29f2d8180eac7cdbc266d60046566974e58264736f6c63430008130033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806315efd8a714610051578063a6021ace14610081578063c70242ad14610094578063ee97f7f3146100c7575b600080fd5b61006461005f3660046102b1565b6100da565b6040516001600160a01b0390911681526020015b60405180910390f35b600154610064906001600160a01b031681565b6100b76100a23660046102e4565b60006020819052908152604090205460ff1681565b6040519015158152602001610078565b600254610064906001600160a01b031681565b60025460408051336020820152908101839052600091829161011e916001600160a01b031690606001604051602081830303815290604052805190602001206101eb565b6001546040516343431f6360e11b81526001600160a01b0388811660048301529182166024820152604481018790529192508216906386863ec690606401600060405180830381600087803b15801561017657600080fd5b505af115801561018a573d6000803e3d6000fd5b505050506001600160a01b03811660008181526020818152604091829020805460ff1916600117905590519182527fc0ffc525a1c7689549d7f79b49eca900e61ac49b43d977f680bcc3b36224c004910160405180910390a1949350505050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528360601b60148201526e5af43d82803e903d91602b57fd5bf360881b6028820152826037826000f59150506001600160a01b03811661028f5760405162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c6564000000000000000000604482015260640160405180910390fd5b92915050565b80356001600160a01b03811681146102ac57600080fd5b919050565b6000806000606084860312156102c657600080fd5b6102cf84610295565b95602085013595506040909401359392505050565b6000602082840312156102f657600080fd5b6102ff82610295565b939250505056fea26469706673582212203f76e42322bce6a35f6ef0357cad6785061a54bbbe936b5cc1a425f13408ffbc64736f6c63430008130033", + "numDeployments": 3, + "solcInputHash": "126591187300f42d56a4b4d666be9f01", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_ERC20Address\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"contractAddress\",\"type\":\"address\"}],\"name\":\"SimpleSwapDeployed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"ERC20Address\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"issuer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"defaultHardDepositTimeoutDuration\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"salt\",\"type\":\"bytes32\"}],\"name\":\"deploySimpleSwap\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"deployedContracts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"master\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"The Swarm Authors\",\"kind\":\"dev\",\"methods\":{\"deploySimpleSwap(address,uint256,bytes32)\":{\"params\":{\"defaultHardDepositTimeoutDuration\":\"duration in seconds which by default will be used to reduce hardDeposit allocations\",\"issuer\":\"the issuer of cheques for the new chequebook\",\"salt\":\"salt to include in create2 to enable the same address to deploy multiple chequebooks\"}}},\"title\":\"Factory contract for SimpleSwap\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"deploySimpleSwap(address,uint256,bytes32)\":{\"notice\":\"creates a clone of the master SimpleSwap contract\"}},\"notice\":\"This contract deploys SimpleSwap contracts\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/SimpleSwapFactory.sol\":\"SimpleSwapFactory\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/EnumerableSet.sol\\\";\\nimport \\\"../utils/Address.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n using Address for address;\\n\\n struct RoleData {\\n EnumerableSet.AddressSet members;\\n bytes32 adminRole;\\n }\\n\\n mapping (bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view returns (bool) {\\n return _roles[role].members.contains(account);\\n }\\n\\n /**\\n * @dev Returns the number of accounts that have `role`. Can be used\\n * together with {getRoleMember} to enumerate all bearers of a role.\\n */\\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\\n return _roles[role].members.length();\\n }\\n\\n /**\\n * @dev Returns one of the accounts that have `role`. `index` must be a\\n * value between 0 and {getRoleMemberCount}, non-inclusive.\\n *\\n * Role bearers are not sorted in any particular way, and their ordering may\\n * change at any point.\\n *\\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\\n * you perform all queries on the same block. See the following\\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\\n * for more information.\\n */\\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\\n return _roles[role].members.at(index);\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) public virtual {\\n require(hasRole(_roles[role].adminRole, _msgSender()), \\\"AccessControl: sender must be an admin to grant\\\");\\n\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) public virtual {\\n require(hasRole(_roles[role].adminRole, _msgSender()), \\\"AccessControl: sender must be an admin to revoke\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) public virtual {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\\n _roles[role].adminRole = adminRole;\\n }\\n\\n function _grantRole(bytes32 role, address account) private {\\n if (_roles[role].members.add(account)) {\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n function _revokeRole(bytes32 role, address account) private {\\n if (_roles[role].members.remove(account)) {\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4fc155a2f7837603d69a13cfa481eb5e7f5e02cb77e2ec9edbac30986db37988\",\"license\":\"MIT\"},\"@openzeppelin/contracts/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\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 /**\\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 // Check the signature length\\n if (signature.length != 65) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n }\\n\\n // Divide the signature in r, s and v variables\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n // solhint-disable-next-line no-inline-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\\n return recover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\\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 (281): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (282): 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 require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, \\\"ECDSA: invalid signature 's' value\\\");\\n require(v == 27 || v == 28, \\\"ECDSA: invalid signature 'v' value\\\");\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n require(signer != address(0), \\\"ECDSA: invalid signature\\\");\\n\\n return signer;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * replicates the behavior of the\\n * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]\\n * JSON-RPC method.\\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\",\"keccak256\":\"0x94c4719c16ffb96dd3cdc68f6fbf78105153018adbf382241821e8188e6a4bd5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\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, so we distribute\\n return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);\\n }\\n}\\n\",\"keccak256\":\"0x363bd3b45201f07c9b71c2edc96533468cf14a3d029fabd82fddceb1eb3ebd9c\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * 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 */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xcc78a17dd88fa5a2edc60c8489e2f405c0913b377216a5b26b35656b2d0dab52\",\"license\":\"MIT\"},\"@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../access/AccessControl.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\nimport \\\"../token/ERC20/ERC20.sol\\\";\\nimport \\\"../token/ERC20/ERC20Burnable.sol\\\";\\nimport \\\"../token/ERC20/ERC20Pausable.sol\\\";\\n\\n/**\\n * @dev {ERC20} token, including:\\n *\\n * - ability for holders to burn (destroy) their tokens\\n * - a minter role that allows for token minting (creation)\\n * - a pauser role that allows to stop all token transfers\\n *\\n * This contract uses {AccessControl} to lock permissioned functions using the\\n * different roles - head to its documentation for details.\\n *\\n * The account that deploys the contract will be granted the minter and pauser\\n * roles, as well as the default admin role, which will let it grant both minter\\n * and pauser roles to other accounts.\\n */\\ncontract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20Pausable {\\n bytes32 public constant MINTER_ROLE = keccak256(\\\"MINTER_ROLE\\\");\\n bytes32 public constant PAUSER_ROLE = keccak256(\\\"PAUSER_ROLE\\\");\\n\\n /**\\n * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the\\n * account that deploys the contract.\\n *\\n * See {ERC20-constructor}.\\n */\\n constructor(string memory name, string memory symbol) public ERC20(name, symbol) {\\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\\n\\n _setupRole(MINTER_ROLE, _msgSender());\\n _setupRole(PAUSER_ROLE, _msgSender());\\n }\\n\\n /**\\n * @dev Creates `amount` new tokens for `to`.\\n *\\n * See {ERC20-_mint}.\\n *\\n * Requirements:\\n *\\n * - the caller must have the `MINTER_ROLE`.\\n */\\n function mint(address to, uint256 amount) public virtual {\\n require(hasRole(MINTER_ROLE, _msgSender()), \\\"ERC20PresetMinterPauser: must have minter role to mint\\\");\\n _mint(to, amount);\\n }\\n\\n /**\\n * @dev Pauses all token transfers.\\n *\\n * See {ERC20Pausable} and {Pausable-_pause}.\\n *\\n * Requirements:\\n *\\n * - the caller must have the `PAUSER_ROLE`.\\n */\\n function pause() public virtual {\\n require(hasRole(PAUSER_ROLE, _msgSender()), \\\"ERC20PresetMinterPauser: must have pauser role to pause\\\");\\n _pause();\\n }\\n\\n /**\\n * @dev Unpauses all token transfers.\\n *\\n * See {ERC20Pausable} and {Pausable-_unpause}.\\n *\\n * Requirements:\\n *\\n * - the caller must have the `PAUSER_ROLE`.\\n */\\n function unpause() public virtual {\\n require(hasRole(PAUSER_ROLE, _msgSender()), \\\"ERC20PresetMinterPauser: must have pauser role to unpause\\\");\\n _unpause();\\n }\\n\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) {\\n super._beforeTokenTransfer(from, to, amount);\\n }\\n}\\n\",\"keccak256\":\"0xa7c607ed4a0b2bebb811a398838ce4b5165e490f420a06337478eb2ba8c90cfc\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Clones.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\\n * deploying minimal proxy contracts, also known as \\\"clones\\\".\\n *\\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\\n *\\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\\n * deterministic method.\\n *\\n * _Available since v3.4._\\n */\\nlibrary Clones {\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\\n *\\n * This function uses the create opcode, which should never revert.\\n */\\n function clone(address master) internal returns (address instance) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create(0, ptr, 0x37)\\n }\\n require(instance != address(0), \\\"ERC1167: create failed\\\");\\n }\\n\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\\n *\\n * This function uses the create2 opcode and a `salt` to deterministically deploy\\n * the clone. Using the same `master` and `salt` multiple time will revert, since\\n * the clones cannot be deployed twice at the same address.\\n */\\n function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create2(0, ptr, 0x37, salt)\\n }\\n require(instance != address(0), \\\"ERC1167: create2 failed\\\");\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\\n mstore(add(ptr, 0x38), shl(0x60, deployer))\\n mstore(add(ptr, 0x4c), salt)\\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\\n predicted := keccak256(add(ptr, 0x37), 0x55)\\n }\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {\\n return predictDeterministicAddress(master, salt, address(this));\\n }\\n}\\n\",\"keccak256\":\"0x0d24348f536f928d8b42789737bf34762faee065667ab530ea20969a9d9920d1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20 {\\n using SafeMath for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor (string memory name_, string memory symbol_) public {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\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 *\\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 *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n}\\n\",\"keccak256\":\"0xca0c2396dbeb3503b51abf4248ebf77a1461edad513c01529df51850a012bee3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./ERC20.sol\\\";\\n\\n/**\\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\\n * tokens and those that they have an allowance for, in a way that can be\\n * recognized off-chain (via event analysis).\\n */\\nabstract contract ERC20Burnable is Context, ERC20 {\\n using SafeMath for uint256;\\n\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, \\\"ERC20: burn amount exceeds allowance\\\");\\n\\n _approve(account, _msgSender(), decreasedAllowance);\\n _burn(account, amount);\\n }\\n}\\n\",\"keccak256\":\"0x9c0eb3b0e11d2480d49991dc384f1e5f9c9b9967cc81944d50916a9b9c6c4984\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"./ERC20.sol\\\";\\nimport \\\"../../utils/Pausable.sol\\\";\\n\\n/**\\n * @dev ERC20 token with pausable token transfers, minting and burning.\\n *\\n * Useful for scenarios such as preventing trades until the end of an evaluation\\n * period, or having an emergency switch for freezing all token transfers in the\\n * event of a large bug.\\n */\\nabstract contract ERC20Pausable is ERC20, Pausable {\\n /**\\n * @dev See {ERC20-_beforeTokenTransfer}.\\n *\\n * Requirements:\\n *\\n * - the contract must not be paused.\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {\\n super._beforeTokenTransfer(from, to, amount);\\n\\n require(!paused(), \\\"ERC20Pausable: token transfer while paused\\\");\\n }\\n}\\n\",\"keccak256\":\"0xa22af140ae7ec1f8f2f3bed5869cd0d548dfaac66343f0efc7324ff34aaf1254\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <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 `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, 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 `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) 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\":\"0x5f02220344881ce43204ae4a6281145a67bc52c2bb1290a791857df3d19d78f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\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 function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 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 // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) 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 // solhint-disable-next-line avoid-low-level-calls\\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 // solhint-disable-next-line no-inline-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}\\n\",\"keccak256\":\"0x28911e614500ae7c607a432a709d35da25f3bc5ddc8bd12b278b66358070c0ea\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <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 GSN 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 payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping (bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) { // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\\n\\n bytes32 lastvalue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastvalue;\\n // Update the index for the moved value\\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n require(set._values.length > index, \\\"EnumerableSet: index out of bounds\\\");\\n return set._values[index];\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n}\\n\",\"keccak256\":\"0x1562cd9922fbf739edfb979f506809e2743789cbde3177515542161c3d04b164\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Pausable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"./Context.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract Pausable is Context {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n constructor () internal {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n require(!paused(), \\\"Pausable: paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n require(paused(), \\\"Pausable: not paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n}\\n\",\"keccak256\":\"0x212fb1b1d4beaf74354dad9bc329f44ee3c5375ef1c32acff76b4ecefc10f1d8\",\"license\":\"MIT\"},\"contracts/ERC20SimpleSwap.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity =0.7.6;\\npragma abicoder v2;\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/math/Math.sol\\\";\\nimport \\\"@openzeppelin/contracts/cryptography/ECDSA.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol\\\";\\n\\n\\n/**\\n@title Chequebook contract without waivers\\n@author The Swarm Authors\\n@notice The chequebook contract allows the issuer of the chequebook to send cheques to an unlimited amount of counterparties.\\nFurthermore, solvency can be guaranteed via hardDeposits\\n@dev as an issuer, no cheques should be send if the cumulative worth of a cheques send is above the cumulative worth of all deposits\\nas a beneficiary, we should always take into account the possibility that a cheque bounces (when no hardDeposits are assigned)\\n*/\\ncontract ERC20SimpleSwap {\\n using SafeMath for uint;\\n\\n event ChequeCashed(\\n address indexed beneficiary,\\n address indexed recipient,\\n address indexed caller,\\n uint totalPayout,\\n uint cumulativePayout,\\n uint callerPayout\\n );\\n event ChequeBounced();\\n event HardDepositAmountChanged(address indexed beneficiary, uint amount);\\n event HardDepositDecreasePrepared(address indexed beneficiary, uint decreaseAmount);\\n event HardDepositTimeoutChanged(address indexed beneficiary, uint timeout);\\n event Withdraw(uint amount);\\n\\n uint public defaultHardDepositTimeout;\\n /* structure to keep track of the hard deposits (on-chain guarantee of solvency) per beneficiary*/\\n struct HardDeposit {\\n uint amount; /* hard deposit amount allocated */\\n uint decreaseAmount; /* decreaseAmount substranced from amount when decrease is requested */\\n uint timeout; /* issuer has to wait timeout seconds to decrease hardDeposit, 0 implies applying defaultHardDepositTimeout */\\n uint canBeDecreasedAt; /* point in time after which harddeposit can be decreased*/\\n }\\n\\n struct EIP712Domain {\\n string name;\\n string version;\\n uint256 chainId;\\n }\\n\\n bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId)\\\"\\n );\\n bytes32 public constant CHEQUE_TYPEHASH = keccak256(\\n \\\"Cheque(address chequebook,address beneficiary,uint256 cumulativePayout)\\\"\\n );\\n bytes32 public constant CASHOUT_TYPEHASH = keccak256(\\n \\\"Cashout(address chequebook,address sender,uint256 requestPayout,address recipient,uint256 callerPayout)\\\"\\n );\\n bytes32 public constant CUSTOMDECREASETIMEOUT_TYPEHASH = keccak256(\\n \\\"CustomDecreaseTimeout(address chequebook,address beneficiary,uint256 decreaseTimeout)\\\"\\n );\\n\\n // the EIP712 domain this contract uses\\n function domain() internal pure returns (EIP712Domain memory) {\\n uint256 chainId;\\n assembly {\\n chainId := chainid()\\n }\\n return EIP712Domain({\\n name: \\\"Chequebook\\\",\\n version: \\\"1.0\\\",\\n chainId: chainId\\n });\\n }\\n\\n // compute the EIP712 domain separator. this cannot be constant because it depends on chainId\\n function domainSeparator(EIP712Domain memory eip712Domain) internal pure returns (bytes32) {\\n return keccak256(abi.encode(\\n EIP712DOMAIN_TYPEHASH,\\n keccak256(bytes(eip712Domain.name)),\\n keccak256(bytes(eip712Domain.version)),\\n eip712Domain.chainId\\n ));\\n }\\n\\n // recover a signature with the EIP712 signing scheme\\n function recoverEIP712(bytes32 hash, bytes memory sig) internal pure returns (address) {\\n bytes32 digest = keccak256(abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n domainSeparator(domain()),\\n hash\\n ));\\n return ECDSA.recover(digest, sig);\\n }\\n\\n /* The token against which this chequebook writes cheques */\\n ERC20 public token;\\n /* associates every beneficiary with how much has been paid out to them */\\n mapping (address => uint) public paidOut;\\n /* total amount paid out */\\n uint public totalPaidOut;\\n /* associates every beneficiary with their HardDeposit */\\n mapping (address => HardDeposit) public hardDeposits;\\n /* sum of all hard deposits */\\n uint public totalHardDeposit;\\n /* issuer of the contract, set at construction */\\n address public issuer;\\n /* indicates wether a cheque bounced in the past */\\n bool public bounced;\\n\\n /**\\n @notice sets the issuer, token and the defaultHardDepositTimeout. can only be called once.\\n @param _issuer the issuer of cheques from this chequebook (needed as an argument for \\\"Setting up a chequebook as a payment\\\").\\n _issuer must be an Externally Owned Account, or it must support calling the function cashCheque\\n @param _token the token this chequebook uses\\n @param _defaultHardDepositTimeout duration in seconds which by default will be used to reduce hardDeposit allocations\\n */\\n function init(address _issuer, address _token, uint _defaultHardDepositTimeout) public {\\n require(_issuer != address(0), \\\"invalid issuer\\\");\\n require(issuer == address(0), \\\"already initialized\\\");\\n issuer = _issuer;\\n token = ERC20(_token);\\n defaultHardDepositTimeout = _defaultHardDepositTimeout;\\n }\\n\\n /// @return the balance of the chequebook\\n function balance() public view returns(uint) {\\n return token.balanceOf(address(this));\\n }\\n /// @return the part of the balance that is not covered by hard deposits\\n function liquidBalance() public view returns(uint) {\\n return balance().sub(totalHardDeposit);\\n }\\n\\n /// @return the part of the balance available for a specific beneficiary\\n function liquidBalanceFor(address beneficiary) public view returns(uint) {\\n return liquidBalance().add(hardDeposits[beneficiary].amount);\\n }\\n /**\\n @dev internal function responsible for checking the issuerSignature, updating hardDeposit balances and doing transfers.\\n Called by cashCheque and cashChequeBeneficary\\n @param beneficiary the beneficiary to which cheques were assigned. Beneficiary must be an Externally Owned Account\\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\\n @param cumulativePayout cumulative amount of cheques assigned to beneficiary\\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\\n */\\n function _cashChequeInternal(\\n address beneficiary,\\n address recipient,\\n uint cumulativePayout,\\n uint callerPayout,\\n bytes memory issuerSig\\n ) internal {\\n /* The issuer must have given explicit approval to the cumulativePayout, either by being the caller or by signature*/\\n if (msg.sender != issuer) {\\n require(issuer == recoverEIP712(chequeHash(address(this), beneficiary, cumulativePayout), issuerSig),\\n \\\"invalid issuer signature\\\");\\n }\\n /* the requestPayout is the amount requested for payment processing */\\n uint requestPayout = cumulativePayout.sub(paidOut[beneficiary]);\\n /* calculates acutal payout */\\n uint totalPayout = Math.min(requestPayout, liquidBalanceFor(beneficiary));\\n /* calculates hard-deposit usage */\\n uint hardDepositUsage = Math.min(totalPayout, hardDeposits[beneficiary].amount);\\n require(totalPayout >= callerPayout, \\\"SimpleSwap: cannot pay caller\\\");\\n /* if there are some of the hard deposit used, update hardDeposits*/\\n if (hardDepositUsage != 0) {\\n hardDeposits[beneficiary].amount = hardDeposits[beneficiary].amount.sub(hardDepositUsage);\\n\\n totalHardDeposit = totalHardDeposit.sub(hardDepositUsage);\\n }\\n /* increase the stored paidOut amount to avoid double payout */\\n paidOut[beneficiary] = paidOut[beneficiary].add(totalPayout);\\n totalPaidOut = totalPaidOut.add(totalPayout);\\n\\n /* let the world know that the issuer has over-promised on outstanding cheques */\\n if (requestPayout != totalPayout) {\\n bounced = true;\\n emit ChequeBounced();\\n }\\n\\n if (callerPayout != 0) {\\n /* do a transfer to the caller if specified*/\\n require(token.transfer(msg.sender, callerPayout), \\\"transfer failed\\\");\\n /* do the actual payment */\\n require(token.transfer(recipient, totalPayout.sub(callerPayout)), \\\"transfer failed\\\");\\n } else {\\n /* do the actual payment */\\n require(token.transfer(recipient, totalPayout), \\\"transfer failed\\\");\\n }\\n\\n emit ChequeCashed(beneficiary, recipient, msg.sender, totalPayout, cumulativePayout, callerPayout);\\n }\\n /**\\n @notice cash a cheque of the beneficiary by a non-beneficiary and reward the sender for doing so with callerPayout\\n @dev a beneficiary must be able to generate signatures (be an Externally Owned Account) to make use of this feature\\n @param beneficiary the beneficiary to which cheques were assigned. Beneficiary must be an Externally Owned Account\\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\\n @param cumulativePayout cumulative amount of cheques assigned to beneficiary\\n @param beneficiarySig beneficiary must have given explicit approval for cashing out the cumulativePayout by the sender and sending the callerPayout\\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\\n @param callerPayout when beneficiary does not have ether yet, he can incentivize other people to cash cheques with help of callerPayout\\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\\n */\\n function cashCheque(\\n address beneficiary,\\n address recipient,\\n uint cumulativePayout,\\n bytes memory beneficiarySig,\\n uint256 callerPayout,\\n bytes memory issuerSig\\n ) public {\\n require(\\n beneficiary == recoverEIP712(\\n cashOutHash(\\n address(this),\\n msg.sender,\\n cumulativePayout,\\n recipient,\\n callerPayout\\n ), beneficiarySig\\n ), \\\"invalid beneficiary signature\\\");\\n _cashChequeInternal(beneficiary, recipient, cumulativePayout, callerPayout, issuerSig);\\n }\\n\\n /**\\n @notice cash a cheque as beneficiary\\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\\n @param cumulativePayout amount requested to pay out\\n @param issuerSig issuer must have given explicit approval on the cumulativePayout to the beneficiary\\n */\\n function cashChequeBeneficiary(address recipient, uint cumulativePayout, bytes memory issuerSig) public {\\n _cashChequeInternal(msg.sender, recipient, cumulativePayout, 0, issuerSig);\\n }\\n\\n /**\\n @notice prepare to decrease the hard deposit\\n @dev decreasing hardDeposits must be done in two steps to allow beneficiaries to cash any uncashed cheques (and make use of the assgined hard-deposits)\\n @param beneficiary beneficiary whose hard deposit should be decreased\\n @param decreaseAmount amount that the deposit is supposed to be decreased by\\n */\\n function prepareDecreaseHardDeposit(address beneficiary, uint decreaseAmount) public {\\n require(msg.sender == issuer, \\\"SimpleSwap: not issuer\\\");\\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\\n /* cannot decrease it by more than the deposit */\\n require(decreaseAmount <= hardDeposit.amount, \\\"hard deposit not sufficient\\\");\\n // if hardDeposit.timeout was never set, apply defaultHardDepositTimeout\\n uint timeout = hardDeposit.timeout == 0 ? defaultHardDepositTimeout : hardDeposit.timeout;\\n hardDeposit.canBeDecreasedAt = block.timestamp + timeout;\\n hardDeposit.decreaseAmount = decreaseAmount;\\n emit HardDepositDecreasePrepared(beneficiary, decreaseAmount);\\n }\\n\\n /**\\n @notice decrease the hard deposit after waiting the necesary amount of time since prepareDecreaseHardDeposit was called\\n @param beneficiary beneficiary whose hard deposit should be decreased\\n */\\n function decreaseHardDeposit(address beneficiary) public {\\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\\n require(block.timestamp >= hardDeposit.canBeDecreasedAt && hardDeposit.canBeDecreasedAt != 0, \\\"deposit not yet timed out\\\");\\n /* this throws if decreaseAmount > amount */\\n //TODO: if there is a cash-out in between prepareDecreaseHardDeposit and decreaseHardDeposit, decreaseHardDeposit will throw and reducing hard-deposits is impossible.\\n hardDeposit.amount = hardDeposit.amount.sub(hardDeposit.decreaseAmount);\\n /* reset the canBeDecreasedAt to avoid a double decrease */\\n hardDeposit.canBeDecreasedAt = 0;\\n /* keep totalDeposit in sync */\\n totalHardDeposit = totalHardDeposit.sub(hardDeposit.decreaseAmount);\\n emit HardDepositAmountChanged(beneficiary, hardDeposit.amount);\\n }\\n\\n /**\\n @notice increase the hard deposit\\n @param beneficiary beneficiary whose hard deposit should be decreased\\n @param amount the new hard deposit\\n */\\n function increaseHardDeposit(address beneficiary, uint amount) public {\\n require(msg.sender == issuer, \\\"SimpleSwap: not issuer\\\");\\n /* ensure hard deposits don't exceed the global balance */\\n require(totalHardDeposit.add(amount) <= balance(), \\\"hard deposit exceeds balance\\\");\\n\\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\\n hardDeposit.amount = hardDeposit.amount.add(amount);\\n // we don't explicitely set hardDepositTimout, as zero means using defaultHardDepositTimeout\\n totalHardDeposit = totalHardDeposit.add(amount);\\n /* disable any pending decrease */\\n hardDeposit.canBeDecreasedAt = 0;\\n emit HardDepositAmountChanged(beneficiary, hardDeposit.amount);\\n }\\n\\n /**\\n @notice allows for setting a custom hardDepositDecreaseTimeout per beneficiary\\n @dev this is required when solvency must be guaranteed for a period longer than the defaultHardDepositDecreaseTimeout\\n @param beneficiary beneficiary whose hard deposit decreaseTimeout must be changed\\n @param hardDepositTimeout new hardDeposit.timeout for beneficiary\\n @param beneficiarySig beneficiary must give explicit approval by giving his signature on the new decreaseTimeout\\n */\\n function setCustomHardDepositTimeout(\\n address beneficiary,\\n uint hardDepositTimeout,\\n bytes memory beneficiarySig\\n ) public {\\n require(msg.sender == issuer, \\\"not issuer\\\");\\n require(\\n beneficiary == recoverEIP712(customDecreaseTimeoutHash(address(this), beneficiary, hardDepositTimeout), beneficiarySig),\\n \\\"invalid beneficiary signature\\\"\\n );\\n hardDeposits[beneficiary].timeout = hardDepositTimeout;\\n emit HardDepositTimeoutChanged(beneficiary, hardDepositTimeout);\\n }\\n\\n /// @notice withdraw ether\\n /// @param amount amount to withdraw\\n // solhint-disable-next-line no-simple-event-func-name\\n function withdraw(uint amount) public {\\n /* only issuer can do this */\\n require(msg.sender == issuer, \\\"not issuer\\\");\\n /* ensure we don't take anything from the hard deposit */\\n require(amount <= liquidBalance(), \\\"liquidBalance not sufficient\\\");\\n require(token.transfer(issuer, amount), \\\"transfer failed\\\");\\n }\\n\\n function chequeHash(address chequebook, address beneficiary, uint cumulativePayout)\\n internal pure returns (bytes32) {\\n return keccak256(abi.encode(\\n CHEQUE_TYPEHASH,\\n chequebook,\\n beneficiary,\\n cumulativePayout\\n ));\\n } \\n\\n function cashOutHash(address chequebook, address sender, uint requestPayout, address recipient, uint callerPayout)\\n internal pure returns (bytes32) {\\n return keccak256(abi.encode(\\n CASHOUT_TYPEHASH,\\n chequebook,\\n sender,\\n requestPayout,\\n recipient,\\n callerPayout\\n ));\\n }\\n\\n function customDecreaseTimeoutHash(address chequebook, address beneficiary, uint decreaseTimeout)\\n internal pure returns (bytes32) {\\n return keccak256(abi.encode(\\n CUSTOMDECREASETIMEOUT_TYPEHASH,\\n chequebook,\\n beneficiary,\\n decreaseTimeout\\n ));\\n }\\n}\",\"keccak256\":\"0x7bd0873a5b75bd94a5de127b2e60cb52ebb3a365651e2bb3dba86bcc4134ea6d\",\"license\":\"BSD-3-Clause\"},\"contracts/SimpleSwapFactory.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity =0.7.6;\\npragma abicoder v2;\\nimport \\\"./ERC20SimpleSwap.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/Clones.sol\\\";\\n\\n/**\\n@title Factory contract for SimpleSwap\\n@author The Swarm Authors\\n@notice This contract deploys SimpleSwap contracts\\n*/\\ncontract SimpleSwapFactory {\\n\\n /* event fired on every new SimpleSwap deployment */\\n event SimpleSwapDeployed(address contractAddress);\\n\\n /* mapping to keep track of which contracts were deployed by this factory */\\n mapping (address => bool) public deployedContracts;\\n\\n /* address of the ERC20-token, to be used by the to-be-deployed chequebooks */\\n address public ERC20Address;\\n /* address of the code contract from which all chequebooks are cloned */\\n address public master;\\n\\n constructor(address _ERC20Address) {\\n ERC20Address = _ERC20Address;\\n ERC20SimpleSwap _master = new ERC20SimpleSwap();\\n // set the issuer of the master contract to prevent misuse\\n _master.init(address(1), address(0), 0);\\n master = address(_master);\\n }\\n /**\\n @notice creates a clone of the master SimpleSwap contract\\n @param issuer the issuer of cheques for the new chequebook\\n @param defaultHardDepositTimeoutDuration duration in seconds which by default will be used to reduce hardDeposit allocations\\n @param salt salt to include in create2 to enable the same address to deploy multiple chequebooks\\n */\\n function deploySimpleSwap(address issuer, uint defaultHardDepositTimeoutDuration, bytes32 salt)\\n public returns (address) { \\n address contractAddress = Clones.cloneDeterministic(master, keccak256(abi.encode(msg.sender, salt)));\\n ERC20SimpleSwap(contractAddress).init(issuer, ERC20Address, defaultHardDepositTimeoutDuration);\\n deployedContracts[contractAddress] = true;\\n emit SimpleSwapDeployed(contractAddress);\\n return contractAddress;\\n }\\n}\",\"keccak256\":\"0x9c53f43c46e681f3adfd000d7c82b711edc558149a7d711a7d735d23ceaf8d7c\",\"license\":\"BSD-3-Clause\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50604051611df2380380611df283398101604081905261002f91610112565b600180546001600160a01b0319166001600160a01b03831617905560405160009061005990610105565b604051809103906000f080158015610075573d6000803e3d6000fd5b506040516343431f6360e11b81529091506001600160a01b038216906386863ec6906100ab906001906000908190600401610140565b600060405180830381600087803b1580156100c557600080fd5b505af11580156100d9573d6000803e3d6000fd5b5050600280546001600160a01b0319166001600160a01b03949094169390931790925550610164915050565b6118e58061050d83390190565b600060208284031215610123578081fd5b81516001600160a01b0381168114610139578182fd5b9392505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b61039a806101736000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806315efd8a714610051578063a6021ace1461007a578063c70242ad14610082578063ee97f7f3146100a2575b600080fd5b61006461005f3660046102d6565b6100aa565b6040516100719190610308565b60405180910390f35b6100646101bb565b6100956100903660046102b5565b6101ca565b6040516100719190610359565b6100646101df565b60025460405160009182916100ee916001600160a01b0316906100d3903390879060200161031c565b604051602081830303815290604052805190602001206101ee565b6001546040516343431f6360e11b81529192506001600160a01b03808416926386863ec692610126928a929116908990600401610335565b600060405180830381600087803b15801561014057600080fd5b505af1158015610154573d6000803e3d6000fd5b5050506001600160a01b03821660009081526020819052604090819020805460ff19166001179055517fc0ffc525a1c7689549d7f79b49eca900e61ac49b43d977f680bcc3b36224c00491506101ab908390610308565b60405180910390a1949350505050565b6001546001600160a01b031681565b60006020819052908152604090205460ff1681565b6002546001600160a01b031681565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528360601b60148201526e5af43d82803e903d91602b57fd5bf360881b6028820152826037826000f59150506001600160a01b038116610293576040805162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c6564000000000000000000604482015290519081900360640190fd5b92915050565b80356001600160a01b03811681146102b057600080fd5b919050565b6000602082840312156102c6578081fd5b6102cf82610299565b9392505050565b6000806000606084860312156102ea578182fd5b6102f384610299565b95602085013595506040909401359392505050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b90151581526020019056fea2646970667358221220b260612b64b2388a58a0d557b99cc9121129d7c5aaa1c649d70eac8f0870b29c64736f6c63430007060033608060405234801561001057600080fd5b506118c5806100206000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c8063946f46a2116100c3578063b7ec1a331161007c578063b7ec1a331461027f578063c49f91d314610287578063c76a4d311461028f578063d4c9a8e8146102a2578063e0bcf13a146102b5578063fc0c546a146102bd5761014d565b8063946f46a214610211578063b6343b0d14610224578063b648b41714610247578063b69ef8a81461025c578063b777035014610264578063b7998907146102775761014d565b80631d143848116101155780631d143848146101a85780632e1a7d4d146101bd578063338f3fed146101d0578063488b017c146101e357806381f03fcb146101eb57806386863ec6146101fe5761014d565b80630d5f26591461015257806312101021146101675780631357e1dc1461018557806315c3343f1461018d5780631633fb1d14610195575b600080fd5b61016561016036600461146b565b6102c5565b005b61016f6102d8565b60405161017c9190611563565b60405180910390f35b61016f6102de565b61016f6102e4565b6101656101a33660046113ae565b610308565b6101b061036c565b60405161017c919061152b565b6101656101cb3660046114e0565b61037b565b6101656101de366004611442565b610473565b61016f610556565b61016f6101f9366004611359565b61057a565b61016561020c366004611373565b61058c565b61016561021f366004611359565b610610565b610237610232366004611359565b6106d0565b60405161017c94939291906115c7565b61024f6106f7565b60405161017c9190611558565b61016f610707565b610165610272366004611442565b61078d565b61016f610867565b61016f61088b565b61016f6108a1565b61016f61029d366004611359565b6108c5565b6101656102b036600461146b565b6108f8565b61016f6109b4565b6101b06109ba565b6102d33384846000856109c9565b505050565b60005481565b60035481565b7f48ebe6deff4a5ee645c01506a026031e2a945d6f41f1f4e5098ad65347492c1281565b61031e6103183033878987610dd2565b84610e30565b6001600160a01b0316866001600160a01b0316146103575760405162461bcd60e51b815260040161034e906117d5565b60405180910390fd5b61036486868685856109c9565b505050505050565b6006546001600160a01b031681565b6006546001600160a01b031633146103a55760405162461bcd60e51b815260040161034e906115e2565b6103ad61088b565b8111156103cc5760405162461bcd60e51b815260040161034e90611695565b60015460065460405163a9059cbb60e01b81526001600160a01b039283169263a9059cbb9261040292911690859060040161153f565b602060405180830381600087803b15801561041c57600080fd5b505af1158015610430573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045491906114c0565b6104705760405162461bcd60e51b815260040161034e9061180c565b50565b6006546001600160a01b0316331461049d5760405162461bcd60e51b815260040161034e90611665565b6104a5610707565b6005546104b29083610e7f565b11156104d05760405162461bcd60e51b815260040161034e90611730565b6001600160a01b038216600090815260046020526040902080546104f49083610e7f565b81556005546105039083610e7f565b6005556000600382015580546040516001600160a01b038516917f2506c43272ded05d095b91dbba876e66e46888157d3e078db5691496e96c5fad916105499190611563565b60405180910390a2505050565b7f7d824962dd0f01520922ea1766c987b1db570cd5db90bdba5ccf5e320607950281565b60026020526000908152604090205481565b6001600160a01b0383166105b25760405162461bcd60e51b815260040161034e9061163d565b6006546001600160a01b0316156105db5760405162461bcd60e51b815260040161034e906116cc565b600680546001600160a01b039485166001600160a01b0319918216179091556001805493909416921691909117909155600055565b6001600160a01b03811660009081526004602052604090206003810154421080159061063f5750600381015415155b61065b5760405162461bcd60e51b815260040161034e90611606565b6001810154815461066b91610ee0565b815560006003820155600181015460055461068591610ee0565b60055580546040516001600160a01b038416917f2506c43272ded05d095b91dbba876e66e46888157d3e078db5691496e96c5fad916106c49190611563565b60405180910390a25050565b60046020526000908152604090208054600182015460028301546003909301549192909184565b600654600160a01b900460ff1681565b6001546040516370a0823160e01b81526000916001600160a01b0316906370a082319061073890309060040161152b565b60206040518083038186803b15801561075057600080fd5b505afa158015610764573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078891906114f8565b905090565b6006546001600160a01b031633146107b75760405162461bcd60e51b815260040161034e90611665565b6001600160a01b038216600090815260046020526040902080548211156107f05760405162461bcd60e51b815260040161034e906116f9565b6000816002015460001461080857816002015461080c565b6000545b4281016003840155600183018490556040519091506001600160a01b038516907fc8305077b495025ec4c1d977b176a762c350bb18cad4666ce1ee85c32b78698a90610859908690611563565b60405180910390a250505050565b7fe95f353750f192082df064ca5142d3a2d6f0bef0f3ffad66d80d8af86b7a749a81565b600061078860055461089b610707565b90610ee0565b7fc2f8787176b8ac6bf7215b4adcc1e069bf4ab82d9ab1df05a57a91d425935b6e81565b6001600160a01b0381166000908152600460205260408120546108f0906108ea61088b565b90610e7f565b90505b919050565b6006546001600160a01b031633146109225760405162461bcd60e51b815260040161034e906115e2565b610936610930308585610f3d565b82610e30565b6001600160a01b0316836001600160a01b0316146109665760405162461bcd60e51b815260040161034e906117d5565b6001600160a01b03831660008181526004602052604090819020600201849055517f7b816003a769eb718bd9c66bdbd2dd5827da3f92bc6645276876bd7957b08cf090610549908590611563565b60055481565b6001546001600160a01b031681565b6006546001600160a01b03163314610a16576109e9610930308786610f95565b6006546001600160a01b03908116911614610a165760405162461bcd60e51b815260040161034e9061179e565b6001600160a01b038516600090815260026020526040812054610a3a908590610ee0565b90506000610a5082610a4b896108c5565b610fce565b6001600160a01b03881660009081526004602052604081205491925090610a78908390610fce565b905084821015610a9a5760405162461bcd60e51b815260040161034e90611767565b8015610aed576001600160a01b038816600090815260046020526040902054610ac39082610ee0565b6001600160a01b038916600090815260046020526040902055600554610ae99082610ee0565b6005555b6001600160a01b038816600090815260026020526040902054610b109083610e7f565b6001600160a01b038916600090815260026020526040902055600354610b369083610e7f565b600355828214610b7d576006805460ff60a01b1916600160a01b1790556040517f3f4449c047e11092ec54dc0751b6b4817a9162745de856c893a26e611d18ffc490600090a15b8415610ccf5760015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610bb5903390899060040161153f565b602060405180830381600087803b158015610bcf57600080fd5b505af1158015610be3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0791906114c0565b610c235760405162461bcd60e51b815260040161034e9061180c565b6001546001600160a01b031663a9059cbb88610c3f8589610ee0565b6040518363ffffffff1660e01b8152600401610c5c92919061153f565b602060405180830381600087803b158015610c7657600080fd5b505af1158015610c8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cae91906114c0565b610cca5760405162461bcd60e51b815260040161034e9061180c565b610d6f565b60015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610d01908a90869060040161153f565b602060405180830381600087803b158015610d1b57600080fd5b505af1158015610d2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5391906114c0565b610d6f5760405162461bcd60e51b815260040161034e9061180c565b336001600160a01b0316876001600160a01b0316896001600160a01b03167f950494fc3642fae5221b6c32e0e45765c95ebb382a04a71b160db0843e74c99f858a8a604051610dc093929190611835565b60405180910390a45050505050505050565b60007f7d824962dd0f01520922ea1766c987b1db570cd5db90bdba5ccf5e32060795028686868686604051602001610e0f96959493929190611591565b60405160208183030381529060405280519060200120905095945050505050565b600080610e43610e3e610fe4565b61103e565b84604051602001610e55929190611510565b604051602081830303815290604052805190602001209050610e7781846110ae565b949350505050565b600082820183811015610ed9576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600082821115610f37576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60007fe95f353750f192082df064ca5142d3a2d6f0bef0f3ffad66d80d8af86b7a749a848484604051602001610f76949392919061156c565b6040516020818303038152906040528051906020012090509392505050565b60007f48ebe6deff4a5ee645c01506a026031e2a945d6f41f1f4e5098ad65347492c12848484604051602001610f76949392919061156c565b6000818310610fdd5781610ed9565b5090919050565b610fec6112ac565b506040805160a081018252600a6060820190815269436865717565626f6f6b60b01b608083015281528151808301835260038152620312e360ec1b602082810191909152820152469181019190915290565b60007fc2f8787176b8ac6bf7215b4adcc1e069bf4ab82d9ab1df05a57a91d425935b6e826000015180519060200120836020015180519060200120846040015160405160200161109194939291906115c7565b604051602081830303815290604052805190602001209050919050565b60008151604114611106576040805162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015290519081900360640190fd5b60208201516040830151606084015160001a6111248682858561112e565b9695505050505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a082111561118f5760405162461bcd60e51b815260040180806020018281038252602281526020018061184c6022913960400191505060405180910390fd5b8360ff16601b14806111a457508360ff16601c145b6111df5760405162461bcd60e51b815260040180806020018281038252602281526020018061186e6022913960400191505060405180910390fd5b600060018686868660405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561123b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166112a3576040805162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015290519081900360640190fd5b95945050505050565b60405180606001604052806060815260200160608152602001600081525090565b80356001600160a01b03811681146108f357600080fd5b600082601f8301126112f4578081fd5b813567ffffffffffffffff8082111561130957fe5b604051601f8301601f19168101602001828111828210171561132757fe5b60405282815284830160200186101561133e578384fd5b82602086016020830137918201602001929092529392505050565b60006020828403121561136a578081fd5b610ed9826112cd565b600080600060608486031215611387578182fd5b611390846112cd565b925061139e602085016112cd565b9150604084013590509250925092565b60008060008060008060c087890312156113c6578182fd5b6113cf876112cd565b95506113dd602088016112cd565b945060408701359350606087013567ffffffffffffffff80821115611400578384fd5b61140c8a838b016112e4565b94506080890135935060a0890135915080821115611428578283fd5b5061143589828a016112e4565b9150509295509295509295565b60008060408385031215611454578182fd5b61145d836112cd565b946020939093013593505050565b60008060006060848603121561147f578283fd5b611488846112cd565b925060208401359150604084013567ffffffffffffffff8111156114aa578182fd5b6114b6868287016112e4565b9150509250925092565b6000602082840312156114d1578081fd5b81518015158114610ed9578182fd5b6000602082840312156114f1578081fd5b5035919050565b600060208284031215611509578081fd5b5051919050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b90815260200190565b9384526001600160a01b03928316602085015291166040830152606082015260800190565b9586526001600160a01b03948516602087015292841660408601526060850191909152909116608083015260a082015260c00190565b93845260208401929092526040830152606082015260800190565b6020808252600a90820152693737ba1034b9b9bab2b960b11b604082015260600190565b60208082526019908201527f6465706f736974206e6f74207965742074696d6564206f757400000000000000604082015260600190565b6020808252600e908201526d34b73b30b634b21034b9b9bab2b960911b604082015260600190565b60208082526016908201527529b4b6b83632a9bbb0b81d103737ba1034b9b9bab2b960511b604082015260600190565b6020808252601c908201527f6c697175696442616c616e6365206e6f742073756666696369656e7400000000604082015260600190565b602080825260139082015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604082015260600190565b6020808252601b908201527f68617264206465706f736974206e6f742073756666696369656e740000000000604082015260600190565b6020808252601c908201527f68617264206465706f73697420657863656564732062616c616e636500000000604082015260600190565b6020808252601d908201527f53696d706c65537761703a2063616e6e6f74207061792063616c6c6572000000604082015260600190565b60208082526018908201527f696e76616c696420697373756572207369676e61747572650000000000000000604082015260600190565b6020808252601d908201527f696e76616c69642062656e6566696369617279207369676e6174757265000000604082015260600190565b6020808252600f908201526e1d1c985b9cd9995c8819985a5b1959608a1b604082015260600190565b928352602083019190915260408201526060019056fe45434453413a20696e76616c6964207369676e6174757265202773272076616c756545434453413a20696e76616c6964207369676e6174757265202776272076616c7565a2646970667358221220b270820590249f6db00f7142812273c92ea84cea0862f4083a5c75edd08f437264736f6c63430007060033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806315efd8a714610051578063a6021ace1461007a578063c70242ad14610082578063ee97f7f3146100a2575b600080fd5b61006461005f3660046102d6565b6100aa565b6040516100719190610308565b60405180910390f35b6100646101bb565b6100956100903660046102b5565b6101ca565b6040516100719190610359565b6100646101df565b60025460405160009182916100ee916001600160a01b0316906100d3903390879060200161031c565b604051602081830303815290604052805190602001206101ee565b6001546040516343431f6360e11b81529192506001600160a01b03808416926386863ec692610126928a929116908990600401610335565b600060405180830381600087803b15801561014057600080fd5b505af1158015610154573d6000803e3d6000fd5b5050506001600160a01b03821660009081526020819052604090819020805460ff19166001179055517fc0ffc525a1c7689549d7f79b49eca900e61ac49b43d977f680bcc3b36224c00491506101ab908390610308565b60405180910390a1949350505050565b6001546001600160a01b031681565b60006020819052908152604090205460ff1681565b6002546001600160a01b031681565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528360601b60148201526e5af43d82803e903d91602b57fd5bf360881b6028820152826037826000f59150506001600160a01b038116610293576040805162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c6564000000000000000000604482015290519081900360640190fd5b92915050565b80356001600160a01b03811681146102b057600080fd5b919050565b6000602082840312156102c6578081fd5b6102cf82610299565b9392505050565b6000806000606084860312156102ea578182fd5b6102f384610299565b95602085013595506040909401359392505050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b90151581526020019056fea2646970667358221220b260612b64b2388a58a0d557b99cc9121129d7c5aaa1c649d70eac8f0870b29c64736f6c63430007060033", "devdoc": { "author": "The Swarm Authors", "kind": "dev", @@ -152,7 +152,7 @@ "storageLayout": { "storage": [ { - "astId": 3775, + "astId": 3488, "contract": "contracts/SimpleSwapFactory.sol:SimpleSwapFactory", "label": "deployedContracts", "offset": 0, @@ -160,7 +160,7 @@ "type": "t_mapping(t_address,t_bool)" }, { - "astId": 3777, + "astId": 3490, "contract": "contracts/SimpleSwapFactory.sol:SimpleSwapFactory", "label": "ERC20Address", "offset": 0, @@ -168,7 +168,7 @@ "type": "t_address" }, { - "astId": 3779, + "astId": 3492, "contract": "contracts/SimpleSwapFactory.sol:SimpleSwapFactory", "label": "master", "offset": 0, diff --git a/deployments/testnet/solcInputs/126591187300f42d56a4b4d666be9f01.json b/deployments/testnet/solcInputs/126591187300f42d56a4b4d666be9f01.json new file mode 100644 index 0000000..a14ae32 --- /dev/null +++ b/deployments/testnet/solcInputs/126591187300f42d56a4b4d666be9f01.json @@ -0,0 +1,83 @@ +{ + "language": "Solidity", + "sources": { + "contracts/ERC20SimpleSwap.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity =0.7.6;\npragma abicoder v2;\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/math/Math.sol\";\nimport \"@openzeppelin/contracts/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol\";\n\n\n/**\n@title Chequebook contract without waivers\n@author The Swarm Authors\n@notice The chequebook contract allows the issuer of the chequebook to send cheques to an unlimited amount of counterparties.\nFurthermore, solvency can be guaranteed via hardDeposits\n@dev as an issuer, no cheques should be send if the cumulative worth of a cheques send is above the cumulative worth of all deposits\nas a beneficiary, we should always take into account the possibility that a cheque bounces (when no hardDeposits are assigned)\n*/\ncontract ERC20SimpleSwap {\n using SafeMath for uint;\n\n event ChequeCashed(\n address indexed beneficiary,\n address indexed recipient,\n address indexed caller,\n uint totalPayout,\n uint cumulativePayout,\n uint callerPayout\n );\n event ChequeBounced();\n event HardDepositAmountChanged(address indexed beneficiary, uint amount);\n event HardDepositDecreasePrepared(address indexed beneficiary, uint decreaseAmount);\n event HardDepositTimeoutChanged(address indexed beneficiary, uint timeout);\n event Withdraw(uint amount);\n\n uint public defaultHardDepositTimeout;\n /* structure to keep track of the hard deposits (on-chain guarantee of solvency) per beneficiary*/\n struct HardDeposit {\n uint amount; /* hard deposit amount allocated */\n uint decreaseAmount; /* decreaseAmount substranced from amount when decrease is requested */\n uint timeout; /* issuer has to wait timeout seconds to decrease hardDeposit, 0 implies applying defaultHardDepositTimeout */\n uint canBeDecreasedAt; /* point in time after which harddeposit can be decreased*/\n }\n\n struct EIP712Domain {\n string name;\n string version;\n uint256 chainId;\n }\n\n bytes32 public constant EIP712DOMAIN_TYPEHASH = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId)\"\n );\n bytes32 public constant CHEQUE_TYPEHASH = keccak256(\n \"Cheque(address chequebook,address beneficiary,uint256 cumulativePayout)\"\n );\n bytes32 public constant CASHOUT_TYPEHASH = keccak256(\n \"Cashout(address chequebook,address sender,uint256 requestPayout,address recipient,uint256 callerPayout)\"\n );\n bytes32 public constant CUSTOMDECREASETIMEOUT_TYPEHASH = keccak256(\n \"CustomDecreaseTimeout(address chequebook,address beneficiary,uint256 decreaseTimeout)\"\n );\n\n // the EIP712 domain this contract uses\n function domain() internal pure returns (EIP712Domain memory) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return EIP712Domain({\n name: \"Chequebook\",\n version: \"1.0\",\n chainId: chainId\n });\n }\n\n // compute the EIP712 domain separator. this cannot be constant because it depends on chainId\n function domainSeparator(EIP712Domain memory eip712Domain) internal pure returns (bytes32) {\n return keccak256(abi.encode(\n EIP712DOMAIN_TYPEHASH,\n keccak256(bytes(eip712Domain.name)),\n keccak256(bytes(eip712Domain.version)),\n eip712Domain.chainId\n ));\n }\n\n // recover a signature with the EIP712 signing scheme\n function recoverEIP712(bytes32 hash, bytes memory sig) internal pure returns (address) {\n bytes32 digest = keccak256(abi.encodePacked(\n \"\\x19\\x01\",\n domainSeparator(domain()),\n hash\n ));\n return ECDSA.recover(digest, sig);\n }\n\n /* The token against which this chequebook writes cheques */\n ERC20 public token;\n /* associates every beneficiary with how much has been paid out to them */\n mapping (address => uint) public paidOut;\n /* total amount paid out */\n uint public totalPaidOut;\n /* associates every beneficiary with their HardDeposit */\n mapping (address => HardDeposit) public hardDeposits;\n /* sum of all hard deposits */\n uint public totalHardDeposit;\n /* issuer of the contract, set at construction */\n address public issuer;\n /* indicates wether a cheque bounced in the past */\n bool public bounced;\n\n /**\n @notice sets the issuer, token and the defaultHardDepositTimeout. can only be called once.\n @param _issuer the issuer of cheques from this chequebook (needed as an argument for \"Setting up a chequebook as a payment\").\n _issuer must be an Externally Owned Account, or it must support calling the function cashCheque\n @param _token the token this chequebook uses\n @param _defaultHardDepositTimeout duration in seconds which by default will be used to reduce hardDeposit allocations\n */\n function init(address _issuer, address _token, uint _defaultHardDepositTimeout) public {\n require(_issuer != address(0), \"invalid issuer\");\n require(issuer == address(0), \"already initialized\");\n issuer = _issuer;\n token = ERC20(_token);\n defaultHardDepositTimeout = _defaultHardDepositTimeout;\n }\n\n /// @return the balance of the chequebook\n function balance() public view returns(uint) {\n return token.balanceOf(address(this));\n }\n /// @return the part of the balance that is not covered by hard deposits\n function liquidBalance() public view returns(uint) {\n return balance().sub(totalHardDeposit);\n }\n\n /// @return the part of the balance available for a specific beneficiary\n function liquidBalanceFor(address beneficiary) public view returns(uint) {\n return liquidBalance().add(hardDeposits[beneficiary].amount);\n }\n /**\n @dev internal function responsible for checking the issuerSignature, updating hardDeposit balances and doing transfers.\n Called by cashCheque and cashChequeBeneficary\n @param beneficiary the beneficiary to which cheques were assigned. Beneficiary must be an Externally Owned Account\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\n @param cumulativePayout cumulative amount of cheques assigned to beneficiary\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\n */\n function _cashChequeInternal(\n address beneficiary,\n address recipient,\n uint cumulativePayout,\n uint callerPayout,\n bytes memory issuerSig\n ) internal {\n /* The issuer must have given explicit approval to the cumulativePayout, either by being the caller or by signature*/\n if (msg.sender != issuer) {\n require(issuer == recoverEIP712(chequeHash(address(this), beneficiary, cumulativePayout), issuerSig),\n \"invalid issuer signature\");\n }\n /* the requestPayout is the amount requested for payment processing */\n uint requestPayout = cumulativePayout.sub(paidOut[beneficiary]);\n /* calculates acutal payout */\n uint totalPayout = Math.min(requestPayout, liquidBalanceFor(beneficiary));\n /* calculates hard-deposit usage */\n uint hardDepositUsage = Math.min(totalPayout, hardDeposits[beneficiary].amount);\n require(totalPayout >= callerPayout, \"SimpleSwap: cannot pay caller\");\n /* if there are some of the hard deposit used, update hardDeposits*/\n if (hardDepositUsage != 0) {\n hardDeposits[beneficiary].amount = hardDeposits[beneficiary].amount.sub(hardDepositUsage);\n\n totalHardDeposit = totalHardDeposit.sub(hardDepositUsage);\n }\n /* increase the stored paidOut amount to avoid double payout */\n paidOut[beneficiary] = paidOut[beneficiary].add(totalPayout);\n totalPaidOut = totalPaidOut.add(totalPayout);\n\n /* let the world know that the issuer has over-promised on outstanding cheques */\n if (requestPayout != totalPayout) {\n bounced = true;\n emit ChequeBounced();\n }\n\n if (callerPayout != 0) {\n /* do a transfer to the caller if specified*/\n require(token.transfer(msg.sender, callerPayout), \"transfer failed\");\n /* do the actual payment */\n require(token.transfer(recipient, totalPayout.sub(callerPayout)), \"transfer failed\");\n } else {\n /* do the actual payment */\n require(token.transfer(recipient, totalPayout), \"transfer failed\");\n }\n\n emit ChequeCashed(beneficiary, recipient, msg.sender, totalPayout, cumulativePayout, callerPayout);\n }\n /**\n @notice cash a cheque of the beneficiary by a non-beneficiary and reward the sender for doing so with callerPayout\n @dev a beneficiary must be able to generate signatures (be an Externally Owned Account) to make use of this feature\n @param beneficiary the beneficiary to which cheques were assigned. Beneficiary must be an Externally Owned Account\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\n @param cumulativePayout cumulative amount of cheques assigned to beneficiary\n @param beneficiarySig beneficiary must have given explicit approval for cashing out the cumulativePayout by the sender and sending the callerPayout\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\n @param callerPayout when beneficiary does not have ether yet, he can incentivize other people to cash cheques with help of callerPayout\n @param issuerSig if issuer is not the sender, issuer must have given explicit approval on the cumulativePayout to the beneficiary\n */\n function cashCheque(\n address beneficiary,\n address recipient,\n uint cumulativePayout,\n bytes memory beneficiarySig,\n uint256 callerPayout,\n bytes memory issuerSig\n ) public {\n require(\n beneficiary == recoverEIP712(\n cashOutHash(\n address(this),\n msg.sender,\n cumulativePayout,\n recipient,\n callerPayout\n ), beneficiarySig\n ), \"invalid beneficiary signature\");\n _cashChequeInternal(beneficiary, recipient, cumulativePayout, callerPayout, issuerSig);\n }\n\n /**\n @notice cash a cheque as beneficiary\n @param recipient receives the differences between cumulativePayment and what was already paid-out to the beneficiary minus callerPayout\n @param cumulativePayout amount requested to pay out\n @param issuerSig issuer must have given explicit approval on the cumulativePayout to the beneficiary\n */\n function cashChequeBeneficiary(address recipient, uint cumulativePayout, bytes memory issuerSig) public {\n _cashChequeInternal(msg.sender, recipient, cumulativePayout, 0, issuerSig);\n }\n\n /**\n @notice prepare to decrease the hard deposit\n @dev decreasing hardDeposits must be done in two steps to allow beneficiaries to cash any uncashed cheques (and make use of the assgined hard-deposits)\n @param beneficiary beneficiary whose hard deposit should be decreased\n @param decreaseAmount amount that the deposit is supposed to be decreased by\n */\n function prepareDecreaseHardDeposit(address beneficiary, uint decreaseAmount) public {\n require(msg.sender == issuer, \"SimpleSwap: not issuer\");\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\n /* cannot decrease it by more than the deposit */\n require(decreaseAmount <= hardDeposit.amount, \"hard deposit not sufficient\");\n // if hardDeposit.timeout was never set, apply defaultHardDepositTimeout\n uint timeout = hardDeposit.timeout == 0 ? defaultHardDepositTimeout : hardDeposit.timeout;\n hardDeposit.canBeDecreasedAt = block.timestamp + timeout;\n hardDeposit.decreaseAmount = decreaseAmount;\n emit HardDepositDecreasePrepared(beneficiary, decreaseAmount);\n }\n\n /**\n @notice decrease the hard deposit after waiting the necesary amount of time since prepareDecreaseHardDeposit was called\n @param beneficiary beneficiary whose hard deposit should be decreased\n */\n function decreaseHardDeposit(address beneficiary) public {\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\n require(block.timestamp >= hardDeposit.canBeDecreasedAt && hardDeposit.canBeDecreasedAt != 0, \"deposit not yet timed out\");\n /* this throws if decreaseAmount > amount */\n //TODO: if there is a cash-out in between prepareDecreaseHardDeposit and decreaseHardDeposit, decreaseHardDeposit will throw and reducing hard-deposits is impossible.\n hardDeposit.amount = hardDeposit.amount.sub(hardDeposit.decreaseAmount);\n /* reset the canBeDecreasedAt to avoid a double decrease */\n hardDeposit.canBeDecreasedAt = 0;\n /* keep totalDeposit in sync */\n totalHardDeposit = totalHardDeposit.sub(hardDeposit.decreaseAmount);\n emit HardDepositAmountChanged(beneficiary, hardDeposit.amount);\n }\n\n /**\n @notice increase the hard deposit\n @param beneficiary beneficiary whose hard deposit should be decreased\n @param amount the new hard deposit\n */\n function increaseHardDeposit(address beneficiary, uint amount) public {\n require(msg.sender == issuer, \"SimpleSwap: not issuer\");\n /* ensure hard deposits don't exceed the global balance */\n require(totalHardDeposit.add(amount) <= balance(), \"hard deposit exceeds balance\");\n\n HardDeposit storage hardDeposit = hardDeposits[beneficiary];\n hardDeposit.amount = hardDeposit.amount.add(amount);\n // we don't explicitely set hardDepositTimout, as zero means using defaultHardDepositTimeout\n totalHardDeposit = totalHardDeposit.add(amount);\n /* disable any pending decrease */\n hardDeposit.canBeDecreasedAt = 0;\n emit HardDepositAmountChanged(beneficiary, hardDeposit.amount);\n }\n\n /**\n @notice allows for setting a custom hardDepositDecreaseTimeout per beneficiary\n @dev this is required when solvency must be guaranteed for a period longer than the defaultHardDepositDecreaseTimeout\n @param beneficiary beneficiary whose hard deposit decreaseTimeout must be changed\n @param hardDepositTimeout new hardDeposit.timeout for beneficiary\n @param beneficiarySig beneficiary must give explicit approval by giving his signature on the new decreaseTimeout\n */\n function setCustomHardDepositTimeout(\n address beneficiary,\n uint hardDepositTimeout,\n bytes memory beneficiarySig\n ) public {\n require(msg.sender == issuer, \"not issuer\");\n require(\n beneficiary == recoverEIP712(customDecreaseTimeoutHash(address(this), beneficiary, hardDepositTimeout), beneficiarySig),\n \"invalid beneficiary signature\"\n );\n hardDeposits[beneficiary].timeout = hardDepositTimeout;\n emit HardDepositTimeoutChanged(beneficiary, hardDepositTimeout);\n }\n\n /// @notice withdraw ether\n /// @param amount amount to withdraw\n // solhint-disable-next-line no-simple-event-func-name\n function withdraw(uint amount) public {\n /* only issuer can do this */\n require(msg.sender == issuer, \"not issuer\");\n /* ensure we don't take anything from the hard deposit */\n require(amount <= liquidBalance(), \"liquidBalance not sufficient\");\n require(token.transfer(issuer, amount), \"transfer failed\");\n }\n\n function chequeHash(address chequebook, address beneficiary, uint cumulativePayout)\n internal pure returns (bytes32) {\n return keccak256(abi.encode(\n CHEQUE_TYPEHASH,\n chequebook,\n beneficiary,\n cumulativePayout\n ));\n } \n\n function cashOutHash(address chequebook, address sender, uint requestPayout, address recipient, uint callerPayout)\n internal pure returns (bytes32) {\n return keccak256(abi.encode(\n CASHOUT_TYPEHASH,\n chequebook,\n sender,\n requestPayout,\n recipient,\n callerPayout\n ));\n }\n\n function customDecreaseTimeoutHash(address chequebook, address beneficiary, uint decreaseTimeout)\n internal pure returns (bytes32) {\n return keccak256(abi.encode(\n CUSTOMDECREASETIMEOUT_TYPEHASH,\n chequebook,\n beneficiary,\n decreaseTimeout\n ));\n }\n}" + }, + "@openzeppelin/contracts/math/SafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * 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 */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a % b;\n }\n}\n" + }, + "@openzeppelin/contracts/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\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, so we distribute\n return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);\n }\n}\n" + }, + "@openzeppelin/contracts/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\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 /**\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 // Check the signature length\n if (signature.length != 65) {\n revert(\"ECDSA: invalid signature length\");\n }\n\n // Divide the signature in r, s and v variables\n bytes32 r;\n bytes32 s;\n uint8 v;\n\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n // solhint-disable-next-line no-inline-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\n return recover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\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 (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {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 require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, \"ECDSA: invalid signature 's' value\");\n require(v == 27 || v == 28, \"ECDSA: invalid signature 'v' value\");\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n require(signer != address(0), \"ECDSA: invalid signature\");\n\n return signer;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * replicates the behavior of the\n * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]\n * JSON-RPC method.\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" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../utils/Context.sol\";\nimport \"./IERC20.sol\";\nimport \"../../math/SafeMath.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20 {\n using SafeMath for uint256;\n\n mapping (address => uint256) private _balances;\n\n mapping (address => mapping (address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n\n /**\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\n * a default value of 18.\n *\n * To select a different value for {decimals}, use {_setupDecimals}.\n *\n * All three of these values are immutable: they can only be set once during\n * construction.\n */\n constructor (string memory name_, string memory symbol_) public {\n _name = name_;\n _symbol = symbol_;\n _decimals = 18;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\n * called.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return _decimals;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \"ERC20: transfer amount exceeds allowance\"));\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \"ERC20: decreased allowance below zero\"));\n return true;\n }\n\n /**\n * @dev Moves tokens `amount` from `sender` to `recipient`.\n *\n * This is internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n _balances[sender] = _balances[sender].sub(amount, \"ERC20: transfer amount exceeds balance\");\n _balances[recipient] = _balances[recipient].add(amount);\n emit Transfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply = _totalSupply.add(amount);\n _balances[account] = _balances[account].add(amount);\n emit Transfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n _balances[account] = _balances[account].sub(amount, \"ERC20: burn amount exceeds balance\");\n _totalSupply = _totalSupply.sub(amount);\n emit Transfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Sets {decimals} to a value other than the default one of 18.\n *\n * WARNING: This function should only be called from the constructor. Most\n * applications that interact with token contracts will not expect\n * {decimals} to ever change, and may work incorrectly if it does.\n */\n function _setupDecimals(uint8 decimals_) internal virtual {\n _decimals = decimals_;\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 *\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 *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\n}\n" + }, + "@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../access/AccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../token/ERC20/ERC20.sol\";\nimport \"../token/ERC20/ERC20Burnable.sol\";\nimport \"../token/ERC20/ERC20Pausable.sol\";\n\n/**\n * @dev {ERC20} token, including:\n *\n * - ability for holders to burn (destroy) their tokens\n * - a minter role that allows for token minting (creation)\n * - a pauser role that allows to stop all token transfers\n *\n * This contract uses {AccessControl} to lock permissioned functions using the\n * different roles - head to its documentation for details.\n *\n * The account that deploys the contract will be granted the minter and pauser\n * roles, as well as the default admin role, which will let it grant both minter\n * and pauser roles to other accounts.\n */\ncontract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20Pausable {\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n /**\n * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the\n * account that deploys the contract.\n *\n * See {ERC20-constructor}.\n */\n constructor(string memory name, string memory symbol) public ERC20(name, symbol) {\n _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());\n\n _setupRole(MINTER_ROLE, _msgSender());\n _setupRole(PAUSER_ROLE, _msgSender());\n }\n\n /**\n * @dev Creates `amount` new tokens for `to`.\n *\n * See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the `MINTER_ROLE`.\n */\n function mint(address to, uint256 amount) public virtual {\n require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have minter role to mint\");\n _mint(to, amount);\n }\n\n /**\n * @dev Pauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_pause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function pause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to pause\");\n _pause();\n }\n\n /**\n * @dev Unpauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_unpause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function unpause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to unpause\");\n _unpause();\n }\n\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <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 GSN 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 payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <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 `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, 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 `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address sender, address recipient, uint256 amount) 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" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../utils/EnumerableSet.sol\";\nimport \"../utils/Address.sol\";\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context {\n using EnumerableSet for EnumerableSet.AddressSet;\n using Address for address;\n\n struct RoleData {\n EnumerableSet.AddressSet members;\n bytes32 adminRole;\n }\n\n mapping (bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view returns (bool) {\n return _roles[role].members.contains(account);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n return _roles[role].members.length();\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n return _roles[role].members.at(index);\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n _roles[role].adminRole = adminRole;\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (_roles[role].members.add(account)) {\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (_roles[role].members.remove(account)) {\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../utils/Context.sol\";\nimport \"./ERC20.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20Burnable is Context, ERC20 {\n using SafeMath for uint256;\n\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, \"ERC20: burn amount exceeds allowance\");\n\n _approve(account, _msgSender(), decreasedAllowance);\n _burn(account, amount);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./ERC20.sol\";\nimport \"../../utils/Pausable.sol\";\n\n/**\n * @dev ERC20 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n */\nabstract contract ERC20Pausable is ERC20, Pausable {\n /**\n * @dev See {ERC20-_beforeTokenTransfer}.\n *\n * Requirements:\n *\n * - the contract must not be paused.\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" + }, + "@openzeppelin/contracts/utils/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length > index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\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 function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size > 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 // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) 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 // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 // solhint-disable-next-line no-inline-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}\n" + }, + "@openzeppelin/contracts/utils/Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor () internal {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" + }, + "contracts/SimpleSwapFactory.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity =0.7.6;\npragma abicoder v2;\nimport \"./ERC20SimpleSwap.sol\";\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\n\n/**\n@title Factory contract for SimpleSwap\n@author The Swarm Authors\n@notice This contract deploys SimpleSwap contracts\n*/\ncontract SimpleSwapFactory {\n\n /* event fired on every new SimpleSwap deployment */\n event SimpleSwapDeployed(address contractAddress);\n\n /* mapping to keep track of which contracts were deployed by this factory */\n mapping (address => bool) public deployedContracts;\n\n /* address of the ERC20-token, to be used by the to-be-deployed chequebooks */\n address public ERC20Address;\n /* address of the code contract from which all chequebooks are cloned */\n address public master;\n\n constructor(address _ERC20Address) {\n ERC20Address = _ERC20Address;\n ERC20SimpleSwap _master = new ERC20SimpleSwap();\n // set the issuer of the master contract to prevent misuse\n _master.init(address(1), address(0), 0);\n master = address(_master);\n }\n /**\n @notice creates a clone of the master SimpleSwap contract\n @param issuer the issuer of cheques for the new chequebook\n @param defaultHardDepositTimeoutDuration duration in seconds which by default will be used to reduce hardDeposit allocations\n @param salt salt to include in create2 to enable the same address to deploy multiple chequebooks\n */\n function deploySimpleSwap(address issuer, uint defaultHardDepositTimeoutDuration, bytes32 salt)\n public returns (address) { \n address contractAddress = Clones.cloneDeterministic(master, keccak256(abi.encode(msg.sender, salt)));\n ERC20SimpleSwap(contractAddress).init(issuer, ERC20Address, defaultHardDepositTimeoutDuration);\n deployedContracts[contractAddress] = true;\n emit SimpleSwapDeployed(contractAddress);\n return contractAddress;\n }\n}" + }, + "@openzeppelin/contracts/proxy/Clones.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\n * deploying minimal proxy contracts, also known as \"clones\".\n *\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\n *\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\n * deterministic method.\n *\n * _Available since v3.4._\n */\nlibrary Clones {\n /**\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\n *\n * This function uses the create opcode, which should never revert.\n */\n function clone(address master) internal returns (address instance) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, master))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n instance := create(0, ptr, 0x37)\n }\n require(instance != address(0), \"ERC1167: create failed\");\n }\n\n /**\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\n *\n * This function uses the create2 opcode and a `salt` to deterministically deploy\n * the clone. Using the same `master` and `salt` multiple time will revert, since\n * the clones cannot be deployed twice at the same address.\n */\n function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, master))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n instance := create2(0, ptr, 0x37, salt)\n }\n require(instance != address(0), \"ERC1167: create2 failed\");\n }\n\n /**\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n */\n function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, master))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\n mstore(add(ptr, 0x38), shl(0x60, deployer))\n mstore(add(ptr, 0x4c), salt)\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\n predicted := keccak256(add(ptr, 0x37), 0x55)\n }\n }\n\n /**\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n */\n function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {\n return predictDeterministicAddress(master, salt, address(this));\n }\n}\n" + }, + "contracts/TestToken.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity =0.7.6;\n\nimport \"@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol\";\n\ncontract TestToken is ERC20PresetMinterPauser {\n\n constructor() ERC20PresetMinterPauser(\"Test\", \"TST\") {\n }\n\n}" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/hardhat.config.js b/hardhat.config.js index ac5faad..357f086 100755 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -28,7 +28,7 @@ const accounts = module.exports = { defaultNetwork: "hardhat", solidity: { - version: "0.8.19", + version: "0.7.6", settings: { optimizer: { enabled: true, diff --git a/package.json b/package.json index 1ef1f28..d95c9bb 100755 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dependencies": { "@nomicfoundation/hardhat-verify": "^1.0.0", "@nomiclabs/hardhat-etherscan": "^3.1.7", - "@openzeppelin/contracts": "^4.4.1", + "@openzeppelin/contracts": "^3.4.1-solc-0.7-2", "dotenv": "^16.0.3" }, "devDependencies": { @@ -39,4 +39,4 @@ "keywords": [], "author": "", "license": "ISC" -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 393223b..9c0680d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -934,10 +934,10 @@ find-up "^4.1.0" fs-extra "^8.1.0" -"@openzeppelin/contracts@^4.4.1": - version "4.4.1" - resolved "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.4.1.tgz" - integrity sha512-o+pHCf/yMLSlV5MkDQEzEQL402i6SoRnktru+0rdSxVEFZcTzzGhZCAtZjUFyKGazMSv1TilzMg+RbED1N8XHQ== +"@openzeppelin/contracts@^3.4.1-solc-0.7-2": + version "3.4.2" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2.tgz#d81f786fda2871d1eb8a8c5a73e455753ba53527" + integrity sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA== "@openzeppelin/test-helpers@^0.5.15": version "0.5.15"