diff --git a/packages/contracts/contracts/escrow/CollateralUpgradeableBeacon.sol b/packages/contracts/contracts/escrow/CollateralUpgradeableBeacon.sol new file mode 100644 index 000000000..32b7e2a07 --- /dev/null +++ b/packages/contracts/contracts/escrow/CollateralUpgradeableBeacon.sol @@ -0,0 +1,13 @@ + + +pragma solidity >=0.8.0 <0.9.0; +// SPDX-License-Identifier: MIT + +import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; + +contract CollateralUpgradeableBeacon is UpgradeableBeacon { + + +constructor(address _impl) UpgradeableBeacon(_impl) {} + +} \ No newline at end of file diff --git a/packages/contracts/deploy/00_deploy_meta_forwarder.ts b/packages/contracts/deploy/00_deploy_meta_forwarder.ts index cf4d743a0..697564423 100644 --- a/packages/contracts/deploy/00_deploy_meta_forwarder.ts +++ b/packages/contracts/deploy/00_deploy_meta_forwarder.ts @@ -1,7 +1,16 @@ +import { getNamedAccounts } from 'hardhat' import { DeployFunction } from 'hardhat-deploy/dist/types' import { deploy } from 'helpers/deploy-helpers' const deployFn: DeployFunction = async (hre) => { + + + + + let {deployer} = await getNamedAccounts() + + console.log('deployer',deployer) + const trustedForwarder = await deploy({ contract: 'MetaForwarder', skipIfAlreadyDeployed: true, diff --git a/packages/contracts/deploy/00_deploy_teller_v2.ts b/packages/contracts/deploy/00_deploy_teller_v2.ts index 56db8917d..9b6f9b680 100644 --- a/packages/contracts/deploy/00_deploy_teller_v2.ts +++ b/packages/contracts/deploy/00_deploy_teller_v2.ts @@ -58,14 +58,16 @@ const deployFn: DeployFunction = async (hre) => { skipIfAlreadyDeployed: true, hre, }) - + const collateralEscrowBeacon = await deploy({ - contract: 'UpgradeableBeacon', + contract: 'CollateralUpgradeableBeacon', name: 'CollateralEscrowBeacon', args: [collateralEscrowBeaconImpl.address], skipIfAlreadyDeployed: true, hre, }) + + const currentEscrowBeaconImpl = await collateralEscrowBeacon.implementation() if ( collateralEscrowBeaconImpl.deployResult.newlyDeployed && @@ -79,6 +81,8 @@ const deployFn: DeployFunction = async (hre) => { hre.log(`done`) } + + const collateralManager = await deploy({ contract: 'CollateralManager', args: [], @@ -95,6 +99,9 @@ const deployFn: DeployFunction = async (hre) => { hre, }) + + + const tellerV2IsInitialized = await isInitialized(tellerV2Contract.address) if (!tellerV2IsInitialized) { const lenderManager = await hre.contracts.get('LenderManager') diff --git a/packages/contracts/deployments/goerli/.latestDeploymentBlock b/packages/contracts/deployments/goerli/.latestDeploymentBlock index 1322fec84..1b53a8745 100644 --- a/packages/contracts/deployments/goerli/.latestDeploymentBlock +++ b/packages/contracts/deployments/goerli/.latestDeploymentBlock @@ -1 +1 @@ -8667201 \ No newline at end of file +8689047 \ No newline at end of file diff --git a/packages/contracts/deployments/goerli/.migrations.json b/packages/contracts/deployments/goerli/.migrations.json index 2e4d7ec8f..d914652e6 100644 --- a/packages/contracts/deployments/goerli/.migrations.json +++ b/packages/contracts/deployments/goerli/.migrations.json @@ -1,4 +1,4 @@ { - "1676322266__tellerv2_set_lender_manager.ts": 1677101488, - "1677629407__transfer_lendermanager_to_tellerv2.ts": 1677702686 + "1676322266__tellerv2_set_lender_manager.ts": 1679339048, + "1677629407__transfer_lendermanager_to_tellerv2.ts": 1679339057 } \ No newline at end of file diff --git a/packages/contracts/deployments/goerli/CollateralEscrow.json b/packages/contracts/deployments/goerli/CollateralEscrow.json index 8a05b5519..37a1cd5bc 100644 --- a/packages/contracts/deployments/goerli/CollateralEscrow.json +++ b/packages/contracts/deployments/goerli/CollateralEscrow.json @@ -1,5 +1,5 @@ { - "address": "0x5b3B04efA36DA056a29d4d9BED95C0FE723B4AB3", + "address": "0x586303F410efd2e223238aD3A43865599884c982", "abi": [ { "anonymous": false, @@ -365,25 +365,25 @@ "type": "function" } ], - "transactionHash": "0xe2d7731461362e6b742137a71262e0ffc6429bc5160b17e91b59a7c8e4bc88c3", + "transactionHash": "0x320c9465e89527a9a4f038bff862c0d8b092128bf388e999da50aa369d91166c", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x5b3B04efA36DA056a29d4d9BED95C0FE723B4AB3", - "transactionIndex": 7, - "gasUsed": "1198296", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x586303F410efd2e223238aD3A43865599884c982", + "transactionIndex": 12, + "gasUsed": "1198630", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x9a0c94bf0c0cb763160bffdebe60edc8f8233248be0093c64f6b89cdbcfd43c1", - "transactionHash": "0xe2d7731461362e6b742137a71262e0ffc6429bc5160b17e91b59a7c8e4bc88c3", + "blockHash": "0x5a611160ba32a5fc61d49ba5e0df6ba5644bd035f27692cfb95cac0f77450088", + "transactionHash": "0x320c9465e89527a9a4f038bff862c0d8b092128bf388e999da50aa369d91166c", "logs": [], - "blockNumber": 8538488, - "cumulativeGasUsed": "1345296", + "blockNumber": 8688919, + "cumulativeGasUsed": "1582843", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "556fedad003f0c0b44fba88774cf2ef3", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"CollateralDeposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"CollateralWithdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"bidId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"collateralBalances\",\"outputs\":[{\"internalType\":\"enum CollateralType\",\"name\":\"_collateralType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum CollateralType\",\"name\":\"_collateralType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"depositAsset\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"depositToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBid\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155BatchReceived\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"depositAsset(uint8,address,uint256,uint256)\":{\"params\":{\"_amount\":\"The amount to deposit.\",\"_collateralAddress\":\"The address of the collateral token.\",\"_collateralType\":\"The type of collateral asset to deposit (ERC721, ERC1155).\"}},\"depositToken(address,uint256)\":{\"params\":{\"_amount\":\"The amount to deposit.\",\"_collateralAddress\":\"The address of the collateral token.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"withdraw(address,uint256,address)\":{\"params\":{\"_amount\":\"The amount to withdraw.\",\"_collateralAddress\":\"The address of the collateral contract.\",\"_recipient\":\"The address to send the assets to.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"depositAsset(uint8,address,uint256,uint256)\":{\"notice\":\"Deposits a collateral asset into the escrow.\"},\"depositToken(address,uint256)\":{\"notice\":\"Deposits a collateral ERC20 token into the escrow.\"},\"initialize(uint256)\":{\"notice\":\"Initializes an escrow.The id of the associated bid.\"},\"withdraw(address,uint256,address)\":{\"notice\":\"Withdraws a collateral asset from the escrow.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/escrow/CollateralEscrowV1.sol\":\"CollateralEscrowV1\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\\n *\\n * _Available since v3.1._\\n */\\ninterface IERC1155Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\\n */\\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\\n\\n /**\\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\\n * transfers.\\n */\\n event TransferBatch(\\n address indexed operator,\\n address indexed from,\\n address indexed to,\\n uint256[] ids,\\n uint256[] values\\n );\\n\\n /**\\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\\n * `approved`.\\n */\\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\\n\\n /**\\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\\n *\\n * If an {URI} event was emitted for `id`, the standard\\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\\n * returned by {IERC1155MetadataURI-uri}.\\n */\\n event URI(string value, uint256 indexed id);\\n\\n /**\\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function balanceOf(address account, uint256 id) external view returns (uint256);\\n\\n /**\\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\\n *\\n * Requirements:\\n *\\n * - `accounts` and `ids` must have the same length.\\n */\\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\\n *\\n * Emits an {ApprovalForAll} event.\\n *\\n * Requirements:\\n *\\n * - `operator` cannot be the caller.\\n */\\n function setApprovalForAll(address operator, bool approved) external;\\n\\n /**\\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\\n *\\n * See {setApprovalForAll}.\\n */\\n function isApprovedForAll(address account, address operator) external view returns (bool);\\n\\n /**\\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\\n *\\n * Emits a {TransferSingle} event.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\\n * acceptance magic value.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 id,\\n uint256 amount,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\\n *\\n * Emits a {TransferBatch} event.\\n *\\n * Requirements:\\n *\\n * - `ids` and `amounts` must have the same length.\\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\\n * acceptance magic value.\\n */\\n function safeBatchTransferFrom(\\n address from,\\n address to,\\n uint256[] calldata ids,\\n uint256[] calldata amounts,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x091a49ef99a2be002680781a10cc9dd74c0f348301ede5482c4ea625f79a8ffe\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x220c4a5af915e656be2aaa85ca57505d102418e476b1e2ef6c62e0c6ac143871\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721ReceiverUpgradeable {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xbb2ed8106d94aeae6858e2551a1e7174df73994b77b13ebd120ccaaef80155f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"contracts/escrow/CollateralEscrowV1.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// Contracts\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\n// Interfaces\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport { SafeERC20Upgradeable } from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\\\";\\nimport \\\"../interfaces/escrow/ICollateralEscrowV1.sol\\\";\\n\\ncontract CollateralEscrowV1 is OwnableUpgradeable, ICollateralEscrowV1 {\\n uint256 public bidId;\\n /* Mappings */\\n mapping(address => Collateral) public collateralBalances; // collateral address -> collateral\\n\\n /* Events */\\n event CollateralDeposited(address _collateralAddress, uint256 _amount);\\n event CollateralWithdrawn(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n );\\n\\n /**\\n * @notice Initializes an escrow.\\n * @notice The id of the associated bid.\\n */\\n function initialize(uint256 _bidId) public initializer {\\n __Ownable_init();\\n bidId = _bidId;\\n }\\n\\n function getBid() external view returns (uint256) {\\n return bidId;\\n }\\n\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount)\\n external\\n onlyOwner\\n {\\n require(_amount > 0, \\\"Deposit amount cannot be zero\\\");\\n _depositCollateral(\\n CollateralType.ERC20,\\n _collateralAddress,\\n _amount,\\n 0\\n );\\n Collateral storage collateral = collateralBalances[_collateralAddress];\\n collateral._collateralType = CollateralType.ERC20;\\n collateral._amount = _amount;\\n emit CollateralDeposited(_collateralAddress, _amount);\\n }\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable onlyOwner {\\n require(_amount > 0, \\\"Deposit amount cannot be zero\\\");\\n _depositCollateral(\\n _collateralType,\\n _collateralAddress,\\n _amount,\\n _tokenId\\n );\\n Collateral storage collateral = collateralBalances[_collateralAddress];\\n collateral._collateralType = _collateralType;\\n collateral._amount = _amount;\\n collateral._tokenId = _tokenId;\\n emit CollateralDeposited(_collateralAddress, _amount);\\n }\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external onlyOwner {\\n require(_amount > 0, \\\"Withdraw amount cannot be zero\\\");\\n Collateral storage collateral = collateralBalances[_collateralAddress];\\n require(\\n collateral._amount >= _amount,\\n \\\"No collateral balance for asset\\\"\\n );\\n _withdrawCollateral(\\n collateral,\\n _collateralAddress,\\n _amount,\\n _recipient\\n );\\n collateral._amount -= _amount;\\n emit CollateralWithdrawn(_collateralAddress, _amount, _recipient);\\n }\\n\\n function _depositCollateral(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) internal {\\n // Deposit ERC20\\n if (_collateralType == CollateralType.ERC20) {\\n SafeERC20Upgradeable.safeTransferFrom(\\n IERC20Upgradeable(_collateralAddress),\\n _msgSender(),\\n address(this),\\n _amount\\n );\\n }\\n // Deposit ERC721\\n else if (_collateralType == CollateralType.ERC721) {\\n require(_amount == 1, \\\"Incorrect deposit amount\\\");\\n IERC721Upgradeable(_collateralAddress).transferFrom(\\n _msgSender(),\\n address(this),\\n _tokenId\\n );\\n }\\n // Deposit ERC1155\\n else if (_collateralType == CollateralType.ERC1155) {\\n bytes memory data;\\n\\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\\n _msgSender(),\\n address(this),\\n _tokenId,\\n _amount,\\n data\\n );\\n }\\n }\\n\\n function _withdrawCollateral(\\n Collateral memory _collateral,\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) internal {\\n // Withdraw ERC20\\n if (_collateral._collateralType == CollateralType.ERC20) {\\n IERC20Upgradeable(_collateralAddress).transfer(\\n _recipient,\\n _collateral._amount\\n );\\n }\\n // Withdraw ERC721\\n else if (_collateral._collateralType == CollateralType.ERC721) {\\n require(_amount == 1, \\\"Incorrect withdrawal amount\\\");\\n IERC721Upgradeable(_collateralAddress).transferFrom(\\n address(this),\\n _recipient,\\n _collateral._tokenId\\n );\\n }\\n // Withdraw ERC1155\\n else if (_collateral._collateralType == CollateralType.ERC1155) {\\n bytes memory data;\\n\\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\\n address(this),\\n _recipient,\\n _collateral._tokenId,\\n _amount,\\n data\\n );\\n }\\n }\\n\\n // On NFT Received handlers\\n\\n function onERC721Received(address, address, uint256, bytes calldata)\\n external\\n pure\\n returns (bytes4)\\n {\\n return\\n bytes4(\\n keccak256(\\\"onERC721Received(address,address,uint256,bytes)\\\")\\n );\\n }\\n\\n function onERC1155Received(\\n address,\\n address,\\n uint256 id,\\n uint256 value,\\n bytes calldata\\n ) external returns (bytes4) {\\n return\\n bytes4(\\n keccak256(\\n \\\"onERC1155Received(address,address,uint256,uint256,bytes)\\\"\\n )\\n );\\n }\\n\\n function onERC1155BatchReceived(\\n address,\\n address,\\n uint256[] calldata _ids,\\n uint256[] calldata _values,\\n bytes calldata\\n ) external returns (bytes4) {\\n require(\\n _ids.length == 1,\\n \\\"Only allowed one asset batch transfer per transaction.\\\"\\n );\\n return\\n bytes4(\\n keccak256(\\n \\\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\\\"\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0xb248a1cb9e5eeb70890fe05a6cddd01521fe66b4eaef84a7202f01454691220d\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b506114b8806100206000396000f3fe6080604052600436106100c25760003560e01c80638ac473191161007f578063f20c929611610059578063f20c92961461025d578063f23a6e6114610270578063f2fde38b146102b6578063fe4b84df146102d657600080fd5b80638ac47319146101ff5780638da5cb5b14610215578063bc197c811461023d57600080fd5b8063099a019d146100c7578063150b7a02146100eb57806329bc969d14610149578063338b5dea146101a857806369328dec146101ca578063715018a6146101ea575b600080fd5b3480156100d357600080fd5b506065545b6040519081526020015b60405180910390f35b3480156100f757600080fd5b50610130610106366004611002565b7f150b7a023d4804d13e8c85fb27262cb750cf6ba9f9dd3bb30d90f482ceeb4b1f95945050505050565b6040516001600160e01b031990911681526020016100e2565b34801561015557600080fd5b50610198610164366004611071565b606660205260009081526040902080546001820154600283015460039093015460ff9092169290916001600160a01b031684565b6040516100e294939291906110a9565b3480156101b457600080fd5b506101c86101c33660046110f0565b6102f6565b005b3480156101d657600080fd5b506101c86101e536600461111a565b6103c8565b3480156101f657600080fd5b506101c8610563565b34801561020b57600080fd5b506100d860655481565b34801561022157600080fd5b506033546040516001600160a01b0390911681526020016100e2565b34801561024957600080fd5b5061013061025836600461119b565b610577565b6101c861026b366004611256565b610616565b34801561027c57600080fd5b5061013061028b36600461129e565b7ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf979695505050505050565b3480156102c257600080fd5b506101c86102d1366004611071565b61070c565b3480156102e257600080fd5b506101c86102f1366004611316565b610785565b6102fe61089c565b600081116103535760405162461bcd60e51b815260206004820152601d60248201527f4465706f73697420616d6f756e742063616e6e6f74206265207a65726f00000060448201526064015b60405180910390fd5b6103616000838360006108f6565b6001600160a01b038216600081815260666020908152604091829020805460ff19168155600181018590558251938452908301849052917fd7243f6f8212d5188fd054141cf6ea89cfc0d91facb8c3afe2f88a1358480142910160405180910390a1505050565b6103d061089c565b600082116104205760405162461bcd60e51b815260206004820152601e60248201527f576974686472617720616d6f756e742063616e6e6f74206265207a65726f0000604482015260640161034a565b6001600160a01b0383166000908152606660205260409020600181015483111561048c5760405162461bcd60e51b815260206004820152601f60248201527f4e6f20636f6c6c61746572616c2062616c616e636520666f7220617373657400604482015260640161034a565b604080516080810190915281546104fa91908390829060ff1660028111156104b6576104b6611093565b60028111156104c7576104c7611093565b815260018201546020820152600282015460408201526003909101546001600160a01b0316606090910152858585610a82565b8281600101600082825461050e919061132f565b9091555050604080516001600160a01b0386811682526020820186905284168183015290517f5c582f045c0b9365cea3be0c0ad7deef76a1c4fe20ef1f84c153043ec35985039181900360600190a150505050565b61056b61089c565b6105756000610c2e565b565b6000600186146105e85760405162461bcd60e51b815260206004820152603660248201527f4f6e6c7920616c6c6f776564206f6e65206173736574206261746368207472616044820152753739b332b9103832b9103a3930b739b0b1ba34b7b71760511b606482015260840161034a565b507fbc197c819b3e337a6f9652dd10becd7eef83032af3b9d958d3d42f669414662198975050505050505050565b61061e61089c565b6000821161066e5760405162461bcd60e51b815260206004820152601d60248201527f4465706f73697420616d6f756e742063616e6e6f74206265207a65726f000000604482015260640161034a565b61067a848484846108f6565b6001600160a01b038316600090815260666020526040902080548590829060ff191660018360028111156106b0576106b0611093565b02179055506001810183905560028101829055604080516001600160a01b0386168152602081018590527fd7243f6f8212d5188fd054141cf6ea89cfc0d91facb8c3afe2f88a1358480142910160405180910390a15050505050565b61071461089c565b6001600160a01b0381166107795760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161034a565b61078281610c2e565b50565b600054610100900460ff16158080156107a55750600054600160ff909116105b806107bf5750303b1580156107bf575060005460ff166001145b6108225760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161034a565b6000805460ff191660011790558015610845576000805461ff0019166101001790555b61084d610c80565b60658290558015610898576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6033546001600160a01b031633146105755760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161034a565b600084600281111561090a5761090a611093565b14156109215761091c83333085610caf565b610a7c565b600184600281111561093557610935611093565b14156109f7578160011461098b5760405162461bcd60e51b815260206004820152601860248201527f496e636f7272656374206465706f73697420616d6f756e740000000000000000604482015260640161034a565b6040516323b872dd60e01b8152336004820152306024820152604481018290526001600160a01b038416906323b872dd906064015b600060405180830381600087803b1580156109da57600080fd5b505af11580156109ee573d6000803e3d6000fd5b50505050610a7c565b6002846002811115610a0b57610a0b611093565b1415610a7c57604051637921219560e11b81526060906001600160a01b0385169063f242432a90610a4890339030908790899088906004016113ac565b600060405180830381600087803b158015610a6257600080fd5b505af1158015610a76573d6000803e3d6000fd5b50505050505b50505050565b600084516002811115610a9757610a97611093565b1415610b2c57602084015160405163a9059cbb60e01b81526001600160a01b03838116600483015260248201929092529084169063a9059cbb90604401602060405180830381600087803b158015610aee57600080fd5b505af1158015610b02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2691906113e6565b50610a7c565b600184516002811115610b4157610b41611093565b1415610bd95781600114610b975760405162461bcd60e51b815260206004820152601b60248201527f496e636f7272656374207769746864726177616c20616d6f756e740000000000604482015260640161034a565b60408481015190516323b872dd60e01b81523060048201526001600160a01b0383811660248301526044820192909252908416906323b872dd906064016109c0565b600284516002811115610bee57610bee611093565b1415610a7c576040808501519051637921219560e11b81526060916001600160a01b0386169163f242432a91610a489130918791899088906004016113ac565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610ca75760405162461bcd60e51b815260040161034a90611408565b610575610d09565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610a7c908590610d39565b600054610100900460ff16610d305760405162461bcd60e51b815260040161034a90611408565b61057533610c2e565b6000610d8e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610e109092919063ffffffff16565b805190915015610e0b5780806020019051810190610dac91906113e6565b610e0b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161034a565b505050565b6060610e1f8484600085610e27565b949350505050565b606082471015610e885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161034a565b600080866001600160a01b03168587604051610ea49190611453565b60006040518083038185875af1925050503d8060008114610ee1576040519150601f19603f3d011682016040523d82523d6000602084013e610ee6565b606091505b5091509150610ef787838387610f02565b979650505050505050565b60608315610f6e578251610f67576001600160a01b0385163b610f675760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161034a565b5081610e1f565b610e1f8383815115610f835781518083602001fd5b8060405162461bcd60e51b815260040161034a919061146f565b80356001600160a01b0381168114610fb457600080fd5b919050565b60008083601f840112610fcb57600080fd5b50813567ffffffffffffffff811115610fe357600080fd5b602083019150836020828501011115610ffb57600080fd5b9250929050565b60008060008060006080868803121561101a57600080fd5b61102386610f9d565b945061103160208701610f9d565b935060408601359250606086013567ffffffffffffffff81111561105457600080fd5b61106088828901610fb9565b969995985093965092949392505050565b60006020828403121561108357600080fd5b61108c82610f9d565b9392505050565b634e487b7160e01b600052602160045260246000fd5b60808101600386106110cb57634e487b7160e01b600052602160045260246000fd5b948152602081019390935260408301919091526001600160a01b031660609091015290565b6000806040838503121561110357600080fd5b61110c83610f9d565b946020939093013593505050565b60008060006060848603121561112f57600080fd5b61113884610f9d565b92506020840135915061114d60408501610f9d565b90509250925092565b60008083601f84011261116857600080fd5b50813567ffffffffffffffff81111561118057600080fd5b6020830191508360208260051b8501011115610ffb57600080fd5b60008060008060008060008060a0898b0312156111b757600080fd5b6111c089610f9d565b97506111ce60208a01610f9d565b9650604089013567ffffffffffffffff808211156111eb57600080fd5b6111f78c838d01611156565b909850965060608b013591508082111561121057600080fd5b61121c8c838d01611156565b909650945060808b013591508082111561123557600080fd5b506112428b828c01610fb9565b999c989b5096995094979396929594505050565b6000806000806080858703121561126c57600080fd5b84356003811061127b57600080fd5b935061128960208601610f9d565b93969395505050506040820135916060013590565b60008060008060008060a087890312156112b757600080fd5b6112c087610f9d565b95506112ce60208801610f9d565b94506040870135935060608701359250608087013567ffffffffffffffff8111156112f857600080fd5b61130489828a01610fb9565b979a9699509497509295939492505050565b60006020828403121561132857600080fd5b5035919050565b60008282101561134f57634e487b7160e01b600052601160045260246000fd5b500390565b60005b8381101561136f578181015183820152602001611357565b83811115610a7c5750506000910152565b60008151808452611398816020860160208601611354565b601f01601f19169290920160200192915050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090610ef790830184611380565b6000602082840312156113f857600080fd5b8151801515811461108c57600080fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251611465818460208701611354565b9190910192915050565b60208152600061108c602083018461138056fea264697066735822122093c003031a3546ddcfd6ac46399099cb5b2154c7b596670ffeaf5c6b2e9d33db64736f6c63430008090033", "deployedBytecode": "0x6080604052600436106100c25760003560e01c80638ac473191161007f578063f20c929611610059578063f20c92961461025d578063f23a6e6114610270578063f2fde38b146102b6578063fe4b84df146102d657600080fd5b80638ac47319146101ff5780638da5cb5b14610215578063bc197c811461023d57600080fd5b8063099a019d146100c7578063150b7a02146100eb57806329bc969d14610149578063338b5dea146101a857806369328dec146101ca578063715018a6146101ea575b600080fd5b3480156100d357600080fd5b506065545b6040519081526020015b60405180910390f35b3480156100f757600080fd5b50610130610106366004611002565b7f150b7a023d4804d13e8c85fb27262cb750cf6ba9f9dd3bb30d90f482ceeb4b1f95945050505050565b6040516001600160e01b031990911681526020016100e2565b34801561015557600080fd5b50610198610164366004611071565b606660205260009081526040902080546001820154600283015460039093015460ff9092169290916001600160a01b031684565b6040516100e294939291906110a9565b3480156101b457600080fd5b506101c86101c33660046110f0565b6102f6565b005b3480156101d657600080fd5b506101c86101e536600461111a565b6103c8565b3480156101f657600080fd5b506101c8610563565b34801561020b57600080fd5b506100d860655481565b34801561022157600080fd5b506033546040516001600160a01b0390911681526020016100e2565b34801561024957600080fd5b5061013061025836600461119b565b610577565b6101c861026b366004611256565b610616565b34801561027c57600080fd5b5061013061028b36600461129e565b7ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf979695505050505050565b3480156102c257600080fd5b506101c86102d1366004611071565b61070c565b3480156102e257600080fd5b506101c86102f1366004611316565b610785565b6102fe61089c565b600081116103535760405162461bcd60e51b815260206004820152601d60248201527f4465706f73697420616d6f756e742063616e6e6f74206265207a65726f00000060448201526064015b60405180910390fd5b6103616000838360006108f6565b6001600160a01b038216600081815260666020908152604091829020805460ff19168155600181018590558251938452908301849052917fd7243f6f8212d5188fd054141cf6ea89cfc0d91facb8c3afe2f88a1358480142910160405180910390a1505050565b6103d061089c565b600082116104205760405162461bcd60e51b815260206004820152601e60248201527f576974686472617720616d6f756e742063616e6e6f74206265207a65726f0000604482015260640161034a565b6001600160a01b0383166000908152606660205260409020600181015483111561048c5760405162461bcd60e51b815260206004820152601f60248201527f4e6f20636f6c6c61746572616c2062616c616e636520666f7220617373657400604482015260640161034a565b604080516080810190915281546104fa91908390829060ff1660028111156104b6576104b6611093565b60028111156104c7576104c7611093565b815260018201546020820152600282015460408201526003909101546001600160a01b0316606090910152858585610a82565b8281600101600082825461050e919061132f565b9091555050604080516001600160a01b0386811682526020820186905284168183015290517f5c582f045c0b9365cea3be0c0ad7deef76a1c4fe20ef1f84c153043ec35985039181900360600190a150505050565b61056b61089c565b6105756000610c2e565b565b6000600186146105e85760405162461bcd60e51b815260206004820152603660248201527f4f6e6c7920616c6c6f776564206f6e65206173736574206261746368207472616044820152753739b332b9103832b9103a3930b739b0b1ba34b7b71760511b606482015260840161034a565b507fbc197c819b3e337a6f9652dd10becd7eef83032af3b9d958d3d42f669414662198975050505050505050565b61061e61089c565b6000821161066e5760405162461bcd60e51b815260206004820152601d60248201527f4465706f73697420616d6f756e742063616e6e6f74206265207a65726f000000604482015260640161034a565b61067a848484846108f6565b6001600160a01b038316600090815260666020526040902080548590829060ff191660018360028111156106b0576106b0611093565b02179055506001810183905560028101829055604080516001600160a01b0386168152602081018590527fd7243f6f8212d5188fd054141cf6ea89cfc0d91facb8c3afe2f88a1358480142910160405180910390a15050505050565b61071461089c565b6001600160a01b0381166107795760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161034a565b61078281610c2e565b50565b600054610100900460ff16158080156107a55750600054600160ff909116105b806107bf5750303b1580156107bf575060005460ff166001145b6108225760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161034a565b6000805460ff191660011790558015610845576000805461ff0019166101001790555b61084d610c80565b60658290558015610898576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6033546001600160a01b031633146105755760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161034a565b600084600281111561090a5761090a611093565b14156109215761091c83333085610caf565b610a7c565b600184600281111561093557610935611093565b14156109f7578160011461098b5760405162461bcd60e51b815260206004820152601860248201527f496e636f7272656374206465706f73697420616d6f756e740000000000000000604482015260640161034a565b6040516323b872dd60e01b8152336004820152306024820152604481018290526001600160a01b038416906323b872dd906064015b600060405180830381600087803b1580156109da57600080fd5b505af11580156109ee573d6000803e3d6000fd5b50505050610a7c565b6002846002811115610a0b57610a0b611093565b1415610a7c57604051637921219560e11b81526060906001600160a01b0385169063f242432a90610a4890339030908790899088906004016113ac565b600060405180830381600087803b158015610a6257600080fd5b505af1158015610a76573d6000803e3d6000fd5b50505050505b50505050565b600084516002811115610a9757610a97611093565b1415610b2c57602084015160405163a9059cbb60e01b81526001600160a01b03838116600483015260248201929092529084169063a9059cbb90604401602060405180830381600087803b158015610aee57600080fd5b505af1158015610b02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2691906113e6565b50610a7c565b600184516002811115610b4157610b41611093565b1415610bd95781600114610b975760405162461bcd60e51b815260206004820152601b60248201527f496e636f7272656374207769746864726177616c20616d6f756e740000000000604482015260640161034a565b60408481015190516323b872dd60e01b81523060048201526001600160a01b0383811660248301526044820192909252908416906323b872dd906064016109c0565b600284516002811115610bee57610bee611093565b1415610a7c576040808501519051637921219560e11b81526060916001600160a01b0386169163f242432a91610a489130918791899088906004016113ac565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610ca75760405162461bcd60e51b815260040161034a90611408565b610575610d09565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610a7c908590610d39565b600054610100900460ff16610d305760405162461bcd60e51b815260040161034a90611408565b61057533610c2e565b6000610d8e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610e109092919063ffffffff16565b805190915015610e0b5780806020019051810190610dac91906113e6565b610e0b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161034a565b505050565b6060610e1f8484600085610e27565b949350505050565b606082471015610e885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161034a565b600080866001600160a01b03168587604051610ea49190611453565b60006040518083038185875af1925050503d8060008114610ee1576040519150601f19603f3d011682016040523d82523d6000602084013e610ee6565b606091505b5091509150610ef787838387610f02565b979650505050505050565b60608315610f6e578251610f67576001600160a01b0385163b610f675760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161034a565b5081610e1f565b610e1f8383815115610f835781518083602001fd5b8060405162461bcd60e51b815260040161034a919061146f565b80356001600160a01b0381168114610fb457600080fd5b919050565b60008083601f840112610fcb57600080fd5b50813567ffffffffffffffff811115610fe357600080fd5b602083019150836020828501011115610ffb57600080fd5b9250929050565b60008060008060006080868803121561101a57600080fd5b61102386610f9d565b945061103160208701610f9d565b935060408601359250606086013567ffffffffffffffff81111561105457600080fd5b61106088828901610fb9565b969995985093965092949392505050565b60006020828403121561108357600080fd5b61108c82610f9d565b9392505050565b634e487b7160e01b600052602160045260246000fd5b60808101600386106110cb57634e487b7160e01b600052602160045260246000fd5b948152602081019390935260408301919091526001600160a01b031660609091015290565b6000806040838503121561110357600080fd5b61110c83610f9d565b946020939093013593505050565b60008060006060848603121561112f57600080fd5b61113884610f9d565b92506020840135915061114d60408501610f9d565b90509250925092565b60008083601f84011261116857600080fd5b50813567ffffffffffffffff81111561118057600080fd5b6020830191508360208260051b8501011115610ffb57600080fd5b60008060008060008060008060a0898b0312156111b757600080fd5b6111c089610f9d565b97506111ce60208a01610f9d565b9650604089013567ffffffffffffffff808211156111eb57600080fd5b6111f78c838d01611156565b909850965060608b013591508082111561121057600080fd5b61121c8c838d01611156565b909650945060808b013591508082111561123557600080fd5b506112428b828c01610fb9565b999c989b5096995094979396929594505050565b6000806000806080858703121561126c57600080fd5b84356003811061127b57600080fd5b935061128960208601610f9d565b93969395505050506040820135916060013590565b60008060008060008060a087890312156112b757600080fd5b6112c087610f9d565b95506112ce60208801610f9d565b94506040870135935060608701359250608087013567ffffffffffffffff8111156112f857600080fd5b61130489828a01610fb9565b979a9699509497509295939492505050565b60006020828403121561132857600080fd5b5035919050565b60008282101561134f57634e487b7160e01b600052601160045260246000fd5b500390565b60005b8381101561136f578181015183820152602001611357565b83811115610a7c5750506000910152565b60008151808452611398816020860160208601611354565b601f01601f19169290920160200192915050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090610ef790830184611380565b6000602082840312156113f857600080fd5b8151801515811461108c57600080fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251611465818460208701611354565b9190910192915050565b60208152600061108c602083018461138056fea264697066735822122093c003031a3546ddcfd6ac46399099cb5b2154c7b596670ffeaf5c6b2e9d33db64736f6c63430008090033", @@ -443,7 +443,7 @@ "storageLayout": { "storage": [ { - "astId": 1625, + "astId": 326, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "_initialized", "offset": 0, @@ -451,7 +451,7 @@ "type": "t_uint8" }, { - "astId": 1628, + "astId": 329, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "_initializing", "offset": 1, @@ -459,7 +459,7 @@ "type": "t_bool" }, { - "astId": 3912, + "astId": 2613, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "__gap", "offset": 0, @@ -467,7 +467,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 1309, + "astId": 10, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "_owner", "offset": 0, @@ -475,7 +475,7 @@ "type": "t_address" }, { - "astId": 1429, + "astId": 130, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "__gap", "offset": 0, @@ -483,7 +483,7 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 23997, + "astId": 23305, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "bidId", "offset": 0, @@ -491,12 +491,12 @@ "type": "t_uint256" }, { - "astId": 24002, + "astId": 23310, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "collateralBalances", "offset": 0, "slot": "102", - "type": "t_mapping(t_address,t_struct(Collateral)25699_storage)" + "type": "t_mapping(t_address,t_struct(Collateral)25148_storage)" } ], "types": { @@ -522,32 +522,32 @@ "label": "bool", "numberOfBytes": "1" }, - "t_enum(CollateralType)25689": { + "t_enum(CollateralType)25138": { "encoding": "inplace", "label": "enum CollateralType", "numberOfBytes": "1" }, - "t_mapping(t_address,t_struct(Collateral)25699_storage)": { + "t_mapping(t_address,t_struct(Collateral)25148_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct Collateral)", "numberOfBytes": "32", - "value": "t_struct(Collateral)25699_storage" + "value": "t_struct(Collateral)25148_storage" }, - "t_struct(Collateral)25699_storage": { + "t_struct(Collateral)25148_storage": { "encoding": "inplace", "label": "struct Collateral", "members": [ { - "astId": 25692, + "astId": 25141, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "_collateralType", "offset": 0, "slot": "0", - "type": "t_enum(CollateralType)25689" + "type": "t_enum(CollateralType)25138" }, { - "astId": 25694, + "astId": 25143, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "_amount", "offset": 0, @@ -555,7 +555,7 @@ "type": "t_uint256" }, { - "astId": 25696, + "astId": 25145, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "_tokenId", "offset": 0, @@ -563,7 +563,7 @@ "type": "t_uint256" }, { - "astId": 25698, + "astId": 25147, "contract": "contracts/escrow/CollateralEscrowV1.sol:CollateralEscrowV1", "label": "_collateralAddress", "offset": 0, diff --git a/packages/contracts/deployments/goerli/CollateralEscrowBeacon.json b/packages/contracts/deployments/goerli/CollateralEscrowBeacon.json index f07d221eb..23f182154 100644 --- a/packages/contracts/deployments/goerli/CollateralEscrowBeacon.json +++ b/packages/contracts/deployments/goerli/CollateralEscrowBeacon.json @@ -1,11 +1,11 @@ { - "address": "0x5133D831F2d761e8d64953C489Fab1395D91e7e8", + "address": "0x49C97802A5d2598c1a4564EdED553330bb85603c", "abi": [ { "inputs": [ { "internalType": "address", - "name": "implementation_", + "name": "_impl", "type": "address" } ], @@ -104,57 +104,48 @@ "type": "function" } ], - "transactionHash": "0x5a099cc478a1d85a7e730cb77c620a7e0aca6061bd597cdd06af60c2d1ef23a5", + "transactionHash": "0xee8c4facf2f7446425fb6f0dfdd4c78c3596d0fb0b1535144b5399fdd656f677", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x5133D831F2d761e8d64953C489Fab1395D91e7e8", - "transactionIndex": 2, - "gasUsed": "292111", - "logsBloom": "0x00000000000000000000000000008000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000080000000000000000000000020000000000000000000000000000000000000000000000000800000000000000000", - "blockHash": "0x76716c70ab9f11b7e89a4b677943bfdf64aa237340be303e9998202a80422048", - "transactionHash": "0x5a099cc478a1d85a7e730cb77c620a7e0aca6061bd597cdd06af60c2d1ef23a5", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x49C97802A5d2598c1a4564EdED553330bb85603c", + "transactionIndex": 53, + "gasUsed": "292230", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000002000000000800001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000400000000000000000000000000000000000000000000000000080020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xbc725f95a3dd14bd6aed82167263fde006e60537762810c157f54f7d3f0a91e1", + "transactionHash": "0xee8c4facf2f7446425fb6f0dfdd4c78c3596d0fb0b1535144b5399fdd656f677", "logs": [ { - "transactionIndex": 2, - "blockNumber": 8538489, - "transactionHash": "0x5a099cc478a1d85a7e730cb77c620a7e0aca6061bd597cdd06af60c2d1ef23a5", - "address": "0x5133D831F2d761e8d64953C489Fab1395D91e7e8", + "transactionIndex": 53, + "blockNumber": 8689001, + "transactionHash": "0xee8c4facf2f7446425fb6f0dfdd4c78c3596d0fb0b1535144b5399fdd656f677", + "address": "0x49C97802A5d2598c1a4564EdED553330bb85603c", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", - "logIndex": 0, - "blockHash": "0x76716c70ab9f11b7e89a4b677943bfdf64aa237340be303e9998202a80422048" + "logIndex": 3, + "blockHash": "0xbc725f95a3dd14bd6aed82167263fde006e60537762810c157f54f7d3f0a91e1" } ], - "blockNumber": 8538489, - "cumulativeGasUsed": "334111", + "blockNumber": 8689001, + "cumulativeGasUsed": "1546211", "status": 1, "byzantium": true }, "args": [ - "0x5b3B04efA36DA056a29d4d9BED95C0FE723B4AB3" + "0x586303F410efd2e223238aD3A43865599884c982" ], "numDeployments": 1, - "solcInputHash": "556fedad003f0c0b44fba88774cf2ef3", - "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their implementation contract, which is where they will delegate all function calls. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\",\"events\":{\"Upgraded(address)\":{\"details\":\"Emitted when the implementation returned by the beacon is changed.\"}},\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the beacon.\"},\"implementation()\":{\"details\":\"Returns the current implementation address.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgradeTo(address)\":{\"details\":\"Upgrades the beacon to a new implementation. Emits an {Upgraded} event. Requirements: - msg.sender must be the owner of the contract. - `newImplementation` must be a contract.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\":\"UpgradeableBeacon\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IBeacon.sol\\\";\\nimport \\\"../../access/Ownable.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\\n * implementation contract, which is where they will delegate all function calls.\\n *\\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\\n */\\ncontract UpgradeableBeacon is IBeacon, Ownable {\\n address private _implementation;\\n\\n /**\\n * @dev Emitted when the implementation returned by the beacon is changed.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\\n * beacon.\\n */\\n constructor(address implementation_) {\\n _setImplementation(implementation_);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function implementation() public view virtual override returns (address) {\\n return _implementation;\\n }\\n\\n /**\\n * @dev Upgrades the beacon to a new implementation.\\n *\\n * Emits an {Upgraded} event.\\n *\\n * Requirements:\\n *\\n * - msg.sender must be the owner of the contract.\\n * - `newImplementation` must be a contract.\\n */\\n function upgradeTo(address newImplementation) public virtual onlyOwner {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Sets the implementation contract address for this beacon\\n *\\n * Requirements:\\n *\\n * - `newImplementation` must be a contract.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"UpgradeableBeacon: implementation is not a contract\\\");\\n _implementation = newImplementation;\\n }\\n}\\n\",\"keccak256\":\"0x6ec71aef5659f3f74011169948d2fcda8c6599be5bb38f986380a8737f96cc0f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b506040516104e43803806104e483398101604081905261002f91610151565b61003833610047565b61004181610097565b50610181565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6100aa8161014260201b6101a01760201c565b6101205760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840160405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03163b151590565b60006020828403121561016357600080fd5b81516001600160a01b038116811461017a57600080fd5b9392505050565b610354806101906000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80633659cfe61461005c5780635c60da1b14610071578063715018a61461009a5780638da5cb5b146100a2578063f2fde38b146100b3575b600080fd5b61006f61006a3660046102ee565b6100c6565b005b6001546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b61006f61010e565b6000546001600160a01b031661007e565b61006f6100c13660046102ee565b610122565b6100ce6101af565b6100d781610209565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6101166101af565b610120600061029e565b565b61012a6101af565b6001600160a01b0381166101945760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61019d8161029e565b50565b6001600160a01b03163b151590565b6000546001600160a01b031633146101205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161018b565b6001600160a01b0381163b61027c5760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f6044820152721b881a5cc81b9bdd08184818dbdb9d1c9858dd606a1b606482015260840161018b565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561030057600080fd5b81356001600160a01b038116811461031757600080fd5b939250505056fea264697066735822122071948ec535f218355f7b1a6b146021e45a71d4a4e7804487b9425355928d0eaa64736f6c63430008090033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c80633659cfe61461005c5780635c60da1b14610071578063715018a61461009a5780638da5cb5b146100a2578063f2fde38b146100b3575b600080fd5b61006f61006a3660046102ee565b6100c6565b005b6001546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b61006f61010e565b6000546001600160a01b031661007e565b61006f6100c13660046102ee565b610122565b6100ce6101af565b6100d781610209565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6101166101af565b610120600061029e565b565b61012a6101af565b6001600160a01b0381166101945760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61019d8161029e565b50565b6001600160a01b03163b151590565b6000546001600160a01b031633146101205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161018b565b6001600160a01b0381163b61027c5760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f6044820152721b881a5cc81b9bdd08184818dbdb9d1c9858dd606a1b606482015260840161018b565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561030057600080fd5b81356001600160a01b038116811461031757600080fd5b939250505056fea264697066735822122071948ec535f218355f7b1a6b146021e45a71d4a4e7804487b9425355928d0eaa64736f6c63430008090033", + "solcInputHash": "05370541c71c17418e30623d45438913", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_impl\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"implementation()\":{\"details\":\"Returns the current implementation address.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgradeTo(address)\":{\"details\":\"Upgrades the beacon to a new implementation. Emits an {Upgraded} event. Requirements: - msg.sender must be the owner of the contract. - `newImplementation` must be a contract.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/escrow/CollateralUpgradeableBeacon.sol\":\"CollateralUpgradeableBeacon\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IBeacon.sol\\\";\\nimport \\\"../../access/Ownable.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\\n * implementation contract, which is where they will delegate all function calls.\\n *\\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\\n */\\ncontract UpgradeableBeacon is IBeacon, Ownable {\\n address private _implementation;\\n\\n /**\\n * @dev Emitted when the implementation returned by the beacon is changed.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\\n * beacon.\\n */\\n constructor(address implementation_) {\\n _setImplementation(implementation_);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function implementation() public view virtual override returns (address) {\\n return _implementation;\\n }\\n\\n /**\\n * @dev Upgrades the beacon to a new implementation.\\n *\\n * Emits an {Upgraded} event.\\n *\\n * Requirements:\\n *\\n * - msg.sender must be the owner of the contract.\\n * - `newImplementation` must be a contract.\\n */\\n function upgradeTo(address newImplementation) public virtual onlyOwner {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Sets the implementation contract address for this beacon\\n *\\n * Requirements:\\n *\\n * - `newImplementation` must be a contract.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"UpgradeableBeacon: implementation is not a contract\\\");\\n _implementation = newImplementation;\\n }\\n}\\n\",\"keccak256\":\"0x6ec71aef5659f3f74011169948d2fcda8c6599be5bb38f986380a8737f96cc0f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/escrow/CollateralUpgradeableBeacon.sol\":{\"content\":\"\\n\\npragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\\\";\\n\\ncontract CollateralUpgradeableBeacon is UpgradeableBeacon {\\n\\n\\nconstructor(address _impl) UpgradeableBeacon(_impl) {}\\n\\n}\",\"keccak256\":\"0x33ebd0bdcfeaab2508ad426b986b043009c499434275631bbbd69f6dbf6afbe4\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506040516104e63803806104e683398101604081905261002f91610153565b8061003933610049565b61004281610099565b5050610183565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6100ac8161014460201b6101a01760201c565b6101225760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f60448201527f6e206973206e6f74206120636f6e747261637400000000000000000000000000606482015260840160405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03163b151590565b60006020828403121561016557600080fd5b81516001600160a01b038116811461017c57600080fd5b9392505050565b610354806101926000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80633659cfe61461005c5780635c60da1b14610071578063715018a61461009a5780638da5cb5b146100a2578063f2fde38b146100b3575b600080fd5b61006f61006a3660046102ee565b6100c6565b005b6001546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b61006f61010e565b6000546001600160a01b031661007e565b61006f6100c13660046102ee565b610122565b6100ce6101af565b6100d781610209565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6101166101af565b610120600061029e565b565b61012a6101af565b6001600160a01b0381166101945760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61019d8161029e565b50565b6001600160a01b03163b151590565b6000546001600160a01b031633146101205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161018b565b6001600160a01b0381163b61027c5760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f6044820152721b881a5cc81b9bdd08184818dbdb9d1c9858dd606a1b606482015260840161018b565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561030057600080fd5b81356001600160a01b038116811461031757600080fd5b939250505056fea2646970667358221220af71527c92be4259e1cbe24767aed87d63d389ce9475d0bc2a112bb983ca671964736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c80633659cfe61461005c5780635c60da1b14610071578063715018a61461009a5780638da5cb5b146100a2578063f2fde38b146100b3575b600080fd5b61006f61006a3660046102ee565b6100c6565b005b6001546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b61006f61010e565b6000546001600160a01b031661007e565b61006f6100c13660046102ee565b610122565b6100ce6101af565b6100d781610209565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6101166101af565b610120600061029e565b565b61012a6101af565b6001600160a01b0381166101945760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61019d8161029e565b50565b6001600160a01b03163b151590565b6000546001600160a01b031633146101205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161018b565b6001600160a01b0381163b61027c5760405162461bcd60e51b815260206004820152603360248201527f5570677261646561626c65426561636f6e3a20696d706c656d656e746174696f6044820152721b881a5cc81b9bdd08184818dbdb9d1c9858dd606a1b606482015260840161018b565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561030057600080fd5b81356001600160a01b038116811461031757600080fd5b939250505056fea2646970667358221220af71527c92be4259e1cbe24767aed87d63d389ce9475d0bc2a112bb983ca671964736f6c63430008090033", "devdoc": { - "details": "This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their implementation contract, which is where they will delegate all function calls. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.", - "events": { - "Upgraded(address)": { - "details": "Emitted when the implementation returned by the beacon is changed." - } - }, "kind": "dev", "methods": { - "constructor": { - "details": "Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the beacon." - }, "implementation()": { "details": "Returns the current implementation address." }, @@ -181,16 +172,16 @@ "storageLayout": { "storage": [ { - "astId": 6680, - "contract": "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol:UpgradeableBeacon", + "astId": 7, + "contract": "contracts/escrow/CollateralUpgradeableBeacon.sol:CollateralUpgradeableBeacon", "label": "_owner", "offset": 0, "slot": "0", "type": "t_address" }, { - "astId": 7331, - "contract": "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol:UpgradeableBeacon", + "astId": 134, + "contract": "contracts/escrow/CollateralUpgradeableBeacon.sol:CollateralUpgradeableBeacon", "label": "_implementation", "offset": 0, "slot": "1", diff --git a/packages/contracts/deployments/goerli/CollateralManager.json b/packages/contracts/deployments/goerli/CollateralManager.json index e4e8c9270..74f1c3a4e 100644 --- a/packages/contracts/deployments/goerli/CollateralManager.json +++ b/packages/contracts/deployments/goerli/CollateralManager.json @@ -1,5 +1,5 @@ { - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "abi": [ { "anonymous": false, @@ -884,85 +884,92 @@ "type": "constructor" } ], - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xD66de8b25C4165dA2e7696e15E8436380823B118", - "transactionIndex": 7, - "gasUsed": "815126", - "logsBloom": "0x00000000000000000000000000808000400000000000008000800000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000002000101000000000000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000000000008000000080000000000000800000000000000000000000000000000400000000000002000000000000000000000000000020000100000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000800000000000000000", - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb", - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", + "transactionIndex": 6, + "gasUsed": "815436", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000000000000000000000000000000000000000000000000000002000000000800000000000000000000200000002000001002000001000000000000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000004000000000000000000000000000080000000000000800000000000000000000000000000000400048000000000000000001000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c", + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", "logs": [ { - "transactionIndex": 7, - "blockNumber": 8538491, - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "transactionIndex": 6, + "blockNumber": 8689003, + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000001727add0680412e839c500cce4a2a20e3d96ff5c" + "0x000000000000000000000000c1bbf4dea9168e4949fc1d0aebe0fc51975c7b44" ], "data": "0x", "logIndex": 0, - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb" + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c" }, { - "transactionIndex": 7, - "blockNumber": 8538491, - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "transactionIndex": 6, + "blockNumber": 8689003, + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", "logIndex": 1, - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb" + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c" }, { - "transactionIndex": 7, - "blockNumber": 8538491, - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "transactionIndex": 6, + "blockNumber": 8689003, + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 2, - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb" + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c" }, { - "transactionIndex": 7, - "blockNumber": 8538491, - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "transactionIndex": 6, + "blockNumber": 8689003, + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 3, - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb" + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c" } ], - "blockNumber": 8538491, - "cumulativeGasUsed": "962126", + "blockNumber": 8689003, + "cumulativeGasUsed": "968404", "status": 1, "byzantium": true }, "args": [ - "0x1727ADd0680412e839c500ccE4a2A20e3d96fF5C", - "0x5956c8158bde236d8e3638362ff7555C329A839B", - "0x485cc9550000000000000000000000005133d831f2d761e8d64953c489fab1395d91e7e8000000000000000000000000195c6608705546725df0629dd60690cf2b367734" + "0xC1bBF4dea9168e4949fc1D0aeBE0Fc51975C7B44", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0x485cc95500000000000000000000000049c97802a5d2598c1a4564eded553330bb85603c0000000000000000000000003a8c417a743a60ecff3988c34783d65362b62915" ], - "numDeployments": 3, + "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", - "implementation": "0xf64a61e57a504C802416E6f64C522eE2Dd22FAC1", + "execute": { + "methodName": "initialize", + "args": [ + "0x49C97802A5d2598c1a4564EdED553330bb85603c", + "0x3a8C417a743A60ECfF3988C34783D65362b62915" + ] + }, + "implementation": "0xC1bBF4dea9168e4949fc1D0aeBE0Fc51975C7B44", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/CollateralManager_Implementation.json b/packages/contracts/deployments/goerli/CollateralManager_Implementation.json index 869cf7719..260266cfe 100644 --- a/packages/contracts/deployments/goerli/CollateralManager_Implementation.json +++ b/packages/contracts/deployments/goerli/CollateralManager_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0xf64a61e57a504C802416E6f64C522eE2Dd22FAC1", + "address": "0xC1bBF4dea9168e4949fc1D0aeBE0Fc51975C7B44", "abi": [ { "anonymous": false, @@ -740,25 +740,25 @@ "type": "function" } ], - "transactionHash": "0x49e0ec53edb59afd63c8d2583ec646a515b4bce59aecf2859efc4cfc62ac7223", + "transactionHash": "0x0be9bda26efdeca15f442cf6a1f7a29ed7d94f29d3d041fef4c0e4b7e33470c6", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xf64a61e57a504C802416E6f64C522eE2Dd22FAC1", - "transactionIndex": 0, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xC1bBF4dea9168e4949fc1D0aeBE0Fc51975C7B44", + "transactionIndex": 14, "gasUsed": "2862430", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x430f3d486d2c02c6bee68e899e4d3bc62c8913e04c859f9c7da20c6967cfdf5e", - "transactionHash": "0x49e0ec53edb59afd63c8d2583ec646a515b4bce59aecf2859efc4cfc62ac7223", + "blockHash": "0x48ed584015961eec6e90f5c09425652d33771f8d0958b3476744ad1083afb477", + "transactionHash": "0x0be9bda26efdeca15f442cf6a1f7a29ed7d94f29d3d041fef4c0e4b7e33470c6", "logs": [], - "blockNumber": 8667197, - "cumulativeGasUsed": "2862430", + "blockNumber": 8689002, + "cumulativeGasUsed": "3388323", "status": 1, "byzantium": true }, "args": [], - "numDeployments": 3, - "solcInputHash": "704ec39527d925eea3260ddc4e8d1e8a", + "numDeployments": 1, + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"CollateralClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum CollateralType\",\"name\":\"_type\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"CollateralCommitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum CollateralType\",\"name\":\"_type\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"CollateralDeposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_collateralEscrow\",\"type\":\"address\"}],\"name\":\"CollateralEscrowDeployed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum CollateralType\",\"name\":\"_type\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"CollateralWithdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"enum CollateralType\",\"name\":\"_collateralType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"}],\"internalType\":\"struct Collateral\",\"name\":\"collateralInfo\",\"type\":\"tuple\"}],\"name\":\"_deposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"_escrows\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"enum CollateralType\",\"name\":\"_collateralType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"}],\"internalType\":\"struct Collateral[]\",\"name\":\"_collateralInfo\",\"type\":\"tuple[]\"}],\"name\":\"checkBalances\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"validated_\",\"type\":\"bool\"},{\"internalType\":\"bool[]\",\"name\":\"checks_\",\"type\":\"bool[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"enum CollateralType\",\"name\":\"_collateralType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"}],\"internalType\":\"struct Collateral[]\",\"name\":\"_collateralInfo\",\"type\":\"tuple[]\"}],\"name\":\"commitCollateral\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"validation_\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"enum CollateralType\",\"name\":\"_collateralType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"}],\"internalType\":\"struct Collateral\",\"name\":\"_collateralInfo\",\"type\":\"tuple\"}],\"name\":\"commitCollateral\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"validation_\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"deployAndDeposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"}],\"name\":\"getCollateralAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getCollateralInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"enum CollateralType\",\"name\":\"_collateralType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"}],\"internalType\":\"struct Collateral[]\",\"name\":\"infos_\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getEscrow\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_collateralEscrowBeacon\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tellerV2\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"isBidCollateralBacked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_liquidatorAddress\",\"type\":\"address\"}],\"name\":\"liquidateCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_values\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155BatchReceived\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC1155Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"revalidateCollateral\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"validation_\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_collateralEscrowBeacon\",\"type\":\"address\"}],\"name\":\"setCollateralEscrowBeacon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tellerV2\",\"outputs\":[{\"internalType\":\"contract ITellerV2\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"checkBalances(address,(uint8,uint256,uint256,address)[])\":{\"params\":{\"_borrowerAddress\":\"The address of the borrower holding the collateral.\",\"_collateralInfo\":\"Additional information about the collateral assets.\"}},\"commitCollateral(uint256,(uint8,uint256,uint256,address))\":{\"params\":{\"_bidId\":\"The id of the associated bid.\",\"_collateralInfo\":\"Additional information about the collateral asset.\"},\"returns\":{\"validation_\":\"Boolean indicating if the collateral balance was validated.\"}},\"commitCollateral(uint256,(uint8,uint256,uint256,address)[])\":{\"params\":{\"_bidId\":\"The id of the associated bid.\",\"_collateralInfo\":\"Additional information about the collateral assets.\"},\"returns\":{\"validation_\":\"Boolean indicating if the collateral balances were validated.\"}},\"deployAndDeposit(uint256)\":{\"params\":{\"_bidId\":\"The associated bidId of the collateral escrow.\"}},\"getCollateralAmount(uint256,address)\":{\"params\":{\"_bidId\":\"The ID of a bid on TellerV2.\",\"_collateralAddress\":\"An address used as collateral.\"},\"returns\":{\"amount_\":\"The amount of collateral of type _collateralAddress.\"}},\"getCollateralInfo(uint256)\":{\"params\":{\"_bidId\":\"The bidId to return the collateral info for.\"},\"returns\":{\"infos_\":\"The stored collateral info.\"}},\"getEscrow(uint256)\":{\"returns\":{\"_0\":\"The address of the escrow.\"}},\"initialize(address,address)\":{\"params\":{\"_collateralEscrowBeacon\":\"The address of the escrow implementation.\",\"_tellerV2\":\"The address of the protocol.\"}},\"isBidCollateralBacked(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid to check.\"}},\"liquidateCollateral(uint256,address)\":{\"params\":{\"_bidId\":\"The id of the liquidated bid.\",\"_liquidatorAddress\":\"The address of the liquidator to send the collateral to.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"revalidateCollateral(uint256)\":{\"params\":{\"_bidId\":\"The id of the associated bid.\"},\"returns\":{\"validation_\":\"Boolean indicating if the collateral balance was validated.\"}},\"setCollateralEscrowBeacon(address)\":{\"params\":{\"_collateralEscrowBeacon\":\"The address of the Beacon contract.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"withdraw(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid to withdraw collateral for.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"checkBalances(address,(uint8,uint256,uint256,address)[])\":{\"notice\":\"Checks the validity of a borrower's multiple collateral balances.\"},\"commitCollateral(uint256,(uint8,uint256,uint256,address))\":{\"notice\":\"Checks the validity of a borrower's collateral balance and commits it to a bid.\"},\"commitCollateral(uint256,(uint8,uint256,uint256,address)[])\":{\"notice\":\"Checks the validity of a borrower's multiple collateral balances and commits it to a bid.\"},\"deployAndDeposit(uint256)\":{\"notice\":\"Deploys a new collateral escrow and deposits collateral.\"},\"getCollateralAmount(uint256,address)\":{\"notice\":\"Gets the collateral asset amount for a given bid id on the TellerV2 contract.\"},\"getCollateralInfo(uint256)\":{\"notice\":\"Gets the collateral info for a given bid id.\"},\"getEscrow(uint256)\":{\"notice\":\"Gets the address of a deployed escrow._bidId The bidId to return the escrow for.\"},\"initialize(address,address)\":{\"notice\":\"Initializes the collateral manager.\"},\"isBidCollateralBacked(uint256)\":{\"notice\":\"Checks to see if a bid is backed by collateral.\"},\"liquidateCollateral(uint256,address)\":{\"notice\":\"Sends the deposited collateral to a liquidator of a bid.Can only be called by the protocol.\"},\"revalidateCollateral(uint256)\":{\"notice\":\"Re-checks the validity of a borrower's collateral balance committed to a bid.\"},\"setCollateralEscrowBeacon(address)\":{\"notice\":\"Sets the address of the Beacon contract used for the collateral escrow contracts.\"},\"withdraw(uint256)\":{\"notice\":\"Withdraws deposited collateral from the created escrow of a bid that has been successfully repaid.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/CollateralManager.sol\":\"CollateralManager\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\\n *\\n * _Available since v3.1._\\n */\\ninterface IERC1155Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\\n */\\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\\n\\n /**\\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\\n * transfers.\\n */\\n event TransferBatch(\\n address indexed operator,\\n address indexed from,\\n address indexed to,\\n uint256[] ids,\\n uint256[] values\\n );\\n\\n /**\\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\\n * `approved`.\\n */\\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\\n\\n /**\\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\\n *\\n * If an {URI} event was emitted for `id`, the standard\\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\\n * returned by {IERC1155MetadataURI-uri}.\\n */\\n event URI(string value, uint256 indexed id);\\n\\n /**\\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function balanceOf(address account, uint256 id) external view returns (uint256);\\n\\n /**\\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\\n *\\n * Requirements:\\n *\\n * - `accounts` and `ids` must have the same length.\\n */\\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\\n *\\n * Emits an {ApprovalForAll} event.\\n *\\n * Requirements:\\n *\\n * - `operator` cannot be the caller.\\n */\\n function setApprovalForAll(address operator, bool approved) external;\\n\\n /**\\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\\n *\\n * See {setApprovalForAll}.\\n */\\n function isApprovedForAll(address account, address operator) external view returns (bool);\\n\\n /**\\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\\n *\\n * Emits a {TransferSingle} event.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\\n * acceptance magic value.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 id,\\n uint256 amount,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\\n *\\n * Emits a {TransferBatch} event.\\n *\\n * Requirements:\\n *\\n * - `ids` and `amounts` must have the same length.\\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\\n * acceptance magic value.\\n */\\n function safeBatchTransferFrom(\\n address from,\\n address to,\\n uint256[] calldata ids,\\n uint256[] calldata amounts,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0x091a49ef99a2be002680781a10cc9dd74c0f348301ede5482c4ea625f79a8ffe\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721ReceiverUpgradeable {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xbb2ed8106d94aeae6858e2551a1e7174df73994b77b13ebd120ccaaef80155f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSetUpgradeable {\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x4807db844a856813048b5af81a764fdd25a0ae8876a3132593e8d21ddc6b607c\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IBeacon.sol\\\";\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"../ERC1967/ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.\\n *\\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\\n * conflict with the storage layout of the implementation behind the proxy.\\n *\\n * _Available since v3.4._\\n */\\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the proxy with `beacon`.\\n *\\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\\n * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity\\n * constructor.\\n *\\n * Requirements:\\n *\\n * - `beacon` must be a contract with the interface {IBeacon}.\\n */\\n constructor(address beacon, bytes memory data) payable {\\n _upgradeBeaconToAndCall(beacon, data, false);\\n }\\n\\n /**\\n * @dev Returns the current beacon address.\\n */\\n function _beacon() internal view virtual returns (address) {\\n return _getBeacon();\\n }\\n\\n /**\\n * @dev Returns the current implementation address of the associated beacon.\\n */\\n function _implementation() internal view virtual override returns (address) {\\n return IBeacon(_getBeacon()).implementation();\\n }\\n\\n /**\\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\\n *\\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\\n *\\n * Requirements:\\n *\\n * - `beacon` must be a contract.\\n * - The implementation returned by `beacon` must be a contract.\\n */\\n function _setBeacon(address beacon, bytes memory data) internal virtual {\\n _upgradeBeaconToAndCall(beacon, data, false);\\n }\\n}\\n\",\"keccak256\":\"0x85439e74ab467b6a23d45d32bdc9506cbc3760320289afd605f11638c4138e95\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/CollateralManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// Contracts\\nimport \\\"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\n// Libraries\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\\\";\\n\\n// Interfaces\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { Collateral, CollateralType, ICollateralEscrowV1 } from \\\"./interfaces/escrow/ICollateralEscrowV1.sol\\\";\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\n\\ncontract CollateralManager is OwnableUpgradeable, ICollateralManager {\\n /* Storage */\\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\\n ITellerV2 public tellerV2;\\n address private collateralEscrowBeacon; // The address of the escrow contract beacon\\n mapping(uint256 => address) public _escrows; // bidIds -> collateralEscrow\\n // bidIds -> validated collateral info\\n mapping(uint256 => CollateralInfo) internal _bidCollaterals;\\n\\n /**\\n * Since collateralInfo is mapped (address assetAddress => Collateral) that means\\n * that only a single tokenId per nft per loan can be collateralized.\\n * Ex. Two bored apes cannot be used as collateral for a single loan.\\n */\\n struct CollateralInfo {\\n EnumerableSetUpgradeable.AddressSet collateralAddresses;\\n mapping(address => Collateral) collateralInfo;\\n }\\n\\n /* Events */\\n event CollateralEscrowDeployed(uint256 _bidId, address _collateralEscrow);\\n event CollateralCommitted(\\n uint256 _bidId,\\n CollateralType _type,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n );\\n event CollateralClaimed(uint256 _bidId);\\n event CollateralDeposited(\\n uint256 _bidId,\\n CollateralType _type,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n );\\n event CollateralWithdrawn(\\n uint256 _bidId,\\n CollateralType _type,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId,\\n address _recipient\\n );\\n\\n /* Modifiers */\\n modifier onlyTellerV2() {\\n require(_msgSender() == address(tellerV2), \\\"Sender not authorized\\\");\\n _;\\n }\\n\\n /* External Functions */\\n\\n /**\\n * @notice Initializes the collateral manager.\\n * @param _collateralEscrowBeacon The address of the escrow implementation.\\n * @param _tellerV2 The address of the protocol.\\n */\\n function initialize(address _collateralEscrowBeacon, address _tellerV2)\\n external\\n initializer\\n {\\n collateralEscrowBeacon = _collateralEscrowBeacon;\\n tellerV2 = ITellerV2(_tellerV2);\\n __Ownable_init_unchained();\\n }\\n\\n /**\\n * @notice Sets the address of the Beacon contract used for the collateral escrow contracts.\\n * @param _collateralEscrowBeacon The address of the Beacon contract.\\n */\\n function setCollateralEscrowBeacon(address _collateralEscrowBeacon)\\n external\\n reinitializer(2)\\n {\\n collateralEscrowBeacon = _collateralEscrowBeacon;\\n }\\n\\n /**\\n * @notice Checks to see if a bid is backed by collateral.\\n * @param _bidId The id of the bid to check.\\n */\\n\\n function isBidCollateralBacked(uint256 _bidId) public returns (bool) {\\n return _bidCollaterals[_bidId].collateralAddresses.length() > 0;\\n }\\n\\n /**\\n * @notice Checks the validity of a borrower's multiple collateral balances and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral assets.\\n * @return validation_ Boolean indicating if the collateral balances were validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) public returns (bool validation_) {\\n address borrower = tellerV2.getLoanBorrower(_bidId);\\n (validation_, ) = checkBalances(borrower, _collateralInfo);\\n if (validation_) {\\n for (uint256 i; i < _collateralInfo.length; i++) {\\n Collateral memory info = _collateralInfo[i];\\n _commitCollateral(_bidId, info);\\n }\\n }\\n }\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) public returns (bool validation_) {\\n address borrower = tellerV2.getLoanBorrower(_bidId);\\n validation_ = _checkBalance(borrower, _collateralInfo);\\n if (validation_) {\\n _commitCollateral(_bidId, _collateralInfo);\\n }\\n }\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId)\\n external\\n returns (bool validation_)\\n {\\n Collateral[] memory collateralInfos = getCollateralInfo(_bidId);\\n address borrower = tellerV2.getLoanBorrower(_bidId);\\n (validation_, ) = _checkBalances(borrower, collateralInfos, true);\\n }\\n\\n /**\\n * @notice Checks the validity of a borrower's multiple collateral balances.\\n * @param _borrowerAddress The address of the borrower holding the collateral.\\n * @param _collateralInfo Additional information about the collateral assets.\\n */\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) public returns (bool validated_, bool[] memory checks_) {\\n return _checkBalances(_borrowerAddress, _collateralInfo, false);\\n }\\n\\n /**\\n * @notice Deploys a new collateral escrow and deposits collateral.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external onlyTellerV2 {\\n if (isBidCollateralBacked(_bidId)) {\\n (address proxyAddress, ) = _deployEscrow(_bidId);\\n _escrows[_bidId] = proxyAddress;\\n\\n for (\\n uint256 i;\\n i < _bidCollaterals[_bidId].collateralAddresses.length();\\n i++\\n ) {\\n _deposit(\\n _bidId,\\n _bidCollaterals[_bidId].collateralInfo[\\n _bidCollaterals[_bidId].collateralAddresses.at(i)\\n ]\\n );\\n }\\n\\n emit CollateralEscrowDeployed(_bidId, proxyAddress);\\n }\\n }\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address) {\\n return _escrows[_bidId];\\n }\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return infos_ The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n public\\n view\\n returns (Collateral[] memory infos_)\\n {\\n CollateralInfo storage collateral = _bidCollaterals[_bidId];\\n address[] memory collateralAddresses = collateral\\n .collateralAddresses\\n .values();\\n infos_ = new Collateral[](collateralAddresses.length);\\n for (uint256 i; i < collateralAddresses.length; i++) {\\n infos_[i] = collateral.collateralInfo[collateralAddresses[i]];\\n }\\n }\\n\\n /**\\n * @notice Gets the collateral asset amount for a given bid id on the TellerV2 contract.\\n * @param _bidId The ID of a bid on TellerV2.\\n * @param _collateralAddress An address used as collateral.\\n * @return amount_ The amount of collateral of type _collateralAddress.\\n */\\n function getCollateralAmount(uint256 _bidId, address _collateralAddress)\\n public\\n view\\n returns (uint256 amount_)\\n {\\n amount_ = _bidCollaterals[_bidId]\\n .collateralInfo[_collateralAddress]\\n ._amount;\\n }\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid that has been successfully repaid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external {\\n BidState bidState = tellerV2.getBidState(_bidId);\\n if (bidState == BidState.PAID) {\\n _withdraw(_bidId, tellerV2.getLoanBorrower(_bidId));\\n } else if (tellerV2.isLoanDefaulted(_bidId)) {\\n _withdraw(_bidId, tellerV2.getLoanLender(_bidId));\\n emit CollateralClaimed(_bidId);\\n } else {\\n revert(\\\"collateral cannot be withdrawn\\\");\\n }\\n }\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external\\n onlyTellerV2\\n {\\n if (isBidCollateralBacked(_bidId)) {\\n BidState bidState = tellerV2.getBidState(_bidId);\\n require(\\n bidState == BidState.LIQUIDATED,\\n \\\"Loan has not been liquidated\\\"\\n );\\n _withdraw(_bidId, _liquidatorAddress);\\n }\\n }\\n\\n /* Internal Functions */\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function _deployEscrow(uint256 _bidId)\\n internal\\n returns (address proxyAddress_, address borrower_)\\n {\\n proxyAddress_ = _escrows[_bidId];\\n // Get bid info\\n borrower_ = tellerV2.getLoanBorrower(_bidId);\\n if (proxyAddress_ == address(0)) {\\n require(borrower_ != address(0), \\\"Bid does not exist\\\");\\n\\n BeaconProxy proxy = new BeaconProxy(\\n collateralEscrowBeacon,\\n abi.encodeWithSelector(\\n ICollateralEscrowV1.initialize.selector,\\n _bidId\\n )\\n );\\n proxyAddress_ = address(proxy);\\n }\\n }\\n\\n function _deposit(uint256 _bidId, Collateral memory collateralInfo)\\n public\\n payable\\n {\\n require(collateralInfo._amount > 0, \\\"Collateral not validated\\\");\\n (address escrowAddress, address borrower) = _deployEscrow(_bidId);\\n ICollateralEscrowV1 collateralEscrow = ICollateralEscrowV1(\\n escrowAddress\\n );\\n // Pull collateral from borrower & deposit into escrow\\n if (collateralInfo._collateralType == CollateralType.ERC20) {\\n IERC20Upgradeable(collateralInfo._collateralAddress).transferFrom(\\n borrower,\\n address(this),\\n collateralInfo._amount\\n );\\n IERC20Upgradeable(collateralInfo._collateralAddress).approve(\\n escrowAddress,\\n collateralInfo._amount\\n );\\n collateralEscrow.depositToken(\\n collateralInfo._collateralAddress,\\n collateralInfo._amount\\n );\\n } else if (collateralInfo._collateralType == CollateralType.ERC721) {\\n IERC721Upgradeable(collateralInfo._collateralAddress).transferFrom(\\n borrower,\\n address(this),\\n collateralInfo._tokenId\\n );\\n IERC721Upgradeable(collateralInfo._collateralAddress).approve(\\n escrowAddress,\\n collateralInfo._tokenId\\n );\\n collateralEscrow.depositAsset(\\n CollateralType.ERC721,\\n collateralInfo._collateralAddress,\\n collateralInfo._amount,\\n collateralInfo._tokenId\\n );\\n } else if (collateralInfo._collateralType == CollateralType.ERC1155) {\\n bytes memory data;\\n IERC1155Upgradeable(collateralInfo._collateralAddress)\\n .safeTransferFrom(\\n borrower,\\n address(this),\\n collateralInfo._tokenId,\\n collateralInfo._amount,\\n data\\n );\\n IERC1155Upgradeable(collateralInfo._collateralAddress)\\n .setApprovalForAll(escrowAddress, true);\\n collateralEscrow.depositAsset(\\n CollateralType.ERC1155,\\n collateralInfo._collateralAddress,\\n collateralInfo._amount,\\n collateralInfo._tokenId\\n );\\n }\\n emit CollateralDeposited(\\n _bidId,\\n collateralInfo._collateralType,\\n collateralInfo._collateralAddress,\\n collateralInfo._amount,\\n collateralInfo._tokenId\\n );\\n }\\n\\n /**\\n * @notice Withdraws collateral to a given receiver's address.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n * @param _receiver The address to withdraw the collateral to.\\n */\\n function _withdraw(uint256 _bidId, address _receiver) internal {\\n for (\\n uint256 i;\\n i < _bidCollaterals[_bidId].collateralAddresses.length();\\n i++\\n ) {\\n // Get collateral info\\n Collateral storage collateralInfo = _bidCollaterals[_bidId]\\n .collateralInfo[\\n _bidCollaterals[_bidId].collateralAddresses.at(i)\\n ];\\n // Withdraw collateral from escrow and send it to bid lender\\n ICollateralEscrowV1(_escrows[_bidId]).withdraw(\\n collateralInfo._collateralAddress,\\n collateralInfo._amount,\\n _receiver\\n );\\n emit CollateralWithdrawn(\\n _bidId,\\n collateralInfo._collateralType,\\n collateralInfo._collateralAddress,\\n collateralInfo._amount,\\n collateralInfo._tokenId,\\n _receiver\\n );\\n }\\n }\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function _commitCollateral(\\n uint256 _bidId,\\n Collateral memory _collateralInfo\\n ) internal {\\n CollateralInfo storage collateral = _bidCollaterals[_bidId];\\n collateral.collateralAddresses.add(_collateralInfo._collateralAddress);\\n collateral.collateralInfo[\\n _collateralInfo._collateralAddress\\n ] = _collateralInfo;\\n emit CollateralCommitted(\\n _bidId,\\n _collateralInfo._collateralType,\\n _collateralInfo._collateralAddress,\\n _collateralInfo._amount,\\n _collateralInfo._tokenId\\n );\\n }\\n\\n /**\\n * @notice Checks the validity of a borrower's multiple collateral balances.\\n * @param _borrowerAddress The address of the borrower holding the collateral.\\n * @param _collateralInfo Additional information about the collateral assets.\\n */\\n function _checkBalances(\\n address _borrowerAddress,\\n Collateral[] memory _collateralInfo,\\n bool _shortCircut\\n ) internal returns (bool validated_, bool[] memory checks_) {\\n checks_ = new bool[](_collateralInfo.length);\\n validated_ = true;\\n for (uint256 i; i < _collateralInfo.length; i++) {\\n bool isValidated = _checkBalance(\\n _borrowerAddress,\\n _collateralInfo[i]\\n );\\n checks_[i] = isValidated;\\n if (!isValidated) {\\n validated_ = false;\\n if (_shortCircut) {\\n return (validated_, checks_);\\n }\\n }\\n }\\n }\\n\\n /**\\n * @notice Checks the validity of a borrower's single collateral balance.\\n * @param _borrowerAddress The address of the borrower holding the collateral.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balances were validated.\\n */\\n function _checkBalance(\\n address _borrowerAddress,\\n Collateral memory _collateralInfo\\n ) internal returns (bool) {\\n CollateralType collateralType = _collateralInfo._collateralType;\\n if (collateralType == CollateralType.ERC20) {\\n return\\n _collateralInfo._amount <=\\n IERC20Upgradeable(_collateralInfo._collateralAddress).balanceOf(\\n _borrowerAddress\\n );\\n }\\n if (collateralType == CollateralType.ERC721) {\\n return\\n _borrowerAddress ==\\n IERC721Upgradeable(_collateralInfo._collateralAddress).ownerOf(\\n _collateralInfo._tokenId\\n );\\n }\\n if (collateralType == CollateralType.ERC1155) {\\n return\\n _collateralInfo._amount <=\\n IERC1155Upgradeable(_collateralInfo._collateralAddress)\\n .balanceOf(_borrowerAddress, _collateralInfo._tokenId);\\n }\\n return false;\\n }\\n\\n // On NFT Received handlers\\n\\n function onERC721Received(address, address, uint256, bytes calldata)\\n external\\n pure\\n returns (bytes4)\\n {\\n return\\n bytes4(\\n keccak256(\\\"onERC721Received(address,address,uint256,bytes)\\\")\\n );\\n }\\n\\n function onERC1155Received(\\n address,\\n address,\\n uint256 id,\\n uint256 value,\\n bytes calldata\\n ) external returns (bytes4) {\\n return\\n bytes4(\\n keccak256(\\n \\\"onERC1155Received(address,address,uint256,uint256,bytes)\\\"\\n )\\n );\\n }\\n\\n function onERC1155BatchReceived(\\n address,\\n address,\\n uint256[] calldata _ids,\\n uint256[] calldata _values,\\n bytes calldata\\n ) external returns (bytes4) {\\n require(\\n _ids.length == 1,\\n \\\"Only allowed one asset batch transfer per transaction.\\\"\\n );\\n return\\n bytes4(\\n keccak256(\\n \\\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\\\"\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0xc9fd3dd95c6210261b233f7ddc7de4b23dfd21ccbd8b10726e11084bf61b79cc\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\\n external\\n view\\n returns (uint256 _amount);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x27778a3446cdbfed6356d5047f9926231261b37def2712a3cc63e3779350e5e4\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanLiquidateable(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n\\n function getLoanSummary(uint256 _bidId)\\n external\\n view\\n returns (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n );\\n}\\n\",\"keccak256\":\"0x2750d9717451e34323ef523810ff2a3a6285f146009955220d3860a7c4326077\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b506132ee806100206000396000f3fe6080604052600436106200014e5760003560e01c80638da5cb5b11620000b9578063cd98536b1162000078578063cd98536b1462000435578063d6c20fa81462000491578063e4ad84b414620004c6578063f0472c4914620004dd578063f23a6e611462000502578063f2fde38b146200054c57600080fd5b80638da5cb5b14620003755780638de161161462000395578063934b5d1314620003ba578063941675db14620003ee578063bc197c81146200041057600080fd5b8063485cc9551162000112578063485cc955146200028f5780635289fe9314620002b4578063715018a614620002d95780637d19e59614620002f1578063853c488d146200032b578063857919de146200035057600080fd5b806294f1e91462000153578063150b7a0214620001aa5780631532dc45146200020d578063251befba14620002435780632e1a7d4d1462000268575b600080fd5b3480156200016057600080fd5b506200018d62000172366004620020d0565b6067602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b348015620001b757600080fd5b50620001f3620001c93660046200214c565b7f150b7a023d4804d13e8c85fb27262cb750cf6ba9f9dd3bb30d90f482ceeb4b1f95945050505050565b6040516001600160e01b03199091168152602001620001a1565b3480156200021a57600080fd5b50620002326200022c3660046200220f565b62000571565b6040519015158152602001620001a1565b3480156200025057600080fd5b506200023262000262366004620020d0565b62000678565b3480156200027557600080fd5b506200028d62000287366004620020d0565b6200069a565b005b3480156200029c57600080fd5b506200028d620002ae3660046200225f565b62000911565b348015620002c157600080fd5b506200028d620002d33660046200229d565b62000a18565b348015620002e657600080fd5b506200028d62000ac9565b348015620002fe57600080fd5b506200018d62000310366004620020d0565b6000908152606760205260409020546001600160a01b031690565b3480156200033857600080fd5b50620002326200034a366004620022bd565b62000ae1565b3480156200035d57600080fd5b50620002326200036f366004620020d0565b62000bb0565b3480156200038257600080fd5b506033546001600160a01b03166200018d565b348015620003a257600080fd5b506200028d620003b4366004620020d0565b62000c5d565b348015620003c757600080fd5b50620003df620003d9366004620020d0565b62000e28565b604051620001a1919062002330565b348015620003fb57600080fd5b506065546200018d906001600160a01b031681565b3480156200041d57600080fd5b50620001f36200042f366004620023f0565b62000faa565b3480156200044257600080fd5b506200048262000454366004620024bd565b60009182526068602090815260408084206001600160a01b0390931684526002909201905290206001015490565b604051908152602001620001a1565b3480156200049e57600080fd5b50620004b6620004b0366004620024e5565b6200104b565b604051620001a192919062002525565b6200028d620004d73660046200261f565b620010c0565b348015620004ea57600080fd5b506200028d620004fc366004620024bd565b6200160a565b3480156200050f57600080fd5b50620001f3620005213660046200264f565b7ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf979695505050505050565b3480156200055957600080fd5b506200028d6200056b3660046200229d565b6200176d565b606554604051633ef0a2f760e01b81526004810185905260009182916001600160a01b0390911690633ef0a2f79060240160206040518083038186803b158015620005bb57600080fd5b505afa158015620005d0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005f69190620026d3565b9050620006058185856200104b565b5091508115620006705760005b838110156200066e576000858583818110620006325762000632620026f3565b9050608002018036038101906200064a919062002709565b9050620006588782620017e9565b5080620006658162002728565b91505062000612565b505b509392505050565b600081815260686020526040812081906200069390620018d4565b1192915050565b606554604051635fbbffd760e11b8152600481018390526000916001600160a01b03169063bf77ffae9060240160206040518083038186803b158015620006e057600080fd5b505afa158015620006f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200071b919062002752565b90506004816005811115620007345762000734620022f7565b1415620007cd57606554604051633ef0a2f760e01b815260048101849052620007c99184916001600160a01b0390911690633ef0a2f7906024015b60206040518083038186803b1580156200078857600080fd5b505afa1580156200079d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007c39190620026d3565b620018e5565b5050565b60655460405163e8cbab0960e01b8152600481018490526001600160a01b039091169063e8cbab099060240160206040518083038186803b1580156200081257600080fd5b505afa15801562000827573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200084d919062002775565b15620008c45760655460405163508482f560e11b8152600481018490526200088c9184916001600160a01b039091169063a10905ea906024016200076f565b6040518281527fd951b721f993d3959dc31ba5a751da7974aa23a2c46f52fc71c9ba9d1675b8e4906020015b60405180910390a15050565b60405162461bcd60e51b815260206004820152601e60248201527f636f6c6c61746572616c2063616e6e6f742062652077697468647261776e000060448201526064015b60405180910390fd5b600054610100900460ff1615808015620009325750600054600160ff909116105b806200094e5750303b1580156200094e575060005460ff166001145b6200096d5760405162461bcd60e51b8152600401620009089062002799565b6000805460ff19166001179055801562000991576000805461ff0019166101001790555b606680546001600160a01b038086166001600160a01b0319928316179092556065805492851692909116919091179055620009cb62001a3c565b801562000a13576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b505050565b600054600290610100900460ff1615801562000a3b575060005460ff8083169116105b62000a5a5760405162461bcd60e51b8152600401620009089062002799565b60008054606680546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b62000ad362001ab4565b62000adf600062001b10565b565b606554604051633ef0a2f760e01b81526004810184905260009182916001600160a01b0390911690633ef0a2f79060240160206040518083038186803b15801562000b2b57600080fd5b505afa15801562000b40573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b669190620026d3565b905062000b848162000b7e3686900386018662002709565b62001b62565b9150811562000ba95762000ba98462000ba33686900386018662002709565b620017e9565b5092915050565b60008062000bbe8362000e28565b606554604051633ef0a2f760e01b8152600481018690529192506000916001600160a01b0390911690633ef0a2f79060240160206040518083038186803b15801562000c0957600080fd5b505afa15801562000c1e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c449190620026d3565b905062000c548183600162001d45565b50949350505050565b6065546001600160a01b0316336001600160a01b03161462000cba5760405162461bcd60e51b815260206004820152601560248201527414d95b99195c881b9bdd08185d5d1a1bdc9a5e9959605a1b604482015260640162000908565b62000cc58162000678565b1562000e2557600062000cd88262001e2e565b50600083815260676020526040812080546001600160a01b0319166001600160a01b0384161790559091505b600083815260686020526040902062000d1d90620018d4565b81101562000de557600083815260686020526040812062000dd091859160028101919062000d4c908662001faa565b6001600160a01b03168152602081019190915260409081016000208151608081019092528054829060ff16600281111562000d8b5762000d8b620022f7565b600281111562000d9f5762000d9f620022f7565b815260018201546020820152600282015460408201526003909101546001600160a01b0316606090910152620010c0565b8062000ddc8162002728565b91505062000d04565b50604080518381526001600160a01b03831660208201527fc201bfb915e3eed80ff17e013f3d88db1c51ac7fc12728fce91a2afc659128ef9101620008b8565b50565b600081815260686020526040812060609162000e448262001fbf565b9050805167ffffffffffffffff81111562000e635762000e6362002579565b60405190808252806020026020018201604052801562000eb757816020015b60408051608081018252600080825260208083018290529282018190526060820152825260001990920191018162000e825790505b50925060005b815181101562000fa25782600201600083838151811062000ee25762000ee2620026f3565b6020908102919091018101516001600160a01b0316825281019190915260409081016000208151608081019092528054829060ff16600281111562000f2b5762000f2b620022f7565b600281111562000f3f5762000f3f620022f7565b815260018201546020820152600282015460408201526003909101546001600160a01b0316606090910152845185908390811062000f815762000f81620026f3565b6020026020010181905250808062000f999062002728565b91505062000ebd565b505050919050565b6000600186146200101d5760405162461bcd60e51b815260206004820152603660248201527f4f6e6c7920616c6c6f776564206f6e65206173736574206261746368207472616044820152753739b332b9103832b9103a3930b739b0b1ba34b7b71760511b606482015260840162000908565b507fbc197c819b3e337a6f9652dd10becd7eef83032af3b9d958d3d42f669414662198975050505050505050565b60006060620010b3858585808060200260200160405190810160405280939291908181526020016000905b82821015620010a657620010966080830286013681900381019062002709565b8152602001906001019062001076565b5050505050600062001d45565b915091505b935093915050565b6000816020015111620011165760405162461bcd60e51b815260206004820152601860248201527f436f6c6c61746572616c206e6f742076616c6964617465640000000000000000604482015260640162000908565b600080620011248462001e2e565b909250905081600084516002811115620011425762001142620022f7565b1415620012f657606084015160208501516040516323b872dd60e01b81526001600160a01b03858116600483015230602483015260448201929092529116906323b872dd90606401602060405180830381600087803b158015620011a557600080fd5b505af1158015620011ba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620011e0919062002775565b506060840151602085015160405163095ea7b360e01b81526001600160a01b038681166004830152602482019290925291169063095ea7b390604401602060405180830381600087803b1580156200123757600080fd5b505af11580156200124c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001272919062002775565b50606084015160208501516040516319c5aef560e11b81526001600160a01b0384169263338b5dea92620012bc926004016001600160a01b03929092168252602082015260400190565b600060405180830381600087803b158015620012d757600080fd5b505af1158015620012ec573d6000803e3d6000fd5b50505050620015b2565b6001845160028111156200130e576200130e620022f7565b14156200143a57606084015160408086015190516323b872dd60e01b81526001600160a01b03858116600483015230602483015260448201929092529116906323b872dd90606401600060405180830381600087803b1580156200137157600080fd5b505af115801562001386573d6000803e3d6000fd5b5050506060850151604080870151905163095ea7b360e01b81526001600160a01b03878116600483015260248201929092529116915063095ea7b390604401600060405180830381600087803b158015620013e057600080fd5b505af1158015620013f5573d6000803e3d6000fd5b50505050806001600160a01b031663f20c929660018660600151876020015188604001516040518563ffffffff1660e01b8152600401620012bc9493929190620027e7565b600284516002811115620014525762001452620022f7565b1415620015b257606084606001516001600160a01b031663f242432a843088604001518960200151866040518663ffffffff1660e01b81526004016200149d9594939291906200286b565b600060405180830381600087803b158015620014b857600080fd5b505af1158015620014cd573d6000803e3d6000fd5b505050606086015160405163a22cb46560e01b81526001600160a01b03878116600483015260016024830152909116915063a22cb46590604401600060405180830381600087803b1580156200152257600080fd5b505af115801562001537573d6000803e3d6000fd5b50505050816001600160a01b031663f20c929660028760600151886020015189604001516040518563ffffffff1660e01b81526004016200157c9493929190620027e7565b600060405180830381600087803b1580156200159757600080fd5b505af1158015620015ac573d6000803e3d6000fd5b50505050505b7f1a7f128dbc559fb97831b7681dee32957c2917e95d1c5070da20fb89e91f9d7a858560000151866060015187602001518860400151604051620015fb959493929190620028b2565b60405180910390a15050505050565b6065546001600160a01b0316336001600160a01b031614620016675760405162461bcd60e51b815260206004820152601560248201527414d95b99195c881b9bdd08185d5d1a1bdc9a5e9959605a1b604482015260640162000908565b620016728262000678565b15620007c957606554604051635fbbffd760e11b8152600481018490526000916001600160a01b03169063bf77ffae9060240160206040518083038186803b158015620016be57600080fd5b505afa158015620016d3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620016f9919062002752565b90506005816005811115620017125762001712620022f7565b14620017615760405162461bcd60e51b815260206004820152601c60248201527f4c6f616e20686173206e6f74206265656e206c69717569646174656400000000604482015260640162000908565b62000a138383620018e5565b6200177762001ab4565b6001600160a01b038116620017de5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840162000908565b62000e258162001b10565b600082815260686020526040902060608201516200180990829062001fce565b5060608201516001600160a01b0316600090815260028083016020526040909120835181548593839160ff19169060019084908111156200184e576200184e620022f7565b021790555060208281015160018301556040808401516002840155606093840151600390930180546001600160a01b0319166001600160a01b0390941693909317909255845192850151908501518583015192517e31b4b6dbbe7e196215f0ee8d3bfca5460603ecaf2d16df68b990ceb382a1169462000a0a94899491939192620028b2565b6000620018df825490565b92915050565b60005b60008381526068602052604090206200190190620018d4565b81101562000a13576000838152606860205260408120600281019082906200192a908562001faa565b6001600160a01b03908116825260208083019390935260409182016000908120888252606790945282902054600384015460018501549351631a4ca37b60e21b815290831660048201526024810193909352868216604484015292935091909116906369328dec90606401600060405180830381600087803b158015620019b057600080fd5b505af1158015620019c5573d6000803e3d6000fd5b505082546003840154600185015460028601546040517f07bdd340c9eda3c1144c9d4d69713c05145dbdf05896acbd3e7d82766de138dd965062001a1e95508a9460ff16936001600160a01b03169291908a90620028ed565b60405180910390a1508062001a338162002728565b915050620018e8565b600054610100900460ff1662001aa95760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840162000908565b62000adf3362001b10565b6033546001600160a01b0316331462000adf5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000908565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516000908181600281111562001b7d5762001b7d620022f7565b141562001c185760608301516040516370a0823160e01b81526001600160a01b038681166004830152909116906370a08231906024015b60206040518083038186803b15801562001bcd57600080fd5b505afa15801562001be2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001c08919062002935565b83602001511115915050620018df565b600181600281111562001c2f5762001c2f620022f7565b141562001cde5782606001516001600160a01b0316636352211e84604001516040518263ffffffff1660e01b815260040162001c6d91815260200190565b60206040518083038186803b15801562001c8657600080fd5b505afa15801562001c9b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001cc19190620026d3565b6001600160a01b0316846001600160a01b031614915050620018df565b600281600281111562001cf55762001cf5620022f7565b141562001d3b5760608301516040808501519051627eeac760e11b81526001600160a01b038781166004830152602482019290925291169062fdd58e9060440162001bb4565b5060009392505050565b60006060835167ffffffffffffffff81111562001d665762001d6662002579565b60405190808252806020026020018201604052801562001d90578160200160208202803683370190505b5090506001915060005b845181101562001e2557600062001dce8787848151811062001dc05762001dc0620026f3565b602002602001015162001b62565b90508083838151811062001de65762001de6620026f3565b911515602092830291909101909101528062001e0f5760009350841562001e0f575050620010b8565b508062001e1c8162002728565b91505062001d9a565b50935093915050565b600081815260676020526040808220546065549151633ef0a2f760e01b8152600481018590526001600160a01b0391821693929190911690633ef0a2f79060240160206040518083038186803b15801562001e8857600080fd5b505afa15801562001e9d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001ec39190620026d3565b90506001600160a01b03821662001fa5576001600160a01b03811662001f215760405162461bcd60e51b8152602060048201526012602482015271109a5908191bd95cc81b9bdd08195e1a5cdd60721b604482015260640162000908565b60665460408051602480820187905282518083039091018152604490910182526020810180516001600160e01b031663fe4b84df60e01b17905290516000926001600160a01b0316919062001f7690620020c2565b62001f839291906200294f565b604051809103906000f08015801562001fa0573d6000803e3d6000fd5b509250505b915091565b600062001fb8838362001fe5565b9392505050565b6060600062001fb88362002012565b600062001fb8836001600160a01b03841662002070565b600082600001828154811062001fff5762001fff620026f3565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156200206457602002820191906000526020600020905b8154815260200190600101908083116200204f575b50505050509050919050565b6000818152600183016020526040812054620020b957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620018df565b506000620018df565b61093b806200297e83390190565b600060208284031215620020e357600080fd5b5035919050565b6001600160a01b038116811462000e2557600080fd5b60008083601f8401126200211357600080fd5b50813567ffffffffffffffff8111156200212c57600080fd5b6020830191508360208285010111156200214557600080fd5b9250929050565b6000806000806000608086880312156200216557600080fd5b85356200217281620020ea565b945060208601356200218481620020ea565b935060408601359250606086013567ffffffffffffffff811115620021a857600080fd5b620021b68882890162002100565b969995985093965092949392505050565b60008083601f840112620021da57600080fd5b50813567ffffffffffffffff811115620021f357600080fd5b6020830191508360208260071b85010111156200214557600080fd5b6000806000604084860312156200222557600080fd5b83359250602084013567ffffffffffffffff8111156200224457600080fd5b6200225286828701620021c7565b9497909650939450505050565b600080604083850312156200227357600080fd5b82356200228081620020ea565b915060208301356200229281620020ea565b809150509250929050565b600060208284031215620022b057600080fd5b813562001fb881620020ea565b60008082840360a0811215620022d257600080fd5b833592506080601f1982011215620022e957600080fd5b506020830190509250929050565b634e487b7160e01b600052602160045260246000fd5b600381106200232c57634e487b7160e01b600052602160045260246000fd5b9052565b602080825282518282018190526000919060409081850190868401855b828110156200239b578151620023658582516200230d565b808701518588015285810151868601526060908101516001600160a01b031690850152608090930192908501906001016200234d565b5091979650505050505050565b60008083601f840112620023bb57600080fd5b50813567ffffffffffffffff811115620023d457600080fd5b6020830191508360208260051b85010111156200214557600080fd5b60008060008060008060008060a0898b0312156200240d57600080fd5b88356200241a81620020ea565b975060208901356200242c81620020ea565b9650604089013567ffffffffffffffff808211156200244a57600080fd5b620024588c838d01620023a8565b909850965060608b01359150808211156200247257600080fd5b620024808c838d01620023a8565b909650945060808b01359150808211156200249a57600080fd5b50620024a98b828c0162002100565b999c989b5096995094979396929594505050565b60008060408385031215620024d157600080fd5b8235915060208301356200229281620020ea565b600080600060408486031215620024fb57600080fd5b83356200250881620020ea565b9250602084013567ffffffffffffffff8111156200224457600080fd5b60006040820184151583526020604081850152818551808452606086019150828701935060005b818110156200256c5784511515835293830193918301916001016200254c565b5090979650505050505050565b634e487b7160e01b600052604160045260246000fd5b600060808284031215620025a257600080fd5b6040516080810181811067ffffffffffffffff82111715620025d457634e487b7160e01b600052604160045260246000fd5b604052905080823560038110620025ea57600080fd5b80825250602083013560208201526040830135604082015260608301356200261281620020ea565b6060919091015292915050565b60008060a083850312156200263357600080fd5b823591506200264684602085016200258f565b90509250929050565b60008060008060008060a087890312156200266957600080fd5b86356200267681620020ea565b955060208701356200268881620020ea565b94506040870135935060608701359250608087013567ffffffffffffffff811115620026b357600080fd5b620026c189828a0162002100565b979a9699509497509295939492505050565b600060208284031215620026e657600080fd5b815162001fb881620020ea565b634e487b7160e01b600052603260045260246000fd5b6000608082840312156200271c57600080fd5b62001fb883836200258f565b60006000198214156200274b57634e487b7160e01b600052601160045260246000fd5b5060010190565b6000602082840312156200276557600080fd5b81516006811062001fb857600080fd5b6000602082840312156200278857600080fd5b8151801515811462001fb857600080fd5b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60808101620027f782876200230d565b6001600160a01b039490941660208201526040810192909252606090910152919050565b6000815180845260005b81811015620028435760208185018101518683018201520162002825565b8181111562002856576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090620028a7908301846200281b565b979650505050505050565b85815260a08101620028c860208301876200230d565b6001600160a01b03949094166040820152606081019290925260809091015292915050565b86815260c081016200290360208301886200230d565b6001600160a01b0395861660408301526060820194909452608081019290925290921660a09092019190915292915050565b6000602082840312156200294857600080fd5b5051919050565b6001600160a01b038316815260406020820181905260009062002975908301846200281b565b94935050505056fe608060405260405161093b38038061093b8339810160408190526100229161047e565b61002e82826000610035565b50506105a8565b61003e8361010f565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a260008251118061007f5750805b1561010a57610108836001600160a01b0316635c60da1b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100c057600080fd5b505afa1580156100d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100f8919061053e565b836102c160201b6100291760201c565b505b505050565b610122816102ed60201b6100551760201c565b6101815760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b610204816001600160a01b0316635c60da1b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156101bd57600080fd5b505afa1580156101d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101f5919061053e565b6102ed60201b6100551760201c565b6102695760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401610178565b806102a07fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5060001b6102fc60201b6100641760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606102e68383604051806060016040528060278152602001610914602791396102ff565b9392505050565b6001600160a01b03163b151590565b90565b6060600080856001600160a01b03168560405161031c9190610559565b600060405180830381855af49150503d8060008114610357576040519150601f19603f3d011682016040523d82523d6000602084013e61035c565b606091505b50909250905061036e86838387610378565b9695505050505050565b606083156103e45782516103dd576001600160a01b0385163b6103dd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610178565b50816103ee565b6103ee83836103f6565b949350505050565b8151156104065781518083602001fd5b8060405162461bcd60e51b81526004016101789190610575565b80516001600160a01b038116811461043757600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561046d578181015183820152602001610455565b838111156101085750506000910152565b6000806040838503121561049157600080fd5b61049a83610420565b60208401519092506001600160401b03808211156104b757600080fd5b818501915085601f8301126104cb57600080fd5b8151818111156104dd576104dd61043c565b604051601f8201601f19908116603f011681019083821181831017156105055761050561043c565b8160405282815288602084870101111561051e57600080fd5b61052f836020830160208801610452565b80955050505050509250929050565b60006020828403121561055057600080fd5b6102e682610420565b6000825161056b818460208701610452565b9190910192915050565b6020815260008251806020840152610594816040850160208701610452565b601f01601f19169190910160400192915050565b61035d806105b76000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610067565b61010f565b565b606061004e838360405180606001604052806027815260200161030160279139610133565b9392505050565b6001600160a01b03163b151590565b90565b600061009a7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50546001600160a01b031690565b6001600160a01b0316635c60da1b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100d257600080fd5b505afa1580156100e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061010a9190610258565b905090565b3660008037600080366000845af43d6000803e80801561012e573d6000f35b3d6000fd5b6060600080856001600160a01b03168560405161015091906102b1565b600060405180830381855af49150503d806000811461018b576040519150601f19603f3d011682016040523d82523d6000602084013e610190565b606091505b50915091506101a1868383876101ab565b9695505050505050565b6060831561021c578251610215576001600160a01b0385163b6102155760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610226565b610226838361022e565b949350505050565b81511561023e5781518083602001fd5b8060405162461bcd60e51b815260040161020c91906102cd565b60006020828403121561026a57600080fd5b81516001600160a01b038116811461004e57600080fd5b60005b8381101561029c578181015183820152602001610284565b838111156102ab576000848401525b50505050565b600082516102c3818460208701610281565b9190910192915050565b60208152600082518060208401526102ec816040850160208701610281565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122008e3e42bc0d525e25f65a02e5f2cbfc4108e5b6fca182c0ce53daa9db213f98364736f6c63430008090033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a69b8e89678d9d855111fc5ec6d3a38fd812f449abf9a5a069646034639d45d264736f6c63430008090033", "deployedBytecode": "0x6080604052600436106200014e5760003560e01c80638da5cb5b11620000b9578063cd98536b1162000078578063cd98536b1462000435578063d6c20fa81462000491578063e4ad84b414620004c6578063f0472c4914620004dd578063f23a6e611462000502578063f2fde38b146200054c57600080fd5b80638da5cb5b14620003755780638de161161462000395578063934b5d1314620003ba578063941675db14620003ee578063bc197c81146200041057600080fd5b8063485cc9551162000112578063485cc955146200028f5780635289fe9314620002b4578063715018a614620002d95780637d19e59614620002f1578063853c488d146200032b578063857919de146200035057600080fd5b806294f1e91462000153578063150b7a0214620001aa5780631532dc45146200020d578063251befba14620002435780632e1a7d4d1462000268575b600080fd5b3480156200016057600080fd5b506200018d62000172366004620020d0565b6067602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b348015620001b757600080fd5b50620001f3620001c93660046200214c565b7f150b7a023d4804d13e8c85fb27262cb750cf6ba9f9dd3bb30d90f482ceeb4b1f95945050505050565b6040516001600160e01b03199091168152602001620001a1565b3480156200021a57600080fd5b50620002326200022c3660046200220f565b62000571565b6040519015158152602001620001a1565b3480156200025057600080fd5b506200023262000262366004620020d0565b62000678565b3480156200027557600080fd5b506200028d62000287366004620020d0565b6200069a565b005b3480156200029c57600080fd5b506200028d620002ae3660046200225f565b62000911565b348015620002c157600080fd5b506200028d620002d33660046200229d565b62000a18565b348015620002e657600080fd5b506200028d62000ac9565b348015620002fe57600080fd5b506200018d62000310366004620020d0565b6000908152606760205260409020546001600160a01b031690565b3480156200033857600080fd5b50620002326200034a366004620022bd565b62000ae1565b3480156200035d57600080fd5b50620002326200036f366004620020d0565b62000bb0565b3480156200038257600080fd5b506033546001600160a01b03166200018d565b348015620003a257600080fd5b506200028d620003b4366004620020d0565b62000c5d565b348015620003c757600080fd5b50620003df620003d9366004620020d0565b62000e28565b604051620001a1919062002330565b348015620003fb57600080fd5b506065546200018d906001600160a01b031681565b3480156200041d57600080fd5b50620001f36200042f366004620023f0565b62000faa565b3480156200044257600080fd5b506200048262000454366004620024bd565b60009182526068602090815260408084206001600160a01b0390931684526002909201905290206001015490565b604051908152602001620001a1565b3480156200049e57600080fd5b50620004b6620004b0366004620024e5565b6200104b565b604051620001a192919062002525565b6200028d620004d73660046200261f565b620010c0565b348015620004ea57600080fd5b506200028d620004fc366004620024bd565b6200160a565b3480156200050f57600080fd5b50620001f3620005213660046200264f565b7ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf979695505050505050565b3480156200055957600080fd5b506200028d6200056b3660046200229d565b6200176d565b606554604051633ef0a2f760e01b81526004810185905260009182916001600160a01b0390911690633ef0a2f79060240160206040518083038186803b158015620005bb57600080fd5b505afa158015620005d0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005f69190620026d3565b9050620006058185856200104b565b5091508115620006705760005b838110156200066e576000858583818110620006325762000632620026f3565b9050608002018036038101906200064a919062002709565b9050620006588782620017e9565b5080620006658162002728565b91505062000612565b505b509392505050565b600081815260686020526040812081906200069390620018d4565b1192915050565b606554604051635fbbffd760e11b8152600481018390526000916001600160a01b03169063bf77ffae9060240160206040518083038186803b158015620006e057600080fd5b505afa158015620006f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200071b919062002752565b90506004816005811115620007345762000734620022f7565b1415620007cd57606554604051633ef0a2f760e01b815260048101849052620007c99184916001600160a01b0390911690633ef0a2f7906024015b60206040518083038186803b1580156200078857600080fd5b505afa1580156200079d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007c39190620026d3565b620018e5565b5050565b60655460405163e8cbab0960e01b8152600481018490526001600160a01b039091169063e8cbab099060240160206040518083038186803b1580156200081257600080fd5b505afa15801562000827573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200084d919062002775565b15620008c45760655460405163508482f560e11b8152600481018490526200088c9184916001600160a01b039091169063a10905ea906024016200076f565b6040518281527fd951b721f993d3959dc31ba5a751da7974aa23a2c46f52fc71c9ba9d1675b8e4906020015b60405180910390a15050565b60405162461bcd60e51b815260206004820152601e60248201527f636f6c6c61746572616c2063616e6e6f742062652077697468647261776e000060448201526064015b60405180910390fd5b600054610100900460ff1615808015620009325750600054600160ff909116105b806200094e5750303b1580156200094e575060005460ff166001145b6200096d5760405162461bcd60e51b8152600401620009089062002799565b6000805460ff19166001179055801562000991576000805461ff0019166101001790555b606680546001600160a01b038086166001600160a01b0319928316179092556065805492851692909116919091179055620009cb62001a3c565b801562000a13576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b505050565b600054600290610100900460ff1615801562000a3b575060005460ff8083169116105b62000a5a5760405162461bcd60e51b8152600401620009089062002799565b60008054606680546001600160a01b0319166001600160a01b03861617905561ff001961010060ff851661ffff19909316831717169091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b62000ad362001ab4565b62000adf600062001b10565b565b606554604051633ef0a2f760e01b81526004810184905260009182916001600160a01b0390911690633ef0a2f79060240160206040518083038186803b15801562000b2b57600080fd5b505afa15801562000b40573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b669190620026d3565b905062000b848162000b7e3686900386018662002709565b62001b62565b9150811562000ba95762000ba98462000ba33686900386018662002709565b620017e9565b5092915050565b60008062000bbe8362000e28565b606554604051633ef0a2f760e01b8152600481018690529192506000916001600160a01b0390911690633ef0a2f79060240160206040518083038186803b15801562000c0957600080fd5b505afa15801562000c1e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c449190620026d3565b905062000c548183600162001d45565b50949350505050565b6065546001600160a01b0316336001600160a01b03161462000cba5760405162461bcd60e51b815260206004820152601560248201527414d95b99195c881b9bdd08185d5d1a1bdc9a5e9959605a1b604482015260640162000908565b62000cc58162000678565b1562000e2557600062000cd88262001e2e565b50600083815260676020526040812080546001600160a01b0319166001600160a01b0384161790559091505b600083815260686020526040902062000d1d90620018d4565b81101562000de557600083815260686020526040812062000dd091859160028101919062000d4c908662001faa565b6001600160a01b03168152602081019190915260409081016000208151608081019092528054829060ff16600281111562000d8b5762000d8b620022f7565b600281111562000d9f5762000d9f620022f7565b815260018201546020820152600282015460408201526003909101546001600160a01b0316606090910152620010c0565b8062000ddc8162002728565b91505062000d04565b50604080518381526001600160a01b03831660208201527fc201bfb915e3eed80ff17e013f3d88db1c51ac7fc12728fce91a2afc659128ef9101620008b8565b50565b600081815260686020526040812060609162000e448262001fbf565b9050805167ffffffffffffffff81111562000e635762000e6362002579565b60405190808252806020026020018201604052801562000eb757816020015b60408051608081018252600080825260208083018290529282018190526060820152825260001990920191018162000e825790505b50925060005b815181101562000fa25782600201600083838151811062000ee25762000ee2620026f3565b6020908102919091018101516001600160a01b0316825281019190915260409081016000208151608081019092528054829060ff16600281111562000f2b5762000f2b620022f7565b600281111562000f3f5762000f3f620022f7565b815260018201546020820152600282015460408201526003909101546001600160a01b0316606090910152845185908390811062000f815762000f81620026f3565b6020026020010181905250808062000f999062002728565b91505062000ebd565b505050919050565b6000600186146200101d5760405162461bcd60e51b815260206004820152603660248201527f4f6e6c7920616c6c6f776564206f6e65206173736574206261746368207472616044820152753739b332b9103832b9103a3930b739b0b1ba34b7b71760511b606482015260840162000908565b507fbc197c819b3e337a6f9652dd10becd7eef83032af3b9d958d3d42f669414662198975050505050505050565b60006060620010b3858585808060200260200160405190810160405280939291908181526020016000905b82821015620010a657620010966080830286013681900381019062002709565b8152602001906001019062001076565b5050505050600062001d45565b915091505b935093915050565b6000816020015111620011165760405162461bcd60e51b815260206004820152601860248201527f436f6c6c61746572616c206e6f742076616c6964617465640000000000000000604482015260640162000908565b600080620011248462001e2e565b909250905081600084516002811115620011425762001142620022f7565b1415620012f657606084015160208501516040516323b872dd60e01b81526001600160a01b03858116600483015230602483015260448201929092529116906323b872dd90606401602060405180830381600087803b158015620011a557600080fd5b505af1158015620011ba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620011e0919062002775565b506060840151602085015160405163095ea7b360e01b81526001600160a01b038681166004830152602482019290925291169063095ea7b390604401602060405180830381600087803b1580156200123757600080fd5b505af11580156200124c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001272919062002775565b50606084015160208501516040516319c5aef560e11b81526001600160a01b0384169263338b5dea92620012bc926004016001600160a01b03929092168252602082015260400190565b600060405180830381600087803b158015620012d757600080fd5b505af1158015620012ec573d6000803e3d6000fd5b50505050620015b2565b6001845160028111156200130e576200130e620022f7565b14156200143a57606084015160408086015190516323b872dd60e01b81526001600160a01b03858116600483015230602483015260448201929092529116906323b872dd90606401600060405180830381600087803b1580156200137157600080fd5b505af115801562001386573d6000803e3d6000fd5b5050506060850151604080870151905163095ea7b360e01b81526001600160a01b03878116600483015260248201929092529116915063095ea7b390604401600060405180830381600087803b158015620013e057600080fd5b505af1158015620013f5573d6000803e3d6000fd5b50505050806001600160a01b031663f20c929660018660600151876020015188604001516040518563ffffffff1660e01b8152600401620012bc9493929190620027e7565b600284516002811115620014525762001452620022f7565b1415620015b257606084606001516001600160a01b031663f242432a843088604001518960200151866040518663ffffffff1660e01b81526004016200149d9594939291906200286b565b600060405180830381600087803b158015620014b857600080fd5b505af1158015620014cd573d6000803e3d6000fd5b505050606086015160405163a22cb46560e01b81526001600160a01b03878116600483015260016024830152909116915063a22cb46590604401600060405180830381600087803b1580156200152257600080fd5b505af115801562001537573d6000803e3d6000fd5b50505050816001600160a01b031663f20c929660028760600151886020015189604001516040518563ffffffff1660e01b81526004016200157c9493929190620027e7565b600060405180830381600087803b1580156200159757600080fd5b505af1158015620015ac573d6000803e3d6000fd5b50505050505b7f1a7f128dbc559fb97831b7681dee32957c2917e95d1c5070da20fb89e91f9d7a858560000151866060015187602001518860400151604051620015fb959493929190620028b2565b60405180910390a15050505050565b6065546001600160a01b0316336001600160a01b031614620016675760405162461bcd60e51b815260206004820152601560248201527414d95b99195c881b9bdd08185d5d1a1bdc9a5e9959605a1b604482015260640162000908565b620016728262000678565b15620007c957606554604051635fbbffd760e11b8152600481018490526000916001600160a01b03169063bf77ffae9060240160206040518083038186803b158015620016be57600080fd5b505afa158015620016d3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620016f9919062002752565b90506005816005811115620017125762001712620022f7565b14620017615760405162461bcd60e51b815260206004820152601c60248201527f4c6f616e20686173206e6f74206265656e206c69717569646174656400000000604482015260640162000908565b62000a138383620018e5565b6200177762001ab4565b6001600160a01b038116620017de5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840162000908565b62000e258162001b10565b600082815260686020526040902060608201516200180990829062001fce565b5060608201516001600160a01b0316600090815260028083016020526040909120835181548593839160ff19169060019084908111156200184e576200184e620022f7565b021790555060208281015160018301556040808401516002840155606093840151600390930180546001600160a01b0319166001600160a01b0390941693909317909255845192850151908501518583015192517e31b4b6dbbe7e196215f0ee8d3bfca5460603ecaf2d16df68b990ceb382a1169462000a0a94899491939192620028b2565b6000620018df825490565b92915050565b60005b60008381526068602052604090206200190190620018d4565b81101562000a13576000838152606860205260408120600281019082906200192a908562001faa565b6001600160a01b03908116825260208083019390935260409182016000908120888252606790945282902054600384015460018501549351631a4ca37b60e21b815290831660048201526024810193909352868216604484015292935091909116906369328dec90606401600060405180830381600087803b158015620019b057600080fd5b505af1158015620019c5573d6000803e3d6000fd5b505082546003840154600185015460028601546040517f07bdd340c9eda3c1144c9d4d69713c05145dbdf05896acbd3e7d82766de138dd965062001a1e95508a9460ff16936001600160a01b03169291908a90620028ed565b60405180910390a1508062001a338162002728565b915050620018e8565b600054610100900460ff1662001aa95760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840162000908565b62000adf3362001b10565b6033546001600160a01b0316331462000adf5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000908565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516000908181600281111562001b7d5762001b7d620022f7565b141562001c185760608301516040516370a0823160e01b81526001600160a01b038681166004830152909116906370a08231906024015b60206040518083038186803b15801562001bcd57600080fd5b505afa15801562001be2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001c08919062002935565b83602001511115915050620018df565b600181600281111562001c2f5762001c2f620022f7565b141562001cde5782606001516001600160a01b0316636352211e84604001516040518263ffffffff1660e01b815260040162001c6d91815260200190565b60206040518083038186803b15801562001c8657600080fd5b505afa15801562001c9b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001cc19190620026d3565b6001600160a01b0316846001600160a01b031614915050620018df565b600281600281111562001cf55762001cf5620022f7565b141562001d3b5760608301516040808501519051627eeac760e11b81526001600160a01b038781166004830152602482019290925291169062fdd58e9060440162001bb4565b5060009392505050565b60006060835167ffffffffffffffff81111562001d665762001d6662002579565b60405190808252806020026020018201604052801562001d90578160200160208202803683370190505b5090506001915060005b845181101562001e2557600062001dce8787848151811062001dc05762001dc0620026f3565b602002602001015162001b62565b90508083838151811062001de65762001de6620026f3565b911515602092830291909101909101528062001e0f5760009350841562001e0f575050620010b8565b508062001e1c8162002728565b91505062001d9a565b50935093915050565b600081815260676020526040808220546065549151633ef0a2f760e01b8152600481018590526001600160a01b0391821693929190911690633ef0a2f79060240160206040518083038186803b15801562001e8857600080fd5b505afa15801562001e9d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001ec39190620026d3565b90506001600160a01b03821662001fa5576001600160a01b03811662001f215760405162461bcd60e51b8152602060048201526012602482015271109a5908191bd95cc81b9bdd08195e1a5cdd60721b604482015260640162000908565b60665460408051602480820187905282518083039091018152604490910182526020810180516001600160e01b031663fe4b84df60e01b17905290516000926001600160a01b0316919062001f7690620020c2565b62001f839291906200294f565b604051809103906000f08015801562001fa0573d6000803e3d6000fd5b509250505b915091565b600062001fb8838362001fe5565b9392505050565b6060600062001fb88362002012565b600062001fb8836001600160a01b03841662002070565b600082600001828154811062001fff5762001fff620026f3565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156200206457602002820191906000526020600020905b8154815260200190600101908083116200204f575b50505050509050919050565b6000818152600183016020526040812054620020b957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620018df565b506000620018df565b61093b806200297e83390190565b600060208284031215620020e357600080fd5b5035919050565b6001600160a01b038116811462000e2557600080fd5b60008083601f8401126200211357600080fd5b50813567ffffffffffffffff8111156200212c57600080fd5b6020830191508360208285010111156200214557600080fd5b9250929050565b6000806000806000608086880312156200216557600080fd5b85356200217281620020ea565b945060208601356200218481620020ea565b935060408601359250606086013567ffffffffffffffff811115620021a857600080fd5b620021b68882890162002100565b969995985093965092949392505050565b60008083601f840112620021da57600080fd5b50813567ffffffffffffffff811115620021f357600080fd5b6020830191508360208260071b85010111156200214557600080fd5b6000806000604084860312156200222557600080fd5b83359250602084013567ffffffffffffffff8111156200224457600080fd5b6200225286828701620021c7565b9497909650939450505050565b600080604083850312156200227357600080fd5b82356200228081620020ea565b915060208301356200229281620020ea565b809150509250929050565b600060208284031215620022b057600080fd5b813562001fb881620020ea565b60008082840360a0811215620022d257600080fd5b833592506080601f1982011215620022e957600080fd5b506020830190509250929050565b634e487b7160e01b600052602160045260246000fd5b600381106200232c57634e487b7160e01b600052602160045260246000fd5b9052565b602080825282518282018190526000919060409081850190868401855b828110156200239b578151620023658582516200230d565b808701518588015285810151868601526060908101516001600160a01b031690850152608090930192908501906001016200234d565b5091979650505050505050565b60008083601f840112620023bb57600080fd5b50813567ffffffffffffffff811115620023d457600080fd5b6020830191508360208260051b85010111156200214557600080fd5b60008060008060008060008060a0898b0312156200240d57600080fd5b88356200241a81620020ea565b975060208901356200242c81620020ea565b9650604089013567ffffffffffffffff808211156200244a57600080fd5b620024588c838d01620023a8565b909850965060608b01359150808211156200247257600080fd5b620024808c838d01620023a8565b909650945060808b01359150808211156200249a57600080fd5b50620024a98b828c0162002100565b999c989b5096995094979396929594505050565b60008060408385031215620024d157600080fd5b8235915060208301356200229281620020ea565b600080600060408486031215620024fb57600080fd5b83356200250881620020ea565b9250602084013567ffffffffffffffff8111156200224457600080fd5b60006040820184151583526020604081850152818551808452606086019150828701935060005b818110156200256c5784511515835293830193918301916001016200254c565b5090979650505050505050565b634e487b7160e01b600052604160045260246000fd5b600060808284031215620025a257600080fd5b6040516080810181811067ffffffffffffffff82111715620025d457634e487b7160e01b600052604160045260246000fd5b604052905080823560038110620025ea57600080fd5b80825250602083013560208201526040830135604082015260608301356200261281620020ea565b6060919091015292915050565b60008060a083850312156200263357600080fd5b823591506200264684602085016200258f565b90509250929050565b60008060008060008060a087890312156200266957600080fd5b86356200267681620020ea565b955060208701356200268881620020ea565b94506040870135935060608701359250608087013567ffffffffffffffff811115620026b357600080fd5b620026c189828a0162002100565b979a9699509497509295939492505050565b600060208284031215620026e657600080fd5b815162001fb881620020ea565b634e487b7160e01b600052603260045260246000fd5b6000608082840312156200271c57600080fd5b62001fb883836200258f565b60006000198214156200274b57634e487b7160e01b600052601160045260246000fd5b5060010190565b6000602082840312156200276557600080fd5b81516006811062001fb857600080fd5b6000602082840312156200278857600080fd5b8151801515811462001fb857600080fd5b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60808101620027f782876200230d565b6001600160a01b039490941660208201526040810192909252606090910152919050565b6000815180845260005b81811015620028435760208185018101518683018201520162002825565b8181111562002856576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090620028a7908301846200281b565b979650505050505050565b85815260a08101620028c860208301876200230d565b6001600160a01b03949094166040820152606081019290925260809091015292915050565b86815260c081016200290360208301886200230d565b6001600160a01b0395861660408301526060820194909452608081019290925290921660a09092019190915292915050565b6000602082840312156200294857600080fd5b5051919050565b6001600160a01b038316815260406020820181905260009062002975908301846200281b565b94935050505056fe608060405260405161093b38038061093b8339810160408190526100229161047e565b61002e82826000610035565b50506105a8565b61003e8361010f565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a260008251118061007f5750805b1561010a57610108836001600160a01b0316635c60da1b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100c057600080fd5b505afa1580156100d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100f8919061053e565b836102c160201b6100291760201c565b505b505050565b610122816102ed60201b6100551760201c565b6101815760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b610204816001600160a01b0316635c60da1b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156101bd57600080fd5b505afa1580156101d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101f5919061053e565b6102ed60201b6100551760201c565b6102695760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401610178565b806102a07fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5060001b6102fc60201b6100641760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b60606102e68383604051806060016040528060278152602001610914602791396102ff565b9392505050565b6001600160a01b03163b151590565b90565b6060600080856001600160a01b03168560405161031c9190610559565b600060405180830381855af49150503d8060008114610357576040519150601f19603f3d011682016040523d82523d6000602084013e61035c565b606091505b50909250905061036e86838387610378565b9695505050505050565b606083156103e45782516103dd576001600160a01b0385163b6103dd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610178565b50816103ee565b6103ee83836103f6565b949350505050565b8151156104065781518083602001fd5b8060405162461bcd60e51b81526004016101789190610575565b80516001600160a01b038116811461043757600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561046d578181015183820152602001610455565b838111156101085750506000910152565b6000806040838503121561049157600080fd5b61049a83610420565b60208401519092506001600160401b03808211156104b757600080fd5b818501915085601f8301126104cb57600080fd5b8151818111156104dd576104dd61043c565b604051601f8201601f19908116603f011681019083821181831017156105055761050561043c565b8160405282815288602084870101111561051e57600080fd5b61052f836020830160208801610452565b80955050505050509250929050565b60006020828403121561055057600080fd5b6102e682610420565b6000825161056b818460208701610452565b9190910192915050565b6020815260008251806020840152610594816040850160208701610452565b601f01601f19169190910160400192915050565b61035d806105b76000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610067565b61010f565b565b606061004e838360405180606001604052806027815260200161030160279139610133565b9392505050565b6001600160a01b03163b151590565b90565b600061009a7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50546001600160a01b031690565b6001600160a01b0316635c60da1b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100d257600080fd5b505afa1580156100e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061010a9190610258565b905090565b3660008037600080366000845af43d6000803e80801561012e573d6000f35b3d6000fd5b6060600080856001600160a01b03168560405161015091906102b1565b600060405180830381855af49150503d806000811461018b576040519150601f19603f3d011682016040523d82523d6000602084013e610190565b606091505b50915091506101a1868383876101ab565b9695505050505050565b6060831561021c578251610215576001600160a01b0385163b6102155760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610226565b610226838361022e565b949350505050565b81511561023e5781518083602001fd5b8060405162461bcd60e51b815260040161020c91906102cd565b60006020828403121561026a57600080fd5b81516001600160a01b038116811461004e57600080fd5b60005b8381101561029c578181015183820152602001610284565b838111156102ab576000848401525b50505050565b600082516102c3818460208701610281565b9190910192915050565b60208152600082518060208401526102ec816040850160208701610281565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122008e3e42bc0d525e25f65a02e5f2cbfc4108e5b6fca182c0ce53daa9db213f98364736f6c63430008090033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a69b8e89678d9d855111fc5ec6d3a38fd812f449abf9a5a069646034639d45d264736f6c63430008090033", @@ -911,7 +911,7 @@ "storageLayout": { "storage": [ { - "astId": 138, + "astId": 326, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_initialized", "offset": 0, @@ -919,7 +919,7 @@ "type": "t_uint8" }, { - "astId": 141, + "astId": 329, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_initializing", "offset": 1, @@ -927,7 +927,7 @@ "type": "t_bool" }, { - "astId": 2108, + "astId": 2613, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "__gap", "offset": 0, @@ -951,15 +951,15 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 9219, + "astId": 12960, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "tellerV2", "offset": 0, "slot": "101", - "type": "t_contract(ITellerV2)19726" + "type": "t_contract(ITellerV2)24720" }, { - "astId": 9221, + "astId": 12962, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "collateralEscrowBeacon", "offset": 0, @@ -967,7 +967,7 @@ "type": "t_address" }, { - "astId": 9225, + "astId": 12966, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_escrows", "offset": 0, @@ -975,12 +975,12 @@ "type": "t_mapping(t_uint256,t_address)" }, { - "astId": 9230, + "astId": 12971, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_bidCollaterals", "offset": 0, "slot": "104", - "type": "t_mapping(t_uint256,t_struct(CollateralInfo)9239_storage)" + "type": "t_mapping(t_uint256,t_struct(CollateralInfo)12980_storage)" } ], "types": { @@ -1017,22 +1017,22 @@ "label": "bytes32", "numberOfBytes": "32" }, - "t_contract(ITellerV2)19726": { + "t_contract(ITellerV2)24720": { "encoding": "inplace", "label": "contract ITellerV2", "numberOfBytes": "20" }, - "t_enum(CollateralType)19759": { + "t_enum(CollateralType)25138": { "encoding": "inplace", "label": "enum CollateralType", "numberOfBytes": "1" }, - "t_mapping(t_address,t_struct(Collateral)19769_storage)": { + "t_mapping(t_address,t_struct(Collateral)25148_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct Collateral)", "numberOfBytes": "32", - "value": "t_struct(Collateral)19769_storage" + "value": "t_struct(Collateral)25148_storage" }, "t_mapping(t_bytes32,t_uint256)": { "encoding": "mapping", @@ -1048,42 +1048,42 @@ "numberOfBytes": "32", "value": "t_address" }, - "t_mapping(t_uint256,t_struct(CollateralInfo)9239_storage)": { + "t_mapping(t_uint256,t_struct(CollateralInfo)12980_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct CollateralManager.CollateralInfo)", "numberOfBytes": "32", - "value": "t_struct(CollateralInfo)9239_storage" + "value": "t_struct(CollateralInfo)12980_storage" }, - "t_struct(AddressSet)3531_storage": { + "t_struct(AddressSet)4547_storage": { "encoding": "inplace", "label": "struct EnumerableSetUpgradeable.AddressSet", "members": [ { - "astId": 3530, + "astId": 4546, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_inner", "offset": 0, "slot": "0", - "type": "t_struct(Set)3216_storage" + "type": "t_struct(Set)4232_storage" } ], "numberOfBytes": "64" }, - "t_struct(Collateral)19769_storage": { + "t_struct(Collateral)25148_storage": { "encoding": "inplace", "label": "struct Collateral", "members": [ { - "astId": 19762, + "astId": 25141, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_collateralType", "offset": 0, "slot": "0", - "type": "t_enum(CollateralType)19759" + "type": "t_enum(CollateralType)25138" }, { - "astId": 19764, + "astId": 25143, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_amount", "offset": 0, @@ -1091,7 +1091,7 @@ "type": "t_uint256" }, { - "astId": 19766, + "astId": 25145, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_tokenId", "offset": 0, @@ -1099,7 +1099,7 @@ "type": "t_uint256" }, { - "astId": 19768, + "astId": 25147, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_collateralAddress", "offset": 0, @@ -1109,35 +1109,35 @@ ], "numberOfBytes": "128" }, - "t_struct(CollateralInfo)9239_storage": { + "t_struct(CollateralInfo)12980_storage": { "encoding": "inplace", "label": "struct CollateralManager.CollateralInfo", "members": [ { - "astId": 9233, + "astId": 12974, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "collateralAddresses", "offset": 0, "slot": "0", - "type": "t_struct(AddressSet)3531_storage" + "type": "t_struct(AddressSet)4547_storage" }, { - "astId": 9238, + "astId": 12979, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "collateralInfo", "offset": 0, "slot": "2", - "type": "t_mapping(t_address,t_struct(Collateral)19769_storage)" + "type": "t_mapping(t_address,t_struct(Collateral)25148_storage)" } ], "numberOfBytes": "96" }, - "t_struct(Set)3216_storage": { + "t_struct(Set)4232_storage": { "encoding": "inplace", "label": "struct EnumerableSetUpgradeable.Set", "members": [ { - "astId": 3211, + "astId": 4227, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_values", "offset": 0, @@ -1145,7 +1145,7 @@ "type": "t_array(t_bytes32)dyn_storage" }, { - "astId": 3215, + "astId": 4231, "contract": "contracts/CollateralManager.sol:CollateralManager", "label": "_indexes", "offset": 0, diff --git a/packages/contracts/deployments/goerli/CollateralManager_Proxy.json b/packages/contracts/deployments/goerli/CollateralManager_Proxy.json index e4ae01fc7..1061adad1 100644 --- a/packages/contracts/deployments/goerli/CollateralManager_Proxy.json +++ b/packages/contracts/deployments/goerli/CollateralManager_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "abi": [ { "inputs": [ @@ -146,78 +146,78 @@ "type": "receive" } ], - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xD66de8b25C4165dA2e7696e15E8436380823B118", - "transactionIndex": 7, - "gasUsed": "815126", - "logsBloom": "0x00000000000000000000000000808000400000000000008000800000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000002000101000000000000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000000000000000008000000080000000000000800000000000000000000000000000000400000000000002000000000000000000000000000020000100000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000800000000000000000", - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb", - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", + "transactionIndex": 6, + "gasUsed": "815436", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000000000000000000000000000000000000000000000000000002000000000800000000000000000000200000002000001002000001000000000000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000004000000000000000000000000000080000000000000800000000000000000000000000000000400048000000000000000001000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c", + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", "logs": [ { - "transactionIndex": 7, - "blockNumber": 8538491, - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "transactionIndex": 6, + "blockNumber": 8689003, + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000001727add0680412e839c500cce4a2a20e3d96ff5c" + "0x000000000000000000000000c1bbf4dea9168e4949fc1d0aebe0fc51975c7b44" ], "data": "0x", "logIndex": 0, - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb" + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c" }, { - "transactionIndex": 7, - "blockNumber": 8538491, - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "transactionIndex": 6, + "blockNumber": 8689003, + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", "logIndex": 1, - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb" + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c" }, { - "transactionIndex": 7, - "blockNumber": 8538491, - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "transactionIndex": 6, + "blockNumber": 8689003, + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 2, - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb" + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c" }, { - "transactionIndex": 7, - "blockNumber": 8538491, - "transactionHash": "0xce9939b4ef707cb105805eb74cdef9c1815696b817811dcfcfdc06164ad07ee8", - "address": "0xD66de8b25C4165dA2e7696e15E8436380823B118", + "transactionIndex": 6, + "blockNumber": 8689003, + "transactionHash": "0x9cd2f327bd483fc2bce864a8f9f12b491d22b61d3b8de09e63cc4f170873e780", + "address": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 3, - "blockHash": "0x85ecff681ea8bf3802d3d28d182a7148496835fb1e3441d93cdcbd1bae80daeb" + "blockHash": "0x9a58b2f12acd461f951ec97a1b6d94fcad3beb85e95be99f495621c20994481c" } ], - "blockNumber": 8538491, - "cumulativeGasUsed": "962126", + "blockNumber": 8689003, + "cumulativeGasUsed": "968404", "status": 1, "byzantium": true }, "args": [ - "0x1727ADd0680412e839c500ccE4a2A20e3d96fF5C", - "0x5956c8158bde236d8e3638362ff7555C329A839B", - "0x485cc9550000000000000000000000005133d831f2d761e8d64953c489fab1395d91e7e8000000000000000000000000195c6608705546725df0629dd60690cf2b367734" + "0xC1bBF4dea9168e4949fc1D0aeBE0Fc51975C7B44", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0x485cc95500000000000000000000000049c97802a5d2598c1a4564eded553330bb85603c0000000000000000000000003a8c417a743a60ecff3988c34783d65362b62915" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", diff --git a/packages/contracts/deployments/goerli/DefaultProxyAdmin.json b/packages/contracts/deployments/goerli/DefaultProxyAdmin.json index 61eba36e9..9b152fdfe 100644 --- a/packages/contracts/deployments/goerli/DefaultProxyAdmin.json +++ b/packages/contracts/deployments/goerli/DefaultProxyAdmin.json @@ -1,5 +1,5 @@ { - "address": "0x5956c8158bde236d8e3638362ff7555C329A839B", + "address": "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "abi": [ { "inputs": [ @@ -162,39 +162,39 @@ "type": "function" } ], - "transactionHash": "0x883dd1eedb1d9266643110596e65620dfa50f33fba84601609a385522982e0b0", + "transactionHash": "0x7eb81f93a81d9c3238a9ea12520151880f87764ad5f412fbd4b209564670950f", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x5956c8158bde236d8e3638362ff7555C329A839B", - "transactionIndex": 1, - "gasUsed": "643983", - "logsBloom": "0x00000000000000000000000000008000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101040000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000100000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc0168a08f6876dd5c3030c58116131248ea75f8cfe3e5383e3565c5c968ed9d3", - "transactionHash": "0x883dd1eedb1d9266643110596e65620dfa50f33fba84601609a385522982e0b0", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "transactionIndex": 18, + "gasUsed": "644151", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000002000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000008000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000020000000000000000010000000000000000000000000000000000000000000000000", + "blockHash": "0x873639197b74a776d07c6daef3f9120f0e44049d26dc53a4dfa4c2dbc5eeab39", + "transactionHash": "0x7eb81f93a81d9c3238a9ea12520151880f87764ad5f412fbd4b209564670950f", "logs": [ { - "transactionIndex": 1, - "blockNumber": 8538439, - "transactionHash": "0x883dd1eedb1d9266643110596e65620dfa50f33fba84601609a385522982e0b0", - "address": "0x5956c8158bde236d8e3638362ff7555C329A839B", + "transactionIndex": 18, + "blockNumber": 8688285, + "transactionHash": "0x7eb81f93a81d9c3238a9ea12520151880f87764ad5f412fbd4b209564670950f", + "address": "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", - "logIndex": 0, - "blockHash": "0xc0168a08f6876dd5c3030c58116131248ea75f8cfe3e5383e3565c5c968ed9d3" + "logIndex": 10, + "blockHash": "0x873639197b74a776d07c6daef3f9120f0e44049d26dc53a4dfa4c2dbc5eeab39" } ], - "blockNumber": 8538439, - "cumulativeGasUsed": "664983", + "blockNumber": 8688285, + "cumulativeGasUsed": "1285639", "status": 1, "byzantium": true }, "args": [ - "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5" + "0x5a5B978142C8F08Dd013901b50892baC49f3b700" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", diff --git a/packages/contracts/deployments/goerli/EnumerableSetAllowlist.json b/packages/contracts/deployments/goerli/EnumerableSetAllowlist.json new file mode 100644 index 000000000..0afe6cb75 --- /dev/null +++ b/packages/contracts/deployments/goerli/EnumerableSetAllowlist.json @@ -0,0 +1,324 @@ +{ + "address": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "commitmentId", + "type": "uint256" + } + ], + "name": "UpdatedAllowList", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_commitmentId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "addressIsAllowed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "commitmentManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_commitmentId", + "type": "uint256" + } + ], + "name": "getAllowedAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "borrowers_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_commitmentId", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "_addressList", + "type": "address[]" + } + ], + "name": "setAllowlist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0xed576f7934a7c1e282acf88fd42a8fc30b121ca02d89e79e000e85ac8771042b", + "receipt": { + "to": null, + "from": "0x5a5b978142c8f08dd013901b50892bac49f3b700", + "contractAddress": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "transactionIndex": "0x14", + "gasUsed": "0xaff52", + "logsBloom": "0x00000000000000000000000000000000400000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000100000000000000001000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000008000000400000000000010000000000000000000000000080000000000000000000000000000000000000000000000", + "blockHash": "0x9b908ed83484a27b609bbdac075f56d6bb7cadd239c15e6abfebb8d7edde117e", + "transactionHash": "0xed576f7934a7c1e282acf88fd42a8fc30b121ca02d89e79e000e85ac8771042b", + "logs": [ + { + "address": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000b6b6f8f2df59ee047ad1649d781ba5bad6aa9b90" + ], + "data": "0x", + "blockNumber": "0x84958e", + "transactionHash": "0xed576f7934a7c1e282acf88fd42a8fc30b121ca02d89e79e000e85ac8771042b", + "transactionIndex": "0x14", + "blockHash": "0x9b908ed83484a27b609bbdac075f56d6bb7cadd239c15e6abfebb8d7edde117e", + "logIndex": "0xf", + "removed": false + }, + { + "address": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", + "blockNumber": "0x84958e", + "transactionHash": "0xed576f7934a7c1e282acf88fd42a8fc30b121ca02d89e79e000e85ac8771042b", + "transactionIndex": "0x14", + "blockHash": "0x9b908ed83484a27b609bbdac075f56d6bb7cadd239c15e6abfebb8d7edde117e", + "logIndex": "0x10", + "removed": false + } + ], + "blockNumber": "0x84958e", + "cumulativeGasUsed": "0x2831b7", + "status": "0x1" + }, + "args": [ + "0xb6b6f8f2DF59Ee047AD1649D781BA5bAD6aA9B90", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0x" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "implementation": "0xb6b6f8f2DF59Ee047AD1649D781BA5bAD6aA9B90", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/goerli/EnumerableSetAllowlist_Implementation.json b/packages/contracts/deployments/goerli/EnumerableSetAllowlist_Implementation.json new file mode 100644 index 000000000..ce88b4dd0 --- /dev/null +++ b/packages/contracts/deployments/goerli/EnumerableSetAllowlist_Implementation.json @@ -0,0 +1,219 @@ +{ + "address": "0xb6b6f8f2DF59Ee047AD1649D781BA5bAD6aA9B90", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_commitmentManager", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "commitmentId", + "type": "uint256" + } + ], + "name": "UpdatedAllowList", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_commitmentId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "addressIsAllowed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "commitmentManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_commitmentId", + "type": "uint256" + } + ], + "name": "getAllowedAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "borrowers_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_commitmentId", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "_addressList", + "type": "address[]" + } + ], + "name": "setAllowlist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x9a557dbf82bdb3f97bd69a99d8bc874498d362bff31a56af48e77040c756ec43", + "receipt": { + "to": null, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xb6b6f8f2DF59Ee047AD1649D781BA5bAD6aA9B90", + "transactionIndex": 10, + "gasUsed": "387270", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xadfc69d1d928b1f01fa2c0e82345627ca28e3f006367bf3931bdc5d5f2fad409", + "transactionHash": "0x9a557dbf82bdb3f97bd69a99d8bc874498d362bff31a56af48e77040c756ec43", + "logs": [], + "blockNumber": 8689005, + "cumulativeGasUsed": "807161", + "status": 1, + "byzantium": true + }, + "args": [ + "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6" + ], + "numDeployments": 1, + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_commitmentManager\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"}],\"name\":\"UpdatedAllowList\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"addressIsAllowed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"commitmentManager\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"}],\"name\":\"getAllowedAddresses\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"borrowers_\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"_addressList\",\"type\":\"address[]\"}],\"name\":\"setAllowlist\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/allowlist/EnumerableSetAllowlist.sol\":\"EnumerableSetAllowlist\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSetUpgradeable {\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x4807db844a856813048b5af81a764fdd25a0ae8876a3132593e8d21ddc6b607c\",\"license\":\"MIT\"},\"contracts/allowlist/EnumerableSetAllowlist.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../interfaces/allowlist/IAllowlistManager.sol\\\";\\nimport \\\"../interfaces/allowlist/IEnumerableSetAllowlist.sol\\\";\\n\\nimport \\\"../interfaces/ILenderCommitmentForwarder.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\\\";\\n\\n\\ncontract EnumerableSetAllowlist is IAllowlistManager,IEnumerableSetAllowlist {\\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\\n\\n event UpdatedAllowList(uint256 commitmentId);\\n \\n address public immutable commitmentManager;\\n\\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet) internal allowList;\\n\\n modifier onlyCommitmentOwner(uint256 _commitmentId){\\n require(msg.sender == ILenderCommitmentForwarder(commitmentManager).getCommitmentLender(_commitmentId),\\\"Must be the lender of the commitment.\\\");\\n _;\\n }\\n\\n constructor(address _commitmentManager){ \\n commitmentManager = _commitmentManager;\\n }\\n\\n\\n function setAllowlist(\\n uint256 _commitmentId,\\n address[] calldata _addressList\\n ) public\\n onlyCommitmentOwner(_commitmentId) \\n {\\n \\n delete allowList[_commitmentId];\\n _addToAllowlist(_commitmentId, _addressList);\\n }\\n\\n \\n /**\\n * @notice Adds a addresses to the allowlist for a commmitment.\\n * @param _commitmentId The id of the commitment that will allow the new borrower\\n * @param _addressList the address array that will be allowed to accept loans using the commitment\\n */\\n function _addToAllowlist(\\n uint256 _commitmentId,\\n address[] calldata _addressList\\n ) internal virtual {\\n \\n for (uint256 i = 0; i < _addressList.length; i++) {\\n allowList[_commitmentId].add(_addressList[i]);\\n }\\n emit UpdatedAllowList(_commitmentId);\\n }\\n\\n\\n function addressIsAllowed(uint256 _commitmentId, address _account) public virtual returns (bool) {\\n return allowList[_commitmentId].contains(_account);\\n }\\n\\n function getAllowedAddresses(uint256 _commitmentId)\\n public\\n view\\n returns (address[] memory borrowers_)\\n {\\n borrowers_ = allowList[_commitmentId].values();\\n }\\n\\n}\",\"keccak256\":\"0x58c43cad15285312b196feb3a0c24a17892e77ef509ba62b50e0fc5cd456c4d2\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderCommitmentForwarder.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\n \\ninterface ILenderCommitmentForwarder {\\n\\n function getCommitmentLender(uint256 _commitmentId) external returns (address lender_);\\n\\n}\\n\",\"keccak256\":\"0x9f9fad9535bd1750d3dad338aa8394f805fd1be13859b12a65a75fc1e8c36f76\"},\"contracts/interfaces/allowlist/IAllowlistManager.sol\":{\"content\":\"\\n\\n\\ninterface IAllowlistManager {\\n\\n \\n function addressIsAllowed(uint256 _commitmentId,address _account) external returns (bool allowed_) ;\\n \\n}\",\"keccak256\":\"0x98b599ad422554ec62b370cad7c7c976a8698b4eb416229e07282f7fc0925ad5\"},\"contracts/interfaces/allowlist/IEnumerableSetAllowlist.sol\":{\"content\":\"\\n\\n\\ninterface IEnumerableSetAllowlist {\\n \\n function setAllowlist(\\n uint256 _commitmentId,\\n address[] calldata _addressList\\n ) external;\\n \\n}\",\"keccak256\":\"0x4958565de4c7816382725a8603ed7bbabe32c9e13150f16ae0fbafe7d8cd3027\"}},\"version\":1}", + "bytecode": "0x60a060405234801561001057600080fd5b5060405161069538038061069583398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b6080516106046100916000396000818160b3015261010501526106046000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80638a38539f14610051578063b0b5316d14610066578063ded7f4ae1461008e578063e3fcf037146100ae575b600080fd5b61006461005f36600461042b565b6100ed565b005b6100796100743660046104bf565b61022b565b60405190151581526020015b60405180910390f35b6100a161009c3660046104ef565b61024c565b6040516100859190610508565b6100d57f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610085565b60405163144408ad60e11b81526004810184905283907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632888115a90602401602060405180830381600087803b15801561015157600080fd5b505af1158015610165573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101899190610555565b6001600160a01b0316336001600160a01b0316146101fb5760405162461bcd60e51b815260206004820152602560248201527f4d75737420626520746865206c656e646572206f662074686520636f6d6d697460448201526436b2b73a1760d91b606482015260840160405180910390fd5b600084815260208190526040812090818161021682826103f1565b50505050610225848484610266565b50505050565b600082815260208190526040812061024390836102fb565b90505b92915050565b60008181526020819052604090206060906102469061031d565b60005b818110156102c2576102af83838381811061028657610286610572565b905060200201602081019061029b9190610588565b600086815260208190526040902090610331565b50806102ba816105a5565b915050610269565b506040518381527f5096b93f393221659700def65554097cdcc366b69bfe7685c47edf3e49b4bbc69060200160405180910390a1505050565b6001600160a01b03811660009081526001830160205260408120541515610243565b6060600061032a83610346565b9392505050565b6000610243836001600160a01b0384166103a2565b60608160000180548060200260200160405190810160405280929190818152602001828054801561039657602002820191906000526020600020905b815481526020019060010190808311610382575b50505050509050919050565b60008181526001830160205260408120546103e957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610246565b506000610246565b508054600082559060005260206000209081019061040f9190610412565b50565b5b808211156104275760008155600101610413565b5090565b60008060006040848603121561044057600080fd5b83359250602084013567ffffffffffffffff8082111561045f57600080fd5b818601915086601f83011261047357600080fd5b81358181111561048257600080fd5b8760208260051b850101111561049757600080fd5b6020830194508093505050509250925092565b6001600160a01b038116811461040f57600080fd5b600080604083850312156104d257600080fd5b8235915060208301356104e4816104aa565b809150509250929050565b60006020828403121561050157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156105495783516001600160a01b031683529284019291840191600101610524565b50909695505050505050565b60006020828403121561056757600080fd5b815161032a816104aa565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561059a57600080fd5b813561032a816104aa565b60006000198214156105c757634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122094333801a10f3550ed6062a7c60b03372cabe8da7735f86fa7dd3ed3b884e13364736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80638a38539f14610051578063b0b5316d14610066578063ded7f4ae1461008e578063e3fcf037146100ae575b600080fd5b61006461005f36600461042b565b6100ed565b005b6100796100743660046104bf565b61022b565b60405190151581526020015b60405180910390f35b6100a161009c3660046104ef565b61024c565b6040516100859190610508565b6100d57f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610085565b60405163144408ad60e11b81526004810184905283907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632888115a90602401602060405180830381600087803b15801561015157600080fd5b505af1158015610165573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101899190610555565b6001600160a01b0316336001600160a01b0316146101fb5760405162461bcd60e51b815260206004820152602560248201527f4d75737420626520746865206c656e646572206f662074686520636f6d6d697460448201526436b2b73a1760d91b606482015260840160405180910390fd5b600084815260208190526040812090818161021682826103f1565b50505050610225848484610266565b50505050565b600082815260208190526040812061024390836102fb565b90505b92915050565b60008181526020819052604090206060906102469061031d565b60005b818110156102c2576102af83838381811061028657610286610572565b905060200201602081019061029b9190610588565b600086815260208190526040902090610331565b50806102ba816105a5565b915050610269565b506040518381527f5096b93f393221659700def65554097cdcc366b69bfe7685c47edf3e49b4bbc69060200160405180910390a1505050565b6001600160a01b03811660009081526001830160205260408120541515610243565b6060600061032a83610346565b9392505050565b6000610243836001600160a01b0384166103a2565b60608160000180548060200260200160405190810160405280929190818152602001828054801561039657602002820191906000526020600020905b815481526020019060010190808311610382575b50505050509050919050565b60008181526001830160205260408120546103e957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610246565b506000610246565b508054600082559060005260206000209081019061040f9190610412565b50565b5b808211156104275760008155600101610413565b5090565b60008060006040848603121561044057600080fd5b83359250602084013567ffffffffffffffff8082111561045f57600080fd5b818601915086601f83011261047357600080fd5b81358181111561048257600080fd5b8760208260051b850101111561049757600080fd5b6020830194508093505050509250925092565b6001600160a01b038116811461040f57600080fd5b600080604083850312156104d257600080fd5b8235915060208301356104e4816104aa565b809150509250929050565b60006020828403121561050157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156105495783516001600160a01b031683529284019291840191600101610524565b50909695505050505050565b60006020828403121561056757600080fd5b815161032a816104aa565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561059a57600080fd5b813561032a816104aa565b60006000198214156105c757634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122094333801a10f3550ed6062a7c60b03372cabe8da7735f86fa7dd3ed3b884e13364736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 23141, + "contract": "contracts/allowlist/EnumerableSetAllowlist.sol:EnumerableSetAllowlist", + "label": "allowList", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_uint256,t_struct(AddressSet)4547_storage)" + } + ], + "types": { + "t_array(t_bytes32)dyn_storage": { + "base": "t_bytes32", + "encoding": "dynamic_array", + "label": "bytes32[]", + "numberOfBytes": "32" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_uint256,t_struct(AddressSet)4547_storage)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => struct EnumerableSetUpgradeable.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)4547_storage" + }, + "t_struct(AddressSet)4547_storage": { + "encoding": "inplace", + "label": "struct EnumerableSetUpgradeable.AddressSet", + "members": [ + { + "astId": 4546, + "contract": "contracts/allowlist/EnumerableSetAllowlist.sol:EnumerableSetAllowlist", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)4232_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)4232_storage": { + "encoding": "inplace", + "label": "struct EnumerableSetUpgradeable.Set", + "members": [ + { + "astId": 4227, + "contract": "contracts/allowlist/EnumerableSetAllowlist.sol:EnumerableSetAllowlist", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 4231, + "contract": "contracts/allowlist/EnumerableSetAllowlist.sol:EnumerableSetAllowlist", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/goerli/EnumerableSetAllowlist_Proxy.json b/packages/contracts/deployments/goerli/EnumerableSetAllowlist_Proxy.json new file mode 100644 index 000000000..d47ecfc16 --- /dev/null +++ b/packages/contracts/deployments/goerli/EnumerableSetAllowlist_Proxy.json @@ -0,0 +1,236 @@ +{ + "address": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xed576f7934a7c1e282acf88fd42a8fc30b121ca02d89e79e000e85ac8771042b", + "receipt": { + "to": null, + "from": "0x5a5b978142c8f08dd013901b50892bac49f3b700", + "contractAddress": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "transactionIndex": "0x14", + "gasUsed": "0xaff52", + "logsBloom": "0x00000000000000000000000000000000400000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000100000000000000001000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000008000000400000000000010000000000000000000000000080000000000000000000000000000000000000000000000", + "blockHash": "0x9b908ed83484a27b609bbdac075f56d6bb7cadd239c15e6abfebb8d7edde117e", + "transactionHash": "0xed576f7934a7c1e282acf88fd42a8fc30b121ca02d89e79e000e85ac8771042b", + "logs": [ + { + "address": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000b6b6f8f2df59ee047ad1649d781ba5bad6aa9b90" + ], + "data": "0x", + "blockNumber": "0x84958e", + "transactionHash": "0xed576f7934a7c1e282acf88fd42a8fc30b121ca02d89e79e000e85ac8771042b", + "transactionIndex": "0x14", + "blockHash": "0x9b908ed83484a27b609bbdac075f56d6bb7cadd239c15e6abfebb8d7edde117e", + "logIndex": "0xf", + "removed": false + }, + { + "address": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", + "blockNumber": "0x84958e", + "transactionHash": "0xed576f7934a7c1e282acf88fd42a8fc30b121ca02d89e79e000e85ac8771042b", + "transactionIndex": "0x14", + "blockHash": "0x9b908ed83484a27b609bbdac075f56d6bb7cadd239c15e6abfebb8d7edde117e", + "logIndex": "0x10", + "removed": false + } + ], + "blockNumber": "0x84958e", + "cumulativeGasUsed": "0x2831b7", + "status": "0x1" + }, + "args": [ + "0xb6b6f8f2DF59Ee047AD1649D781BA5bAD6aA9B90", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0x" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/goerli/LenderCommitmentForwarder.json b/packages/contracts/deployments/goerli/LenderCommitmentForwarder.json index 5c46d0b3b..677a7119a 100644 --- a/packages/contracts/deployments/goerli/LenderCommitmentForwarder.json +++ b/packages/contracts/deployments/goerli/LenderCommitmentForwarder.json @@ -1,5 +1,5 @@ { - "address": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", + "address": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", "abi": [ { "anonymous": false, @@ -250,6 +250,25 @@ "name": "Initialized", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "commitmentId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "manager", + "type": "address" + } + ], + "name": "UpdatedAllowlistManager", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -375,6 +394,25 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "commitmentAllowListManagers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -509,9 +547,9 @@ "type": "tuple" }, { - "internalType": "address[]", - "name": "_borrowerAddressList", - "type": "address[]" + "internalType": "address", + "name": "borrowerAllowlistManager", + "type": "address" } ], "name": "createCommitment", @@ -546,15 +584,15 @@ "type": "uint256" } ], - "name": "getCommitmentBorrowers", + "name": "getCommitmentLender", "outputs": [ { - "internalType": "address[]", - "name": "borrowers_", - "type": "address[]" + "internalType": "address", + "name": "lender_", + "type": "address" } ], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function" }, { @@ -641,6 +679,24 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_commitmentId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_allowlistManager", + "type": "address" + } + ], + "name": "updateAllowlistManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -716,24 +772,6 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_commitmentId", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "_borrowerAddressList", - "type": "address[]" - } - ], - "name": "updateCommitmentBorrowers", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -756,59 +794,59 @@ "type": "constructor" } ], - "transactionHash": "0x2717d02f52012bc65b1d7979940cc7e019c3d92f39c3cecb99ce13e60ea49e8b", + "transactionHash": "0x53a3ae41c6e989dc6a38427e85049cfa332cdb413c79c701dc1dffe2ed70a700", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", - "transactionIndex": 7, - "gasUsed": "720430", - "logsBloom": "0x00200000000000000000000000000000400000000000000000010000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000004000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000000000000000000000040000000000000000000000000000000000040000000000000000", - "blockHash": "0x1c51fff4435d0a45908768428917c2e14f74c3770cef9b00aa6f4f58f5b16ec1", - "transactionHash": "0x2717d02f52012bc65b1d7979940cc7e019c3d92f39c3cecb99ce13e60ea49e8b", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", + "transactionIndex": 17, + "gasUsed": "720722", + "logsBloom": "0x00000000000008000000004000000000400000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000002000000000000000000000000000000000000000000000000000000000000400000000000800000000000000000000000000000000000020000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xb13d51d8e894e9f4220c89716af0f30f226627b77a537e5ca8c98b0891924a51", + "transactionHash": "0x53a3ae41c6e989dc6a38427e85049cfa332cdb413c79c701dc1dffe2ed70a700", "logs": [ { - "transactionIndex": 7, - "blockNumber": 8538455, - "transactionHash": "0x2717d02f52012bc65b1d7979940cc7e019c3d92f39c3cecb99ce13e60ea49e8b", - "address": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", + "transactionIndex": 17, + "blockNumber": 8688917, + "transactionHash": "0x53a3ae41c6e989dc6a38427e85049cfa332cdb413c79c701dc1dffe2ed70a700", + "address": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000095aa87944d9464056228de311b40dcabce22a43" + "0x0000000000000000000000007abf7096c6b287cd81dc7c80de5a7c968fdcb614" ], "data": "0x", "logIndex": 0, - "blockHash": "0x1c51fff4435d0a45908768428917c2e14f74c3770cef9b00aa6f4f58f5b16ec1" + "blockHash": "0xb13d51d8e894e9f4220c89716af0f30f226627b77a537e5ca8c98b0891924a51" }, { - "transactionIndex": 7, - "blockNumber": 8538455, - "transactionHash": "0x2717d02f52012bc65b1d7979940cc7e019c3d92f39c3cecb99ce13e60ea49e8b", - "address": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", + "transactionIndex": 17, + "blockNumber": 8688917, + "transactionHash": "0x53a3ae41c6e989dc6a38427e85049cfa332cdb413c79c701dc1dffe2ed70a700", + "address": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 1, - "blockHash": "0x1c51fff4435d0a45908768428917c2e14f74c3770cef9b00aa6f4f58f5b16ec1" + "blockHash": "0xb13d51d8e894e9f4220c89716af0f30f226627b77a537e5ca8c98b0891924a51" } ], - "blockNumber": 8538455, - "cumulativeGasUsed": "867430", + "blockNumber": 8688917, + "cumulativeGasUsed": "1077722", "status": 1, "byzantium": true }, "args": [ - "0x095aA87944D9464056228DE311B40DcabCe22A43", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0x7abF7096C6B287cd81dc7c80DE5a7c968fdcB614", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x" ], - "numDeployments": 2, + "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", - "implementation": "0x9065E7b11d8de642676B49e16A37EF0B7D38e489", + "implementation": "0x7abF7096C6B287cd81dc7c80DE5a7c968fdcB614", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/LenderCommitmentForwarder_Implementation.json b/packages/contracts/deployments/goerli/LenderCommitmentForwarder_Implementation.json index a091fc02d..840ad1285 100644 --- a/packages/contracts/deployments/goerli/LenderCommitmentForwarder_Implementation.json +++ b/packages/contracts/deployments/goerli/LenderCommitmentForwarder_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0x9065E7b11d8de642676B49e16A37EF0B7D38e489", + "address": "0x7abF7096C6B287cd81dc7c80DE5a7c968fdcB614", "abi": [ { "inputs": [ @@ -143,6 +143,25 @@ "name": "Initialized", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "commitmentId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "manager", + "type": "address" + } + ], + "name": "UpdatedAllowlistManager", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -268,6 +287,25 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "commitmentAllowListManagers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -402,9 +440,9 @@ "type": "tuple" }, { - "internalType": "address[]", - "name": "_borrowerAddressList", - "type": "address[]" + "internalType": "address", + "name": "borrowerAllowlistManager", + "type": "address" } ], "name": "createCommitment", @@ -439,15 +477,15 @@ "type": "uint256" } ], - "name": "getCommitmentBorrowers", + "name": "getCommitmentLender", "outputs": [ { - "internalType": "address[]", - "name": "borrowers_", - "type": "address[]" + "internalType": "address", + "name": "lender_", + "type": "address" } ], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function" }, { @@ -534,6 +572,24 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_commitmentId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_allowlistManager", + "type": "address" + } + ], + "name": "updateAllowlistManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -608,51 +664,33 @@ "outputs": [], "stateMutability": "nonpayable", "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_commitmentId", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "_borrowerAddressList", - "type": "address[]" - } - ], - "name": "updateCommitmentBorrowers", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" } ], - "transactionHash": "0xc78b89fd2f98abda9be7394c39c2cb706e338921b3bbd212cc436fcc3d455c9f", + "transactionHash": "0x485b9e19e59d86e3e8ad2b48157378096548bc0cc85817f2be2eb0a189a6eddc", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x9065E7b11d8de642676B49e16A37EF0B7D38e489", - "transactionIndex": 1, - "gasUsed": "1875998", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x7abF7096C6B287cd81dc7c80DE5a7c968fdcB614", + "transactionIndex": 25, + "gasUsed": "1852937", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xe0ec9ce48e223dcef12969b9f1b61b0ae4bd71114f5f8b8b3b9f42f4f1ae6fdd", - "transactionHash": "0xc78b89fd2f98abda9be7394c39c2cb706e338921b3bbd212cc436fcc3d455c9f", + "blockHash": "0x19292a48e8ce2caa62fd937ceb666a2492e4b6e5fbb805999b16db4e366b6637", + "transactionHash": "0x485b9e19e59d86e3e8ad2b48157378096548bc0cc85817f2be2eb0a189a6eddc", "logs": [], - "blockNumber": 8579796, - "cumulativeGasUsed": "1896998", + "blockNumber": 8688916, + "cumulativeGasUsed": "2571144", "status": 1, "byzantium": true }, "args": [ - "0x195c6608705546725DF0629dd60690Cf2b367734", - "0x74FFC87282ab32c8E0969E26F93C820a213ae146" + "0x3a8C417a743A60ECfF3988C34783D65362b62915", + "0x04F6908B97E4E985b849174f9904FaF0a0E50413" ], - "numDeployments": 2, - "solcInputHash": "976bca259bf89d14d50591c72cf76420", - "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_protocolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_marketRegistry\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"}],\"name\":\"InsufficientBorrowerCollateral\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"allocated\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requested\",\"type\":\"uint256\"}],\"name\":\"InsufficientCommitmentAllocation\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lendingToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"}],\"name\":\"CreatedCommitment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"}],\"name\":\"DeletedCommitment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"ExercisedCommitment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lendingToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"}],\"name\":\"UpdatedCommitment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"}],\"name\":\"UpdatedCommitmentBorrowers\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_marketRegistry\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_tellerV2\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_principalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_collateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_collateralTokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"_interestRate\",\"type\":\"uint16\"},{\"internalType\":\"uint32\",\"name\":\"_loanDuration\",\"type\":\"uint32\"}],\"name\":\"acceptCommitment\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"commitments\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"maxPrincipal\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"expiration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"minInterestRate\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxPrincipalPerCollateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"enum LenderCommitmentForwarder.CommitmentCollateralType\",\"name\":\"collateralTokenType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"principalTokenAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maxPrincipal\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"expiration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"minInterestRate\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxPrincipalPerCollateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"enum LenderCommitmentForwarder.CommitmentCollateralType\",\"name\":\"collateralTokenType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"principalTokenAddress\",\"type\":\"address\"}],\"internalType\":\"struct LenderCommitmentForwarder.Commitment\",\"name\":\"_commitment\",\"type\":\"tuple\"},{\"internalType\":\"address[]\",\"name\":\"_borrowerAddressList\",\"type\":\"address[]\"}],\"name\":\"createCommitment\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"commitmentId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"}],\"name\":\"deleteCommitment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"}],\"name\":\"getCommitmentBorrowers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"borrowers_\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMarketRegistry\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_principalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxPrincipalPerCollateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"enum LenderCommitmentForwarder.CommitmentCollateralType\",\"name\":\"_collateralTokenType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"_collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_principalTokenAddress\",\"type\":\"address\"}],\"name\":\"getRequiredCollateral\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTellerV2\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"getTellerV2MarketOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maxPrincipal\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"expiration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"minInterestRate\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxPrincipalPerCollateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"enum LenderCommitmentForwarder.CommitmentCollateralType\",\"name\":\"collateralTokenType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"principalTokenAddress\",\"type\":\"address\"}],\"internalType\":\"struct LenderCommitmentForwarder.Commitment\",\"name\":\"_commitment\",\"type\":\"tuple\"}],\"name\":\"updateCommitment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"_borrowerAddressList\",\"type\":\"address[]\"}],\"name\":\"updateCommitmentBorrowers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"CreatedCommitment(uint256,address,uint256,address,uint256)\":{\"params\":{\"lender\":\"The address of the lender.\",\"lendingToken\":\"The address of the asset being committed.\",\"marketId\":\"The Id of the market the commitment applies to.\",\"tokenAmount\":\"The amount of the asset being committed.\"}},\"DeletedCommitment(uint256)\":{\"params\":{\"commitmentId\":\"The id of the commitment that was deleted.\"}},\"ExercisedCommitment(uint256,address,uint256,uint256)\":{\"params\":{\"bidId\":\"The bid id for the loan from TellerV2.\",\"borrower\":\"The address of the borrower.\",\"commitmentId\":\"The id of the commitment that was exercised.\",\"tokenAmount\":\"The amount of the asset being committed.\"}},\"UpdatedCommitment(uint256,address,uint256,address,uint256)\":{\"params\":{\"commitmentId\":\"The id of the commitment that was updated.\",\"lender\":\"The address of the lender.\",\"lendingToken\":\"The address of the asset being committed.\",\"marketId\":\"The Id of the market the commitment applies to.\",\"tokenAmount\":\"The amount of the asset being committed.\"}},\"UpdatedCommitmentBorrowers(uint256)\":{\"params\":{\"commitmentId\":\"The id of the commitment that was updated.\"}}},\"kind\":\"dev\",\"methods\":{\"acceptCommitment(uint256,uint256,uint256,uint256,address,uint16,uint32)\":{\"details\":\"LoanDuration must be longer than the market payment cycle\",\"params\":{\"_collateralAmount\":\"The amount of collateral to use for the loan.\",\"_collateralTokenAddress\":\"The contract address to use for the loan collateral token.s\",\"_collateralTokenId\":\"The tokenId of collateral to use for the loan if ERC721 or ERC1155.\",\"_commitmentId\":\"The id of the commitment being accepted.\",\"_interestRate\":\"The interest rate APY to use for the loan in basis points.\",\"_loanDuration\":\"The overall duratiion for the loan. Must be longer than market payment cycle duration.\",\"_principalAmount\":\"The amount of currency to borrow for the loan.\"},\"returns\":{\"bidId\":\"The ID of the loan that was created on TellerV2\"}},\"createCommitment((uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address),address[])\":{\"params\":{\"_borrowerAddressList\":\"The array of borrowers that are allowed to accept loans using this commitment\",\"_commitment\":\"The new commitment data expressed as a struct\"},\"returns\":{\"commitmentId_\":\"returns the commitmentId for the created commitment\"}},\"deleteCommitment(uint256)\":{\"params\":{\"_commitmentId\":\"The id of the commitment to delete.\"}},\"getCommitmentBorrowers(uint256)\":{\"params\":{\"_commitmentId\":\"The commitment id for the commitment to query.\"},\"returns\":{\"borrowers_\":\"An array of addresses restricted to accept the commitment. Empty array means unrestricted.\"}},\"getRequiredCollateral(uint256,uint256,uint8,address,address)\":{\"params\":{\"_collateralTokenAddress\":\"The contract address for the collateral for the loan.\",\"_collateralTokenType\":\"The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\",\"_maxPrincipalPerCollateralAmount\":\"The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\",\"_principalAmount\":\"The amount of currency to borrow for the loan.\",\"_principalTokenAddress\":\"The contract address for the principal for the loan.\"}},\"updateCommitment(uint256,(uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address))\":{\"params\":{\"_commitment\":\"The new commitment data expressed as a struct\",\"_commitmentId\":\"The Id of the commitment to update.\"}},\"updateCommitmentBorrowers(uint256,address[])\":{\"params\":{\"_borrowerAddressList\":\"The array of borrowers that are allowed to accept loans using this commitment\",\"_commitmentId\":\"The Id of the commitment to update.\"}}},\"version\":1},\"userdoc\":{\"events\":{\"CreatedCommitment(uint256,address,uint256,address,uint256)\":{\"notice\":\"This event is emitted when a lender's commitment is created.\"},\"DeletedCommitment(uint256)\":{\"notice\":\"This event is emitted when a lender's commitment has been deleted.\"},\"ExercisedCommitment(uint256,address,uint256,uint256)\":{\"notice\":\"This event is emitted when a lender's commitment is exercised for a loan.\"},\"UpdatedCommitment(uint256,address,uint256,address,uint256)\":{\"notice\":\"This event is emitted when a lender's commitment is updated.\"},\"UpdatedCommitmentBorrowers(uint256)\":{\"notice\":\"This event is emitted when the allowed borrowers for a commitment is updated.\"}},\"kind\":\"user\",\"methods\":{\"acceptCommitment(uint256,uint256,uint256,uint256,address,uint16,uint32)\":{\"notice\":\"Accept the commitment to submitBid and acceptBid using the funds\"},\"constructor\":{\"notice\":\"External Functions *\"},\"createCommitment((uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address),address[])\":{\"notice\":\"Creates a loan commitment from a lender for a market.\"},\"deleteCommitment(uint256)\":{\"notice\":\"Removes the commitment of a lender to a market.\"},\"getCommitmentBorrowers(uint256)\":{\"notice\":\"Return the array of borrowers that are allowlisted for a commitment\"},\"getRequiredCollateral(uint256,uint256,uint8,address,address)\":{\"notice\":\"Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\"},\"updateCommitment(uint256,(uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address))\":{\"notice\":\"Updates the commitment of a lender to a market.\"},\"updateCommitmentBorrowers(uint256,address[])\":{\"notice\":\"Updates the borrowers allowed to accept a commitment\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/LenderCommitmentForwarder.sol\":\"LenderCommitmentForwarder\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x605434219ebbe4653f703640f06969faa5a1d78f0bfef878e5ddbb1ca369ceeb\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSetUpgradeable {\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x4807db844a856813048b5af81a764fdd25a0ae8876a3132593e8d21ddc6b607c\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/LenderCommitmentForwarder.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// Contracts\\nimport \\\"./TellerV2MarketForwarder.sol\\\";\\n\\n// Interfaces\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { Collateral, CollateralType } from \\\"./interfaces/escrow/ICollateralEscrowV1.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\\\";\\n\\n// Libraries\\nimport { MathUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\\\";\\n\\ncontract LenderCommitmentForwarder is TellerV2MarketForwarder {\\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\\n\\n enum CommitmentCollateralType {\\n NONE, // no collateral required\\n ERC20,\\n ERC721,\\n ERC1155,\\n ERC721_ANY_ID,\\n ERC1155_ANY_ID\\n }\\n\\n /**\\n * @notice Details about a lender's capital commitment.\\n * @param maxPrincipal Amount of tokens being committed by the lender. Max amount that can be loaned.\\n * @param expiration Expiration time in seconds, when the commitment expires.\\n * @param maxDuration Length of time, in seconds that the lender's capital can be lent out for.\\n * @param minInterestRate Minimum Annual percentage to be applied for loans using the lender's capital.\\n * @param collateralTokenAddress The address for the token contract that must be used to provide collateral for loans for this commitment.\\n * @param maxPrincipalPerCollateralAmount The amount of principal that can be used for a loan per each unit of collateral, expanded additionally by principal decimals.\\n * @param collateralTokenType The type of asset of the collateralTokenAddress (ERC20, ERC721, or ERC1155).\\n * @param lender The address of the lender for this commitment.\\n * @param marketId The market id for this commitment.\\n * @param principalTokenAddress The address for the token contract that will be used to provide principal for loans of this commitment.\\n */\\n struct Commitment {\\n uint256 maxPrincipal;\\n uint32 expiration;\\n uint32 maxDuration;\\n uint16 minInterestRate;\\n address collateralTokenAddress;\\n uint256 collateralTokenId;\\n uint256 maxPrincipalPerCollateralAmount;\\n CommitmentCollateralType collateralTokenType;\\n address lender;\\n uint256 marketId;\\n address principalTokenAddress;\\n }\\n\\n // CommitmentId => commitment\\n mapping(uint256 => Commitment) public commitments;\\n\\n uint256 commitmentCount;\\n\\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet)\\n internal commitmentBorrowersList;\\n\\n /**\\n * @notice This event is emitted when a lender's commitment is created.\\n * @param lender The address of the lender.\\n * @param marketId The Id of the market the commitment applies to.\\n * @param lendingToken The address of the asset being committed.\\n * @param tokenAmount The amount of the asset being committed.\\n */\\n event CreatedCommitment(\\n uint256 indexed commitmentId,\\n address lender,\\n uint256 marketId,\\n address lendingToken,\\n uint256 tokenAmount\\n );\\n\\n /**\\n * @notice This event is emitted when a lender's commitment is updated.\\n * @param commitmentId The id of the commitment that was updated.\\n * @param lender The address of the lender.\\n * @param marketId The Id of the market the commitment applies to.\\n * @param lendingToken The address of the asset being committed.\\n * @param tokenAmount The amount of the asset being committed.\\n */\\n event UpdatedCommitment(\\n uint256 indexed commitmentId,\\n address lender,\\n uint256 marketId,\\n address lendingToken,\\n uint256 tokenAmount\\n );\\n\\n /**\\n * @notice This event is emitted when the allowed borrowers for a commitment is updated.\\n * @param commitmentId The id of the commitment that was updated.\\n */\\n event UpdatedCommitmentBorrowers(uint256 indexed commitmentId);\\n\\n /**\\n * @notice This event is emitted when a lender's commitment has been deleted.\\n * @param commitmentId The id of the commitment that was deleted.\\n */\\n event DeletedCommitment(uint256 indexed commitmentId);\\n\\n /**\\n * @notice This event is emitted when a lender's commitment is exercised for a loan.\\n * @param commitmentId The id of the commitment that was exercised.\\n * @param borrower The address of the borrower.\\n * @param tokenAmount The amount of the asset being committed.\\n * @param bidId The bid id for the loan from TellerV2.\\n */\\n event ExercisedCommitment(\\n uint256 indexed commitmentId,\\n address borrower,\\n uint256 tokenAmount,\\n uint256 bidId\\n );\\n\\n error InsufficientCommitmentAllocation(\\n uint256 allocated,\\n uint256 requested\\n );\\n error InsufficientBorrowerCollateral(uint256 required, uint256 actual);\\n\\n /** Modifiers **/\\n\\n modifier commitmentLender(uint256 _commitmentId) {\\n require(\\n commitments[_commitmentId].lender == _msgSender(),\\n \\\"unauthorized commitment lender\\\"\\n );\\n _;\\n }\\n\\n function validateCommitment(Commitment storage _commitment) internal {\\n require(\\n _commitment.expiration > uint32(block.timestamp),\\n \\\"expired commitment\\\"\\n );\\n require(\\n _commitment.maxPrincipal > 0,\\n \\\"commitment principal allocation 0\\\"\\n );\\n\\n if (_commitment.collateralTokenType != CommitmentCollateralType.NONE) {\\n require(\\n _commitment.maxPrincipalPerCollateralAmount > 0,\\n \\\"commitment collateral ratio 0\\\"\\n );\\n\\n if (\\n _commitment.collateralTokenType ==\\n CommitmentCollateralType.ERC20\\n ) {\\n require(\\n _commitment.collateralTokenId == 0,\\n \\\"commitment collateral token id must be 0 for ERC20\\\"\\n );\\n }\\n }\\n }\\n\\n /** External Functions **/\\n\\n constructor(address _protocolAddress, address _marketRegistry)\\n TellerV2MarketForwarder(_protocolAddress, _marketRegistry)\\n {}\\n\\n /**\\n * @notice Creates a loan commitment from a lender for a market.\\n * @param _commitment The new commitment data expressed as a struct\\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\\n * @return commitmentId_ returns the commitmentId for the created commitment\\n */\\n function createCommitment(\\n Commitment calldata _commitment,\\n address[] calldata _borrowerAddressList\\n ) public returns (uint256 commitmentId_) {\\n commitmentId_ = commitmentCount++;\\n\\n require(\\n _commitment.lender == _msgSender(),\\n \\\"unauthorized commitment creator\\\"\\n );\\n\\n commitments[commitmentId_] = _commitment;\\n\\n validateCommitment(commitments[commitmentId_]);\\n\\n _addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList);\\n\\n emit CreatedCommitment(\\n commitmentId_,\\n _commitment.lender,\\n _commitment.marketId,\\n _commitment.principalTokenAddress,\\n _commitment.maxPrincipal\\n );\\n }\\n\\n /**\\n * @notice Updates the commitment of a lender to a market.\\n * @param _commitmentId The Id of the commitment to update.\\n * @param _commitment The new commitment data expressed as a struct\\n */\\n function updateCommitment(\\n uint256 _commitmentId,\\n Commitment calldata _commitment\\n ) public commitmentLender(_commitmentId) {\\n require(\\n _commitment.principalTokenAddress ==\\n commitments[_commitmentId].principalTokenAddress,\\n \\\"Principal token address cannot be updated.\\\"\\n );\\n require(\\n _commitment.marketId == commitments[_commitmentId].marketId,\\n \\\"Market Id cannot be updated.\\\"\\n );\\n\\n commitments[_commitmentId] = _commitment;\\n\\n validateCommitment(commitments[_commitmentId]);\\n\\n emit UpdatedCommitment(\\n _commitmentId,\\n _commitment.lender,\\n _commitment.marketId,\\n _commitment.principalTokenAddress,\\n _commitment.maxPrincipal\\n );\\n }\\n\\n /**\\n * @notice Updates the borrowers allowed to accept a commitment\\n * @param _commitmentId The Id of the commitment to update.\\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\\n */\\n function updateCommitmentBorrowers(\\n uint256 _commitmentId,\\n address[] calldata _borrowerAddressList\\n ) public commitmentLender(_commitmentId) {\\n delete commitmentBorrowersList[_commitmentId];\\n _addBorrowersToCommitmentAllowlist(_commitmentId, _borrowerAddressList);\\n }\\n\\n /**\\n * @notice Adds a borrower to the allowlist for a commmitment.\\n * @param _commitmentId The id of the commitment that will allow the new borrower\\n * @param _borrowerArray the address array of the borrowers that will be allowed to accept loans using the commitment\\n */\\n function _addBorrowersToCommitmentAllowlist(\\n uint256 _commitmentId,\\n address[] calldata _borrowerArray\\n ) internal {\\n for (uint256 i = 0; i < _borrowerArray.length; i++) {\\n commitmentBorrowersList[_commitmentId].add(_borrowerArray[i]);\\n }\\n emit UpdatedCommitmentBorrowers(_commitmentId);\\n }\\n\\n /**\\n * @notice Removes the commitment of a lender to a market.\\n * @param _commitmentId The id of the commitment to delete.\\n */\\n function deleteCommitment(uint256 _commitmentId)\\n public\\n commitmentLender(_commitmentId)\\n {\\n delete commitments[_commitmentId];\\n delete commitmentBorrowersList[_commitmentId];\\n emit DeletedCommitment(_commitmentId);\\n }\\n\\n /**\\n * @notice Reduces the commitment amount for a lender to a market.\\n * @param _commitmentId The id of the commitment to modify.\\n * @param _tokenAmountDelta The amount of change in the maxPrincipal.\\n */\\n function _decrementCommitment(\\n uint256 _commitmentId,\\n uint256 _tokenAmountDelta\\n ) internal {\\n commitments[_commitmentId].maxPrincipal -= _tokenAmountDelta;\\n }\\n\\n /**\\n * @notice Accept the commitment to submitBid and acceptBid using the funds\\n * @dev LoanDuration must be longer than the market payment cycle\\n * @param _commitmentId The id of the commitment being accepted.\\n * @param _principalAmount The amount of currency to borrow for the loan.\\n * @param _collateralAmount The amount of collateral to use for the loan.\\n * @param _collateralTokenId The tokenId of collateral to use for the loan if ERC721 or ERC1155.\\n * @param _collateralTokenAddress The contract address to use for the loan collateral token.s\\n * @param _interestRate The interest rate APY to use for the loan in basis points.\\n * @param _loanDuration The overall duratiion for the loan. Must be longer than market payment cycle duration.\\n * @return bidId The ID of the loan that was created on TellerV2\\n */\\n function acceptCommitment(\\n uint256 _commitmentId,\\n uint256 _principalAmount,\\n uint256 _collateralAmount,\\n uint256 _collateralTokenId,\\n address _collateralTokenAddress,\\n uint16 _interestRate,\\n uint32 _loanDuration\\n ) external returns (uint256 bidId) {\\n address borrower = _msgSender();\\n\\n Commitment storage commitment = commitments[_commitmentId];\\n\\n validateCommitment(commitment);\\n\\n require(\\n _collateralTokenAddress == commitment.collateralTokenAddress,\\n \\\"Mismatching collateral token\\\"\\n );\\n require(\\n _interestRate >= commitment.minInterestRate,\\n \\\"Invalid interest rate\\\"\\n );\\n require(\\n _loanDuration <= commitment.maxDuration,\\n \\\"Invalid loan max duration\\\"\\n );\\n\\n require(\\n commitmentBorrowersList[_commitmentId].length() == 0 ||\\n commitmentBorrowersList[_commitmentId].contains(borrower),\\n \\\"unauthorized commitment borrower\\\"\\n );\\n\\n if (_principalAmount > commitment.maxPrincipal) {\\n revert InsufficientCommitmentAllocation({\\n allocated: commitment.maxPrincipal,\\n requested: _principalAmount\\n });\\n }\\n\\n uint256 requiredCollateral = getRequiredCollateral(\\n _principalAmount,\\n commitment.maxPrincipalPerCollateralAmount,\\n commitment.collateralTokenType,\\n commitment.collateralTokenAddress,\\n commitment.principalTokenAddress\\n );\\n if (_collateralAmount < requiredCollateral) {\\n revert InsufficientBorrowerCollateral({\\n required: requiredCollateral,\\n actual: _collateralAmount\\n });\\n }\\n\\n if (\\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\\n commitment.collateralTokenType ==\\n CommitmentCollateralType.ERC721_ANY_ID\\n ) {\\n require(\\n _collateralAmount == 1,\\n \\\"invalid commitment collateral amount for ERC721\\\"\\n );\\n }\\n\\n if (\\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\\n commitment.collateralTokenType == CommitmentCollateralType.ERC1155\\n ) {\\n require(\\n commitment.collateralTokenId == _collateralTokenId,\\n \\\"invalid commitment collateral tokenId\\\"\\n );\\n }\\n\\n bidId = _submitBidFromCommitment(\\n borrower,\\n commitment.marketId,\\n commitment.principalTokenAddress,\\n _principalAmount,\\n commitment.collateralTokenAddress,\\n _collateralAmount,\\n _collateralTokenId,\\n commitment.collateralTokenType,\\n _loanDuration,\\n _interestRate\\n );\\n\\n _acceptBid(bidId, commitment.lender);\\n\\n _decrementCommitment(_commitmentId, _principalAmount);\\n\\n emit ExercisedCommitment(\\n _commitmentId,\\n borrower,\\n _principalAmount,\\n bidId\\n );\\n }\\n\\n /**\\n * @notice Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\\n * @param _principalAmount The amount of currency to borrow for the loan.\\n * @param _maxPrincipalPerCollateralAmount The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\\n * @param _collateralTokenType The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\\n * @param _collateralTokenAddress The contract address for the collateral for the loan.\\n * @param _principalTokenAddress The contract address for the principal for the loan.\\n */\\n function getRequiredCollateral(\\n uint256 _principalAmount,\\n uint256 _maxPrincipalPerCollateralAmount,\\n CommitmentCollateralType _collateralTokenType,\\n address _collateralTokenAddress,\\n address _principalTokenAddress\\n ) public view virtual returns (uint256) {\\n if (_collateralTokenType == CommitmentCollateralType.NONE) {\\n return 0;\\n }\\n\\n uint8 collateralDecimals;\\n uint8 principalDecimals = IERC20MetadataUpgradeable(\\n _principalTokenAddress\\n ).decimals();\\n\\n if (_collateralTokenType == CommitmentCollateralType.ERC20) {\\n collateralDecimals = IERC20MetadataUpgradeable(\\n _collateralTokenAddress\\n ).decimals();\\n }\\n\\n /*\\n * The principalAmount is expanded by (collateralDecimals+principalDecimals) to increase precision\\n * and then it is divided by _maxPrincipalPerCollateralAmount which should already been expanded by principalDecimals\\n */\\n return\\n MathUpgradeable.mulDiv(\\n _principalAmount,\\n (10**(collateralDecimals + principalDecimals)),\\n _maxPrincipalPerCollateralAmount,\\n MathUpgradeable.Rounding.Up\\n );\\n }\\n\\n /**\\n * @notice Return the array of borrowers that are allowlisted for a commitment\\n * @param _commitmentId The commitment id for the commitment to query.\\n * @return borrowers_ An array of addresses restricted to accept the commitment. Empty array means unrestricted.\\n */\\n function getCommitmentBorrowers(uint256 _commitmentId)\\n external\\n view\\n returns (address[] memory borrowers_)\\n {\\n borrowers_ = commitmentBorrowersList[_commitmentId].values();\\n }\\n\\n /**\\n * @notice Internal function to submit a bid to the lending protocol using a commitment\\n * @param _borrower The address of the borrower for the loan.\\n * @param _marketId The id for the market of the loan in the lending protocol.\\n * @param _principalTokenAddress The contract address for the principal token.\\n * @param _principalAmount The amount of principal to borrow for the loan.\\n * @param _collateralTokenAddress The contract address for the collateral token.\\n * @param _collateralAmount The amount of collateral to use for the loan.\\n * @param _collateralTokenId The tokenId for the collateral (if it is ERC721 or ERC1155).\\n * @param _collateralTokenType The type of collateral token (ERC20,ERC721,ERC1177,None).\\n * @param _loanDuration The duration of the loan in seconds delta. Must be longer than loan payment cycle for the market.\\n * @param _interestRate The amount of interest APY for the loan expressed in basis points.\\n */\\n function _submitBidFromCommitment(\\n address _borrower,\\n uint256 _marketId,\\n address _principalTokenAddress,\\n uint256 _principalAmount,\\n address _collateralTokenAddress,\\n uint256 _collateralAmount,\\n uint256 _collateralTokenId,\\n CommitmentCollateralType _collateralTokenType,\\n uint32 _loanDuration,\\n uint16 _interestRate\\n ) internal returns (uint256 bidId) {\\n CreateLoanArgs memory createLoanArgs;\\n createLoanArgs.marketId = _marketId;\\n createLoanArgs.lendingToken = _principalTokenAddress;\\n createLoanArgs.principal = _principalAmount;\\n createLoanArgs.duration = _loanDuration;\\n createLoanArgs.interestRate = _interestRate;\\n\\n Collateral[] memory collateralInfo;\\n if (_collateralTokenType != CommitmentCollateralType.NONE) {\\n collateralInfo = new Collateral[](1);\\n collateralInfo[0] = Collateral({\\n _collateralType: _getEscrowCollateralType(_collateralTokenType),\\n _tokenId: _collateralTokenId,\\n _amount: _collateralAmount,\\n _collateralAddress: _collateralTokenAddress\\n });\\n }\\n\\n bidId = _submitBidWithCollateral(\\n createLoanArgs,\\n collateralInfo,\\n _borrower\\n );\\n }\\n\\n /**\\n * @notice Return the collateral type based on the commitmentcollateral type. Collateral type is used in the base lending protocol.\\n * @param _type The type of collateral to be used for the loan.\\n */\\n function _getEscrowCollateralType(CommitmentCollateralType _type)\\n internal\\n pure\\n returns (CollateralType)\\n {\\n if (_type == CommitmentCollateralType.ERC20) {\\n return CollateralType.ERC20;\\n }\\n if (\\n _type == CommitmentCollateralType.ERC721 ||\\n _type == CommitmentCollateralType.ERC721_ANY_ID\\n ) {\\n return CollateralType.ERC721;\\n }\\n if (\\n _type == CommitmentCollateralType.ERC1155 ||\\n _type == CommitmentCollateralType.ERC1155_ANY_ID\\n ) {\\n return CollateralType.ERC1155;\\n }\\n\\n revert(\\\"Unknown Collateral Type\\\");\\n }\\n}\\n\",\"keccak256\":\"0x0878c6bd2e6db09f9b5aa3838926864ddd1b8b8a4ffb3665c69620ef30256424\",\"license\":\"MIT\"},\"contracts/TellerV2MarketForwarder.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\n\\nimport \\\"./interfaces/IMarketRegistry.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\\\";\\n\\n/**\\n * @dev Simple helper contract to forward an encoded function call to the TellerV2 contract. See {TellerV2Context}\\n */\\nabstract contract TellerV2MarketForwarder is Initializable, ContextUpgradeable {\\n using AddressUpgradeable for address;\\n\\n address public immutable _tellerV2;\\n address public immutable _marketRegistry;\\n\\n struct CreateLoanArgs {\\n uint256 marketId;\\n address lendingToken;\\n uint256 principal;\\n uint32 duration;\\n uint16 interestRate;\\n string metadataURI;\\n address recipient;\\n }\\n\\n constructor(address _protocolAddress, address _marketRegistryAddress) {\\n _tellerV2 = _protocolAddress;\\n _marketRegistry = _marketRegistryAddress;\\n }\\n\\n function getTellerV2() public view returns (address) {\\n return _tellerV2;\\n }\\n\\n function getMarketRegistry() public view returns (address) {\\n return _marketRegistry;\\n }\\n\\n function getTellerV2MarketOwner(uint256 marketId) public returns (address) {\\n return IMarketRegistry(getMarketRegistry()).getMarketOwner(marketId);\\n }\\n\\n /**\\n * @dev Performs function call to the TellerV2 contract by appending an address to the calldata.\\n * @param _data The encoded function calldata on TellerV2.\\n * @param _msgSender The address that should be treated as the underlying function caller.\\n * @return The encoded response from the called function.\\n *\\n * Requirements:\\n * - The {_msgSender} address must set an approval on TellerV2 for this forwarder contract __before__ making this call.\\n */\\n function _forwardCall(bytes memory _data, address _msgSender)\\n internal\\n returns (bytes memory)\\n {\\n return\\n address(_tellerV2).functionCall(\\n abi.encodePacked(_data, _msgSender)\\n );\\n }\\n\\n /**\\n * @notice Creates a new loan using the TellerV2 lending protocol.\\n * @param _createLoanArgs Details describing the loan agreement.]\\n * @param _borrower The borrower address for the new loan.\\n */\\n function _submitBid(\\n CreateLoanArgs memory _createLoanArgs,\\n address _borrower\\n ) internal virtual returns (uint256 bidId) {\\n bytes memory responseData;\\n\\n responseData = _forwardCall(\\n abi.encodeWithSignature(\\n \\\"submitBid(address,uint256,uint256,uint32,uint16,string,address)\\\",\\n _createLoanArgs.lendingToken,\\n _createLoanArgs.marketId,\\n _createLoanArgs.principal,\\n _createLoanArgs.duration,\\n _createLoanArgs.interestRate,\\n _createLoanArgs.metadataURI,\\n _createLoanArgs.recipient\\n ),\\n _borrower\\n );\\n\\n return abi.decode(responseData, (uint256));\\n }\\n\\n /**\\n * @notice Creates a new loan using the TellerV2 lending protocol.\\n * @param _createLoanArgs Details describing the loan agreement.]\\n * @param _borrower The borrower address for the new loan.\\n */\\n function _submitBidWithCollateral(\\n CreateLoanArgs memory _createLoanArgs,\\n Collateral[] memory _collateralInfo,\\n address _borrower\\n ) internal virtual returns (uint256 bidId) {\\n bytes memory responseData;\\n\\n responseData = _forwardCall(\\n abi.encodeWithSignature(\\n \\\"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\\\",\\n _createLoanArgs.lendingToken,\\n _createLoanArgs.marketId,\\n _createLoanArgs.principal,\\n _createLoanArgs.duration,\\n _createLoanArgs.interestRate,\\n _createLoanArgs.metadataURI,\\n _createLoanArgs.recipient,\\n _collateralInfo\\n ),\\n _borrower\\n );\\n\\n return abi.decode(responseData, (uint256));\\n }\\n\\n /**\\n * @notice Accepts a new loan using the TellerV2 lending protocol.\\n * @param _bidId The id of the new loan.\\n * @param _lender The address of the lender who will provide funds for the new loan.\\n */\\n function _acceptBid(uint256 _bidId, address _lender)\\n internal\\n virtual\\n returns (bool)\\n {\\n // Approve the borrower's loan\\n _forwardCall(\\n abi.encodeWithSelector(ITellerV2.lenderAcceptBid.selector, _bidId),\\n _lender\\n );\\n\\n return true;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0xa5820f997a7e78d2902d3d35eadcbff28a589b5545d023b07acd085f8fc089e8\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x549d37cb1390adad543f2e7b1ad46104c4326c4af7dbccda35116833103a6465\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x62c61e6811becc51d0d644e54c342279565e9d8ff5a386cde5a784440a404da7\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60c06040523480156200001157600080fd5b50604051620021d8380380620021d8833981016040819052620000349162000069565b6001600160a01b039182166080521660a052620000a1565b80516001600160a01b03811681146200006457600080fd5b919050565b600080604083850312156200007d57600080fd5b62000088836200004c565b915062000098602084016200004c565b90509250929050565b60805160a0516120f5620000e36000396000818161024a015281816102c001526104fd01526000818161027001528181610299015261143a01526120f56000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80637d458e7b1161008c578063c66b8ed211610066578063c66b8ed214610248578063dc003d5a1461026e578063eafef46e14610294578063fd7b2d91146102bb57600080fd5b80637d458e7b14610202578063bfb40bc014610222578063c1abfa111461023557600080fd5b80631409a2e4146100d45780631dcaa70d146100e957806349ce899714610119578063592113d0146101bb5780635ec77a81146101dc5780637479208b146101ef575b600080fd5b6100e76100e23660046117d9565b6102e2565b005b6100fc6100f7366004611807565b6104dc565b6040516001600160a01b0390911681526020015b60405180910390f35b6101a4610127366004611807565b6065602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154949563ffffffff8086169664010000000087049091169561ffff600160401b820416956001600160a01b03600160501b9092048216959094909360ff8216936101009092048316929091168b565b6040516101109b9a99989796959493929190611836565b6101ce6101c9366004611909565b61057d565b604051908152602001610110565b6100e76101ea3660046119c7565b610a06565b6101ce6101fd366004611a20565b610a77565b610215610210366004611807565b610bcd565b6040516101109190611a7f565b6100e7610230366004611807565b610be7565b6101ce610243366004611acc565b610ccd565b7f00000000000000000000000000000000000000000000000000000000000000006100fc565b7f00000000000000000000000000000000000000000000000000000000000000006100fc565b6100fc7f000000000000000000000000000000000000000000000000000000000000000081565b6100fc7f000000000000000000000000000000000000000000000000000000000000000081565b60008281526065602052604090206004015482906001600160a01b0361010090910416331461032c5760405162461bcd60e51b815260040161032390611b09565b60405180910390fd5b6000838152606560205260409020600601546001600160a01b031661035961016084016101408501611b40565b6001600160a01b0316146103c25760405162461bcd60e51b815260206004820152602a60248201527f5072696e636970616c20746f6b656e20616464726573732063616e6e6f74206260448201526932903ab83230ba32b21760b11b6064820152608401610323565b600083815260656020526040902060050154610120830135146104275760405162461bcd60e51b815260206004820152601c60248201527f4d61726b65742049642063616e6e6f7420626520757064617465642e000000006044820152606401610323565b600083815260656020526040902082906104418282611bb4565b5050600083815260656020526040902061045a90610e0f565b827f3639fd8e82fc21d99ff6df2a4a03995fa53f752fddd525d8a9aadccefa788aa061048e61012085016101008601611b40565b6101208501356104a661016087016101408801611b40565b604080516001600160a01b03948516815260208101939093529216818301528535606082015290519081900360800190a2505050565b604051633d36902960e01b8152600481018290526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633d3690299060240160206040518083038186803b15801561053f57600080fd5b505afa158015610553573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105779190611d3a565b92915050565b6000878152606560205260408120339061059681610e0f565b60018101546001600160a01b03878116600160501b90920416146105fc5760405162461bcd60e51b815260206004820152601c60248201527f4d69736d61746368696e6720636f6c6c61746572616c20746f6b656e000000006044820152606401610323565b600181015461ffff600160401b909104811690861610156106575760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420696e746572657374207261746560581b6044820152606401610323565b600181015463ffffffff640100000000909104811690851611156106bd5760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964206c6f616e206d6178206475726174696f6e000000000000006044820152606401610323565b60008a81526067602052604090206106d490610fbd565b15806106f3575060008a81526067602052604090206106f39083610fc7565b61073f5760405162461bcd60e51b815260206004820181905260248201527f756e617574686f72697a656420636f6d6d69746d656e7420626f72726f7765726044820152606401610323565b805489111561076e5780546040516375d44cf160e11b81526004810191909152602481018a9052604401610323565b60038101546004820154600183015460068401546000936107ac938e93919260ff909116916001600160a01b03600160501b90910481169116610a77565b9050808910156107d95760405163b744c71960e01b815260048101829052602481018a9052604401610323565b6002600483015460ff1660058111156107f4576107f4611820565b1480610817575060048083015460ff16600581111561081557610815611820565b145b1561088457886001146108845760405162461bcd60e51b815260206004820152602f60248201527f696e76616c696420636f6d6d69746d656e7420636f6c6c61746572616c20616d60448201526e6f756e7420666f722045524337323160881b6064820152608401610323565b6002600483015460ff16600581111561089f5761089f611820565b14806108c357506003600483015460ff1660058111156108c1576108c1611820565b145b1561092957878260020154146109295760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420636f6d6d69746d656e7420636f6c6c61746572616c20746f6044820152641ad95b925960da1b6064820152608401610323565b61097e8383600501548460060160009054906101000a90046001600160a01b03168d86600101600a9054906101000a90046001600160a01b03168e8e8960040160009054906101000a900460ff168d8f610fec565b93506109a1848360040160019054906101000a90046001600160a01b0316611116565b506109ac8b8b611178565b604080516001600160a01b0385168152602081018c90529081018590528b907f7839c0e772fbc0df2f1be83221fb8cd10f50be73dac060cbb277ee5c856219309060600160405180910390a2505050979650505050505050565b60008381526065602052604090206004015483906001600160a01b03610100909104163314610a475760405162461bcd60e51b815260040161032390611b09565b6000848152606760205260408120908181610a62828261178e565b50505050610a7184848461119f565b50505050565b600080846005811115610a8c57610a8c611820565b1415610a9a57506000610bc4565b600080836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610ad657600080fd5b505afa158015610aea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0e9190611d57565b90506001866005811115610b2457610b24611820565b1415610b9e57846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6357600080fd5b505afa158015610b77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9b9190611d57565b91505b610bbf88610bac8385611d90565b610bb790600a611e99565b89600161122c565b925050505b95945050505050565b60008181526067602052604090206060906105779061128b565b60008181526065602052604090206004015481906001600160a01b03610100909104163314610c285760405162461bcd60e51b815260040161032390611b09565b60008281526065602090815260408083208381556001810180546001600160f01b031916905560028101849055600381018490556004810180546001600160a81b03191690556005810184905560060180546001600160a01b031916905560679091528120908181610c9a828261178e565b50506040518492507fd278ecade1e148fd8320435541f72d6a02dff654c1577ae2cadecba16e8ef2149150600090a25050565b6066805460009182610cde83611ea8565b90915550905033610cf761012086016101008701611b40565b6001600160a01b031614610d4d5760405162461bcd60e51b815260206004820152601f60248201527f756e617574686f72697a656420636f6d6d69746d656e742063726561746f72006044820152606401610323565b60008181526065602052604090208490610d678282611bb4565b50506000818152606560205260409020610d8090610e0f565b610d8b81848461119f565b807f16b531d6c0bbff6da27b922e61fc528bb3ae5b435f9e56fb87e399afb6ae520a610dbf61012087016101008801611b40565b610120870135610dd761016089016101408a01611b40565b604080516001600160a01b03948516815260208101939093529216818301528735606082015290519081900360800190a29392505050565b600181015463ffffffff428116911611610e605760405162461bcd60e51b8152602060048201526012602482015271195e1c1a5c99590818dbdb5b5a5d1b595b9d60721b6044820152606401610323565b8054610eb85760405162461bcd60e51b815260206004820152602160248201527f636f6d6d69746d656e74207072696e636970616c20616c6c6f636174696f6e206044820152600360fc1b6064820152608401610323565b6000600482015460ff166005811115610ed357610ed3611820565b14610fba576000816003015411610f2c5760405162461bcd60e51b815260206004820152601d60248201527f636f6d6d69746d656e7420636f6c6c61746572616c20726174696f20300000006044820152606401610323565b6001600482015460ff166005811115610f4757610f47611820565b1415610fba57600281015415610fba5760405162461bcd60e51b815260206004820152603260248201527f636f6d6d69746d656e7420636f6c6c61746572616c20746f6b656e206964206d6044820152710757374206265203020666f722045524332360741b6064820152608401610323565b50565b6000610577825490565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6040805160e081018252606060a08201819052600060c083018190528c83526001600160a01b038c1660208401529282018a905263ffffffff85168183015261ffff841660808301528286600581111561104857611048611820565b146110fa5760408051600180825281830190925290816020015b60408051608081018252600080825260208083018290529282018190526060820152825260001990920191018161106257905050905060405180608001604052806110ac88611298565b60028111156110bd576110bd611820565b81526020018981526020018881526020018a6001600160a01b0316815250816000815181106110ee576110ee611ec3565b60200260200101819052505b61110582828f611380565b9d9c50505050505050505050505050565b600061116e63a8cb5d6860e01b8460405160240161113691815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915283611408565b5060019392505050565b60008281526065602052604081208054839290611196908490611ed9565b90915550505050565b60005b818110156111fb576111e88383838181106111bf576111bf611ec3565b90506020020160208101906111d49190611b40565b600086815260676020526040902090611460565b50806111f381611ea8565b9150506111a2565b5060405183907f04224de4972d2a55e811df57692f065a266ea975d06938d50b3cb33b498b161790600090a2505050565b60008061123a868686611475565b9050600183600281111561125057611250611820565b14801561126d57506000848061126857611268611ef0565b868809115b156112805761127d600182611f06565b90505b90505b949350505050565b60606000610fe583611525565b600060018260058111156112ae576112ae611820565b14156112bc57506000919050565b60028260058111156112d0576112d0611820565b14806112ed575060048260058111156112eb576112eb611820565b145b156112fa57506001919050565b600382600581111561130e5761130e611820565b148061132b5750600582600581111561132957611329611820565b145b1561133857506002919050565b60405162461bcd60e51b815260206004820152601760248201527f556e6b6e6f776e20436f6c6c61746572616c20547970650000000000000000006044820152606401610323565b600060606113f2856020015186600001518760400151886060015189608001518a60a001518b60c001518b6040516024016113c2989796959493929190611f76565b60408051601f198184030181529190526020810180516001600160e01b0316637bbd53d760e01b17905284611408565b905080806020019051810190610bc49190612040565b6060610fe58383604051602001611420929190612059565b60408051601f198184030181529190526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690611581565b6000610fe5836001600160a01b0384166115c5565b6000808060001985870985870292508281108382030391505080600014156114b0578382816114a6576114a6611ef0565b0492505050610fe5565b8084116114bc57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561157557602002820191906000526020600020905b815481526020019060010190808311611561575b50505050509050919050565b6060610fe5838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250611614565b600081815260018301602052604081205461160c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610577565b506000610577565b6060824710156116755760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610323565b600080866001600160a01b031685876040516116919190612090565b60006040518083038185875af1925050503d80600081146116ce576040519150601f19603f3d011682016040523d82523d6000602084013e6116d3565b606091505b50915091506116e4878383876116ef565b979650505050505050565b6060831561175b578251611754576001600160a01b0385163b6117545760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610323565b5081611283565b61128383838151156117705781518083602001fd5b8060405162461bcd60e51b815260040161032391906120ac565b5050565b5080546000825590600052602060002090810190610fba91905b808211156117bc57600081556001016117a8565b5090565b600061016082840312156117d357600080fd5b50919050565b60008061018083850312156117ed57600080fd5b823591506117fe84602085016117c0565b90509250929050565b60006020828403121561181957600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b8b815263ffffffff8b811660208301528a16604082015261ffff891660608201526001600160a01b038816608082015260a0810187905260c0810186905261016081016006861061188957611889611820565b8560e08301526118a56101008301866001600160a01b03169052565b836101208301526118c26101408301846001600160a01b03169052565b9c9b505050505050505050505050565b6001600160a01b0381168114610fba57600080fd5b61ffff81168114610fba57600080fd5b63ffffffff81168114610fba57600080fd5b600080600080600080600060e0888a03121561192457600080fd5b87359650602088013595506040880135945060608801359350608088013561194b816118d2565b925060a088013561195b816118e7565b915060c088013561196b816118f7565b8091505092959891949750929550565b60008083601f84011261198d57600080fd5b50813567ffffffffffffffff8111156119a557600080fd5b6020830191508360208260051b85010111156119c057600080fd5b9250929050565b6000806000604084860312156119dc57600080fd5b83359250602084013567ffffffffffffffff8111156119fa57600080fd5b611a068682870161197b565b9497909650939450505050565b60068110610fba57600080fd5b600080600080600060a08688031215611a3857600080fd5b85359450602086013593506040860135611a5181611a13565b92506060860135611a61816118d2565b91506080860135611a71816118d2565b809150509295509295909350565b6020808252825182820181905260009190848201906040850190845b81811015611ac05783516001600160a01b031683529284019291840191600101611a9b565b50909695505050505050565b60008060006101808486031215611ae257600080fd5b611aec85856117c0565b925061016084013567ffffffffffffffff8111156119fa57600080fd5b6020808252601e908201527f756e617574686f72697a656420636f6d6d69746d656e74206c656e6465720000604082015260600190565b600060208284031215611b5257600080fd5b8135610fe5816118d2565b60008135610577816118f7565b60008135610577816118e7565b60008135610577816118d2565b6000813561057781611a13565b60068210611ba157611ba1611820565b60ff1981541660ff831681178255505050565b8135815560018101611be2611bcb60208501611b5d565b825463ffffffff191663ffffffff91909116178255565b611c13611bf160408501611b5d565b825467ffffffff00000000191660209190911b67ffffffff0000000016178255565b611c48611c2260608501611b6a565b825469ffff0000000000000000191660409190911b69ffff000000000000000016178255565b611c96611c5760808501611b77565b8280547fffff0000000000000000000000000000000000000000ffffffffffffffffffff1660509290921b600160501b600160f01b0316919091179055565b5060a0820135600282015560c0820135600382015560048101611cc4611cbe60e08501611b84565b82611b91565b611cfa611cd46101008501611b77565b828054610100600160a81b03191660089290921b610100600160a81b0316919091179055565b50610120820135600582015561178a611d166101408401611b77565b6006830180546001600160a01b0319166001600160a01b0392909216919091179055565b600060208284031215611d4c57600080fd5b8151610fe5816118d2565b600060208284031215611d6957600080fd5b815160ff81168114610fe557600080fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff84168060ff03821115611dad57611dad611d7a565b019392505050565b600181815b80851115611df0578160001904821115611dd657611dd6611d7a565b80851615611de357918102915b93841c9390800290611dba565b509250929050565b600082611e0757506001610577565b81611e1457506000610577565b8160018114611e2a5760028114611e3457611e50565b6001915050610577565b60ff841115611e4557611e45611d7a565b50506001821b610577565b5060208310610133831016604e8410600b8410161715611e73575081810a610577565b611e7d8383611db5565b8060001904821115611e9157611e91611d7a565b029392505050565b6000610fe560ff841683611df8565b6000600019821415611ebc57611ebc611d7a565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600082821015611eeb57611eeb611d7a565b500390565b634e487b7160e01b600052601260045260246000fd5b60008219821115611f1957611f19611d7a565b500190565b60005b83811015611f39578181015183820152602001611f21565b83811115610a715750506000910152565b60008151808452611f62816020860160208601611f1e565b601f01601f19169290920160200192915050565b600061010060018060a01b03808c16845260208b8186015260408b81870152606063ffffffff8c1681880152608061ffff8c16818901528560a0890152611fbf8689018c611f4a565b8a861660c08a015288810360e08a01528951808252858b0197509085019060005b81811015612027578851805160038110611ffc57611ffc611820565b8452808801518885015286810151878501528501518816858401529786019791830191600101611fe0565b5050809750505050505050509998505050505050505050565b60006020828403121561205257600080fd5b5051919050565b6000835161206b818460208801611f1e565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b600082516120a2818460208701611f1e565b9190910192915050565b602081526000610fe56020830184611f4a56fea2646970667358221220a9e5069554f96c6a57ba44265d59a41b3c306970bd183876c9b957d70904aa1c64736f6c63430008090033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80637d458e7b1161008c578063c66b8ed211610066578063c66b8ed214610248578063dc003d5a1461026e578063eafef46e14610294578063fd7b2d91146102bb57600080fd5b80637d458e7b14610202578063bfb40bc014610222578063c1abfa111461023557600080fd5b80631409a2e4146100d45780631dcaa70d146100e957806349ce899714610119578063592113d0146101bb5780635ec77a81146101dc5780637479208b146101ef575b600080fd5b6100e76100e23660046117d9565b6102e2565b005b6100fc6100f7366004611807565b6104dc565b6040516001600160a01b0390911681526020015b60405180910390f35b6101a4610127366004611807565b6065602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154949563ffffffff8086169664010000000087049091169561ffff600160401b820416956001600160a01b03600160501b9092048216959094909360ff8216936101009092048316929091168b565b6040516101109b9a99989796959493929190611836565b6101ce6101c9366004611909565b61057d565b604051908152602001610110565b6100e76101ea3660046119c7565b610a06565b6101ce6101fd366004611a20565b610a77565b610215610210366004611807565b610bcd565b6040516101109190611a7f565b6100e7610230366004611807565b610be7565b6101ce610243366004611acc565b610ccd565b7f00000000000000000000000000000000000000000000000000000000000000006100fc565b7f00000000000000000000000000000000000000000000000000000000000000006100fc565b6100fc7f000000000000000000000000000000000000000000000000000000000000000081565b6100fc7f000000000000000000000000000000000000000000000000000000000000000081565b60008281526065602052604090206004015482906001600160a01b0361010090910416331461032c5760405162461bcd60e51b815260040161032390611b09565b60405180910390fd5b6000838152606560205260409020600601546001600160a01b031661035961016084016101408501611b40565b6001600160a01b0316146103c25760405162461bcd60e51b815260206004820152602a60248201527f5072696e636970616c20746f6b656e20616464726573732063616e6e6f74206260448201526932903ab83230ba32b21760b11b6064820152608401610323565b600083815260656020526040902060050154610120830135146104275760405162461bcd60e51b815260206004820152601c60248201527f4d61726b65742049642063616e6e6f7420626520757064617465642e000000006044820152606401610323565b600083815260656020526040902082906104418282611bb4565b5050600083815260656020526040902061045a90610e0f565b827f3639fd8e82fc21d99ff6df2a4a03995fa53f752fddd525d8a9aadccefa788aa061048e61012085016101008601611b40565b6101208501356104a661016087016101408801611b40565b604080516001600160a01b03948516815260208101939093529216818301528535606082015290519081900360800190a2505050565b604051633d36902960e01b8152600481018290526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633d3690299060240160206040518083038186803b15801561053f57600080fd5b505afa158015610553573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105779190611d3a565b92915050565b6000878152606560205260408120339061059681610e0f565b60018101546001600160a01b03878116600160501b90920416146105fc5760405162461bcd60e51b815260206004820152601c60248201527f4d69736d61746368696e6720636f6c6c61746572616c20746f6b656e000000006044820152606401610323565b600181015461ffff600160401b909104811690861610156106575760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420696e746572657374207261746560581b6044820152606401610323565b600181015463ffffffff640100000000909104811690851611156106bd5760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964206c6f616e206d6178206475726174696f6e000000000000006044820152606401610323565b60008a81526067602052604090206106d490610fbd565b15806106f3575060008a81526067602052604090206106f39083610fc7565b61073f5760405162461bcd60e51b815260206004820181905260248201527f756e617574686f72697a656420636f6d6d69746d656e7420626f72726f7765726044820152606401610323565b805489111561076e5780546040516375d44cf160e11b81526004810191909152602481018a9052604401610323565b60038101546004820154600183015460068401546000936107ac938e93919260ff909116916001600160a01b03600160501b90910481169116610a77565b9050808910156107d95760405163b744c71960e01b815260048101829052602481018a9052604401610323565b6002600483015460ff1660058111156107f4576107f4611820565b1480610817575060048083015460ff16600581111561081557610815611820565b145b1561088457886001146108845760405162461bcd60e51b815260206004820152602f60248201527f696e76616c696420636f6d6d69746d656e7420636f6c6c61746572616c20616d60448201526e6f756e7420666f722045524337323160881b6064820152608401610323565b6002600483015460ff16600581111561089f5761089f611820565b14806108c357506003600483015460ff1660058111156108c1576108c1611820565b145b1561092957878260020154146109295760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420636f6d6d69746d656e7420636f6c6c61746572616c20746f6044820152641ad95b925960da1b6064820152608401610323565b61097e8383600501548460060160009054906101000a90046001600160a01b03168d86600101600a9054906101000a90046001600160a01b03168e8e8960040160009054906101000a900460ff168d8f610fec565b93506109a1848360040160019054906101000a90046001600160a01b0316611116565b506109ac8b8b611178565b604080516001600160a01b0385168152602081018c90529081018590528b907f7839c0e772fbc0df2f1be83221fb8cd10f50be73dac060cbb277ee5c856219309060600160405180910390a2505050979650505050505050565b60008381526065602052604090206004015483906001600160a01b03610100909104163314610a475760405162461bcd60e51b815260040161032390611b09565b6000848152606760205260408120908181610a62828261178e565b50505050610a7184848461119f565b50505050565b600080846005811115610a8c57610a8c611820565b1415610a9a57506000610bc4565b600080836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610ad657600080fd5b505afa158015610aea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0e9190611d57565b90506001866005811115610b2457610b24611820565b1415610b9e57846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6357600080fd5b505afa158015610b77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9b9190611d57565b91505b610bbf88610bac8385611d90565b610bb790600a611e99565b89600161122c565b925050505b95945050505050565b60008181526067602052604090206060906105779061128b565b60008181526065602052604090206004015481906001600160a01b03610100909104163314610c285760405162461bcd60e51b815260040161032390611b09565b60008281526065602090815260408083208381556001810180546001600160f01b031916905560028101849055600381018490556004810180546001600160a81b03191690556005810184905560060180546001600160a01b031916905560679091528120908181610c9a828261178e565b50506040518492507fd278ecade1e148fd8320435541f72d6a02dff654c1577ae2cadecba16e8ef2149150600090a25050565b6066805460009182610cde83611ea8565b90915550905033610cf761012086016101008701611b40565b6001600160a01b031614610d4d5760405162461bcd60e51b815260206004820152601f60248201527f756e617574686f72697a656420636f6d6d69746d656e742063726561746f72006044820152606401610323565b60008181526065602052604090208490610d678282611bb4565b50506000818152606560205260409020610d8090610e0f565b610d8b81848461119f565b807f16b531d6c0bbff6da27b922e61fc528bb3ae5b435f9e56fb87e399afb6ae520a610dbf61012087016101008801611b40565b610120870135610dd761016089016101408a01611b40565b604080516001600160a01b03948516815260208101939093529216818301528735606082015290519081900360800190a29392505050565b600181015463ffffffff428116911611610e605760405162461bcd60e51b8152602060048201526012602482015271195e1c1a5c99590818dbdb5b5a5d1b595b9d60721b6044820152606401610323565b8054610eb85760405162461bcd60e51b815260206004820152602160248201527f636f6d6d69746d656e74207072696e636970616c20616c6c6f636174696f6e206044820152600360fc1b6064820152608401610323565b6000600482015460ff166005811115610ed357610ed3611820565b14610fba576000816003015411610f2c5760405162461bcd60e51b815260206004820152601d60248201527f636f6d6d69746d656e7420636f6c6c61746572616c20726174696f20300000006044820152606401610323565b6001600482015460ff166005811115610f4757610f47611820565b1415610fba57600281015415610fba5760405162461bcd60e51b815260206004820152603260248201527f636f6d6d69746d656e7420636f6c6c61746572616c20746f6b656e206964206d6044820152710757374206265203020666f722045524332360741b6064820152608401610323565b50565b6000610577825490565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6040805160e081018252606060a08201819052600060c083018190528c83526001600160a01b038c1660208401529282018a905263ffffffff85168183015261ffff841660808301528286600581111561104857611048611820565b146110fa5760408051600180825281830190925290816020015b60408051608081018252600080825260208083018290529282018190526060820152825260001990920191018161106257905050905060405180608001604052806110ac88611298565b60028111156110bd576110bd611820565b81526020018981526020018881526020018a6001600160a01b0316815250816000815181106110ee576110ee611ec3565b60200260200101819052505b61110582828f611380565b9d9c50505050505050505050505050565b600061116e63a8cb5d6860e01b8460405160240161113691815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915283611408565b5060019392505050565b60008281526065602052604081208054839290611196908490611ed9565b90915550505050565b60005b818110156111fb576111e88383838181106111bf576111bf611ec3565b90506020020160208101906111d49190611b40565b600086815260676020526040902090611460565b50806111f381611ea8565b9150506111a2565b5060405183907f04224de4972d2a55e811df57692f065a266ea975d06938d50b3cb33b498b161790600090a2505050565b60008061123a868686611475565b9050600183600281111561125057611250611820565b14801561126d57506000848061126857611268611ef0565b868809115b156112805761127d600182611f06565b90505b90505b949350505050565b60606000610fe583611525565b600060018260058111156112ae576112ae611820565b14156112bc57506000919050565b60028260058111156112d0576112d0611820565b14806112ed575060048260058111156112eb576112eb611820565b145b156112fa57506001919050565b600382600581111561130e5761130e611820565b148061132b5750600582600581111561132957611329611820565b145b1561133857506002919050565b60405162461bcd60e51b815260206004820152601760248201527f556e6b6e6f776e20436f6c6c61746572616c20547970650000000000000000006044820152606401610323565b600060606113f2856020015186600001518760400151886060015189608001518a60a001518b60c001518b6040516024016113c2989796959493929190611f76565b60408051601f198184030181529190526020810180516001600160e01b0316637bbd53d760e01b17905284611408565b905080806020019051810190610bc49190612040565b6060610fe58383604051602001611420929190612059565b60408051601f198184030181529190526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690611581565b6000610fe5836001600160a01b0384166115c5565b6000808060001985870985870292508281108382030391505080600014156114b0578382816114a6576114a6611ef0565b0492505050610fe5565b8084116114bc57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561157557602002820191906000526020600020905b815481526020019060010190808311611561575b50505050509050919050565b6060610fe5838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250611614565b600081815260018301602052604081205461160c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610577565b506000610577565b6060824710156116755760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610323565b600080866001600160a01b031685876040516116919190612090565b60006040518083038185875af1925050503d80600081146116ce576040519150601f19603f3d011682016040523d82523d6000602084013e6116d3565b606091505b50915091506116e4878383876116ef565b979650505050505050565b6060831561175b578251611754576001600160a01b0385163b6117545760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610323565b5081611283565b61128383838151156117705781518083602001fd5b8060405162461bcd60e51b815260040161032391906120ac565b5050565b5080546000825590600052602060002090810190610fba91905b808211156117bc57600081556001016117a8565b5090565b600061016082840312156117d357600080fd5b50919050565b60008061018083850312156117ed57600080fd5b823591506117fe84602085016117c0565b90509250929050565b60006020828403121561181957600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b8b815263ffffffff8b811660208301528a16604082015261ffff891660608201526001600160a01b038816608082015260a0810187905260c0810186905261016081016006861061188957611889611820565b8560e08301526118a56101008301866001600160a01b03169052565b836101208301526118c26101408301846001600160a01b03169052565b9c9b505050505050505050505050565b6001600160a01b0381168114610fba57600080fd5b61ffff81168114610fba57600080fd5b63ffffffff81168114610fba57600080fd5b600080600080600080600060e0888a03121561192457600080fd5b87359650602088013595506040880135945060608801359350608088013561194b816118d2565b925060a088013561195b816118e7565b915060c088013561196b816118f7565b8091505092959891949750929550565b60008083601f84011261198d57600080fd5b50813567ffffffffffffffff8111156119a557600080fd5b6020830191508360208260051b85010111156119c057600080fd5b9250929050565b6000806000604084860312156119dc57600080fd5b83359250602084013567ffffffffffffffff8111156119fa57600080fd5b611a068682870161197b565b9497909650939450505050565b60068110610fba57600080fd5b600080600080600060a08688031215611a3857600080fd5b85359450602086013593506040860135611a5181611a13565b92506060860135611a61816118d2565b91506080860135611a71816118d2565b809150509295509295909350565b6020808252825182820181905260009190848201906040850190845b81811015611ac05783516001600160a01b031683529284019291840191600101611a9b565b50909695505050505050565b60008060006101808486031215611ae257600080fd5b611aec85856117c0565b925061016084013567ffffffffffffffff8111156119fa57600080fd5b6020808252601e908201527f756e617574686f72697a656420636f6d6d69746d656e74206c656e6465720000604082015260600190565b600060208284031215611b5257600080fd5b8135610fe5816118d2565b60008135610577816118f7565b60008135610577816118e7565b60008135610577816118d2565b6000813561057781611a13565b60068210611ba157611ba1611820565b60ff1981541660ff831681178255505050565b8135815560018101611be2611bcb60208501611b5d565b825463ffffffff191663ffffffff91909116178255565b611c13611bf160408501611b5d565b825467ffffffff00000000191660209190911b67ffffffff0000000016178255565b611c48611c2260608501611b6a565b825469ffff0000000000000000191660409190911b69ffff000000000000000016178255565b611c96611c5760808501611b77565b8280547fffff0000000000000000000000000000000000000000ffffffffffffffffffff1660509290921b600160501b600160f01b0316919091179055565b5060a0820135600282015560c0820135600382015560048101611cc4611cbe60e08501611b84565b82611b91565b611cfa611cd46101008501611b77565b828054610100600160a81b03191660089290921b610100600160a81b0316919091179055565b50610120820135600582015561178a611d166101408401611b77565b6006830180546001600160a01b0319166001600160a01b0392909216919091179055565b600060208284031215611d4c57600080fd5b8151610fe5816118d2565b600060208284031215611d6957600080fd5b815160ff81168114610fe557600080fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff84168060ff03821115611dad57611dad611d7a565b019392505050565b600181815b80851115611df0578160001904821115611dd657611dd6611d7a565b80851615611de357918102915b93841c9390800290611dba565b509250929050565b600082611e0757506001610577565b81611e1457506000610577565b8160018114611e2a5760028114611e3457611e50565b6001915050610577565b60ff841115611e4557611e45611d7a565b50506001821b610577565b5060208310610133831016604e8410600b8410161715611e73575081810a610577565b611e7d8383611db5565b8060001904821115611e9157611e91611d7a565b029392505050565b6000610fe560ff841683611df8565b6000600019821415611ebc57611ebc611d7a565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600082821015611eeb57611eeb611d7a565b500390565b634e487b7160e01b600052601260045260246000fd5b60008219821115611f1957611f19611d7a565b500190565b60005b83811015611f39578181015183820152602001611f21565b83811115610a715750506000910152565b60008151808452611f62816020860160208601611f1e565b601f01601f19169290920160200192915050565b600061010060018060a01b03808c16845260208b8186015260408b81870152606063ffffffff8c1681880152608061ffff8c16818901528560a0890152611fbf8689018c611f4a565b8a861660c08a015288810360e08a01528951808252858b0197509085019060005b81811015612027578851805160038110611ffc57611ffc611820565b8452808801518885015286810151878501528501518816858401529786019791830191600101611fe0565b5050809750505050505050509998505050505050505050565b60006020828403121561205257600080fd5b5051919050565b6000835161206b818460208801611f1e565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b600082516120a2818460208701611f1e565b9190910192915050565b602081526000610fe56020830184611f4a56fea2646970667358221220a9e5069554f96c6a57ba44265d59a41b3c306970bd183876c9b957d70904aa1c64736f6c63430008090033", + "numDeployments": 1, + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_protocolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_marketRegistry\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"}],\"name\":\"InsufficientBorrowerCollateral\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"allocated\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"requested\",\"type\":\"uint256\"}],\"name\":\"InsufficientCommitmentAllocation\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lendingToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"}],\"name\":\"CreatedCommitment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"}],\"name\":\"DeletedCommitment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"ExercisedCommitment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"manager\",\"type\":\"address\"}],\"name\":\"UpdatedAllowlistManager\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lendingToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"}],\"name\":\"UpdatedCommitment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"}],\"name\":\"UpdatedCommitmentBorrowers\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_marketRegistry\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_tellerV2\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_principalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_collateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_collateralTokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"_interestRate\",\"type\":\"uint16\"},{\"internalType\":\"uint32\",\"name\":\"_loanDuration\",\"type\":\"uint32\"}],\"name\":\"acceptCommitment\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"commitmentAllowListManagers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"commitments\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"maxPrincipal\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"expiration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"minInterestRate\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxPrincipalPerCollateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"enum LenderCommitmentForwarder.CommitmentCollateralType\",\"name\":\"collateralTokenType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"principalTokenAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maxPrincipal\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"expiration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"minInterestRate\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxPrincipalPerCollateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"enum LenderCommitmentForwarder.CommitmentCollateralType\",\"name\":\"collateralTokenType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"principalTokenAddress\",\"type\":\"address\"}],\"internalType\":\"struct LenderCommitmentForwarder.Commitment\",\"name\":\"_commitment\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"borrowerAllowlistManager\",\"type\":\"address\"}],\"name\":\"createCommitment\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"commitmentId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"}],\"name\":\"deleteCommitment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"}],\"name\":\"getCommitmentLender\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"lender_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMarketRegistry\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_principalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxPrincipalPerCollateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"enum LenderCommitmentForwarder.CommitmentCollateralType\",\"name\":\"_collateralTokenType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"_collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_principalTokenAddress\",\"type\":\"address\"}],\"name\":\"getRequiredCollateral\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTellerV2\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"getTellerV2MarketOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_allowlistManager\",\"type\":\"address\"}],\"name\":\"updateAllowlistManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_commitmentId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maxPrincipal\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"expiration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"maxDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"minInterestRate\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"collateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxPrincipalPerCollateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"enum LenderCommitmentForwarder.CommitmentCollateralType\",\"name\":\"collateralTokenType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"principalTokenAddress\",\"type\":\"address\"}],\"internalType\":\"struct LenderCommitmentForwarder.Commitment\",\"name\":\"_commitment\",\"type\":\"tuple\"}],\"name\":\"updateCommitment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"CreatedCommitment(uint256,address,uint256,address,uint256)\":{\"params\":{\"lender\":\"The address of the lender.\",\"lendingToken\":\"The address of the asset being committed.\",\"marketId\":\"The Id of the market the commitment applies to.\",\"tokenAmount\":\"The amount of the asset being committed.\"}},\"DeletedCommitment(uint256)\":{\"params\":{\"commitmentId\":\"The id of the commitment that was deleted.\"}},\"ExercisedCommitment(uint256,address,uint256,uint256)\":{\"params\":{\"bidId\":\"The bid id for the loan from TellerV2.\",\"borrower\":\"The address of the borrower.\",\"commitmentId\":\"The id of the commitment that was exercised.\",\"tokenAmount\":\"The amount of the asset being committed.\"}},\"UpdatedCommitment(uint256,address,uint256,address,uint256)\":{\"params\":{\"commitmentId\":\"The id of the commitment that was updated.\",\"lender\":\"The address of the lender.\",\"lendingToken\":\"The address of the asset being committed.\",\"marketId\":\"The Id of the market the commitment applies to.\",\"tokenAmount\":\"The amount of the asset being committed.\"}},\"UpdatedCommitmentBorrowers(uint256)\":{\"params\":{\"commitmentId\":\"The id of the commitment that was updated.\"}}},\"kind\":\"dev\",\"methods\":{\"acceptCommitment(uint256,uint256,uint256,uint256,address,uint16,uint32)\":{\"details\":\"LoanDuration must be longer than the market payment cycle\",\"params\":{\"_collateralAmount\":\"The amount of collateral to use for the loan.\",\"_collateralTokenAddress\":\"The contract address to use for the loan collateral tokens.\",\"_collateralTokenId\":\"The tokenId of collateral to use for the loan if ERC721 or ERC1155.\",\"_commitmentId\":\"The id of the commitment being accepted.\",\"_interestRate\":\"The interest rate APY to use for the loan in basis points.\",\"_loanDuration\":\"The overall duration for the loan. Must be longer than market payment cycle duration.\",\"_principalAmount\":\"The amount of currency to borrow for the loan.\"},\"returns\":{\"bidId\":\"The ID of the loan that was created on TellerV2\"}},\"createCommitment((uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address),address)\":{\"params\":{\"_commitment\":\"The new commitment data expressed as a struct\",\"borrowerAllowlistManager\":\"The address of the allowlist contract \"},\"returns\":{\"commitmentId_\":\"returns the commitmentId for the created commitment\"}},\"deleteCommitment(uint256)\":{\"params\":{\"_commitmentId\":\"The id of the commitment to delete.\"}},\"getRequiredCollateral(uint256,uint256,uint8,address,address)\":{\"params\":{\"_collateralTokenAddress\":\"The contract address for the collateral for the loan.\",\"_collateralTokenType\":\"The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\",\"_maxPrincipalPerCollateralAmount\":\"The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\",\"_principalAmount\":\"The amount of currency to borrow for the loan.\",\"_principalTokenAddress\":\"The contract address for the principal for the loan.\"}},\"updateCommitment(uint256,(uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address))\":{\"params\":{\"_commitment\":\"The new commitment data expressed as a struct\",\"_commitmentId\":\"The Id of the commitment to update.\"}}},\"version\":1},\"userdoc\":{\"events\":{\"CreatedCommitment(uint256,address,uint256,address,uint256)\":{\"notice\":\"This event is emitted when a lender's commitment is created.\"},\"DeletedCommitment(uint256)\":{\"notice\":\"This event is emitted when a lender's commitment has been deleted.\"},\"ExercisedCommitment(uint256,address,uint256,uint256)\":{\"notice\":\"This event is emitted when a lender's commitment is exercised for a loan.\"},\"UpdatedCommitment(uint256,address,uint256,address,uint256)\":{\"notice\":\"This event is emitted when a lender's commitment is updated.\"},\"UpdatedCommitmentBorrowers(uint256)\":{\"notice\":\"This event is emitted when the allowed borrowers for a commitment is updated.\"}},\"kind\":\"user\",\"methods\":{\"acceptCommitment(uint256,uint256,uint256,uint256,address,uint16,uint32)\":{\"notice\":\"Accept the commitment to submitBid and acceptBid using the funds\"},\"constructor\":{\"notice\":\"External Functions *\"},\"createCommitment((uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address),address)\":{\"notice\":\"Creates a loan commitment from a lender for a market.\"},\"deleteCommitment(uint256)\":{\"notice\":\"Removes the commitment of a lender to a market.\"},\"getRequiredCollateral(uint256,uint256,uint8,address,address)\":{\"notice\":\"Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\"},\"updateCommitment(uint256,(uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address))\":{\"notice\":\"Updates the commitment of a lender to a market.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/LenderCommitmentForwarder.sol\":\"LenderCommitmentForwarder\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x605434219ebbe4653f703640f06969faa5a1d78f0bfef878e5ddbb1ca369ceeb\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\n */\\nlibrary EnumerableSetUpgradeable {\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0x4807db844a856813048b5af81a764fdd25a0ae8876a3132593e8d21ddc6b607c\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/LenderCommitmentForwarder.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// Contracts\\nimport \\\"./TellerV2MarketForwarder.sol\\\";\\n\\n// Interfaces\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\n\\nimport \\\"./interfaces/allowlist/IAllowlistManager.sol\\\";\\nimport \\\"./interfaces/allowlist/IEnumerableSetAllowlist.sol\\\";\\n\\nimport \\\"./interfaces/ILenderCommitmentForwarder.sol\\\";\\n\\nimport { Collateral, CollateralType } from \\\"./interfaces/escrow/ICollateralEscrowV1.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\\\";\\n\\n// Libraries\\nimport { MathUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\\\";\\n\\n\\n\\n\\ncontract LenderCommitmentForwarder is TellerV2MarketForwarder, ILenderCommitmentForwarder {\\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\\n\\n enum CommitmentCollateralType {\\n NONE, // no collateral required\\n ERC20,\\n ERC721,\\n ERC1155,\\n ERC721_ANY_ID,\\n ERC1155_ANY_ID\\n }\\n\\n /**\\n * @notice Details about a lender's capital commitment.\\n * @param maxPrincipal Amount of tokens being committed by the lender. Max amount that can be loaned.\\n * @param expiration Expiration time in seconds, when the commitment expires.\\n * @param maxDuration Length of time, in seconds that the lender's capital can be lent out for.\\n * @param minInterestRate Minimum Annual percentage to be applied for loans using the lender's capital.\\n * @param collateralTokenAddress The address for the token contract that must be used to provide collateral for loans for this commitment.\\n * @param maxPrincipalPerCollateralAmount The amount of principal that can be used for a loan per each unit of collateral, expanded additionally by principal decimals.\\n * @param collateralTokenType The type of asset of the collateralTokenAddress (ERC20, ERC721, or ERC1155).\\n * @param lender The address of the lender for this commitment.\\n * @param marketId The market id for this commitment.\\n * @param principalTokenAddress The address for the token contract that will be used to provide principal for loans of this commitment.\\n */\\n struct Commitment {\\n uint256 maxPrincipal;\\n uint32 expiration;\\n uint32 maxDuration;\\n uint16 minInterestRate;\\n address collateralTokenAddress;\\n uint256 collateralTokenId;\\n uint256 maxPrincipalPerCollateralAmount;\\n CommitmentCollateralType collateralTokenType;\\n address lender;\\n uint256 marketId;\\n address principalTokenAddress;\\n }\\n\\n // CommitmentId => commitment\\n mapping(uint256 => Commitment) public commitments;\\n\\n uint256 commitmentCount;\\n\\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet)\\n internal __commitmentBorrowersList; //DEPRECATED -> moved to manager\\n\\n mapping(uint256 => address) public commitmentAllowListManagers;\\n\\n /**\\n * @notice This event is emitted when a lender's commitment is created.\\n * @param lender The address of the lender.\\n * @param marketId The Id of the market the commitment applies to.\\n * @param lendingToken The address of the asset being committed.\\n * @param tokenAmount The amount of the asset being committed.\\n */\\n event CreatedCommitment(\\n uint256 indexed commitmentId,\\n address lender,\\n uint256 marketId,\\n address lendingToken,\\n uint256 tokenAmount\\n );\\n\\n /**\\n * @notice This event is emitted when a lender's commitment is updated.\\n * @param commitmentId The id of the commitment that was updated.\\n * @param lender The address of the lender.\\n * @param marketId The Id of the market the commitment applies to.\\n * @param lendingToken The address of the asset being committed.\\n * @param tokenAmount The amount of the asset being committed.\\n */\\n event UpdatedCommitment(\\n uint256 indexed commitmentId,\\n address lender,\\n uint256 marketId,\\n address lendingToken,\\n uint256 tokenAmount\\n );\\n\\n event UpdatedAllowlistManager(\\n uint256 indexed commitmentId,\\n address manager\\n );\\n\\n /**\\n * @notice This event is emitted when the allowed borrowers for a commitment is updated.\\n * @param commitmentId The id of the commitment that was updated.\\n */\\n event UpdatedCommitmentBorrowers(uint256 indexed commitmentId);\\n\\n /**\\n * @notice This event is emitted when a lender's commitment has been deleted.\\n * @param commitmentId The id of the commitment that was deleted.\\n */\\n event DeletedCommitment(uint256 indexed commitmentId);\\n\\n /**\\n * @notice This event is emitted when a lender's commitment is exercised for a loan.\\n * @param commitmentId The id of the commitment that was exercised.\\n * @param borrower The address of the borrower.\\n * @param tokenAmount The amount of the asset being committed.\\n * @param bidId The bid id for the loan from TellerV2.\\n */\\n event ExercisedCommitment(\\n uint256 indexed commitmentId,\\n address borrower,\\n uint256 tokenAmount,\\n uint256 bidId\\n );\\n\\n error InsufficientCommitmentAllocation(\\n uint256 allocated,\\n uint256 requested\\n );\\n error InsufficientBorrowerCollateral(uint256 required, uint256 actual);\\n\\n /** Modifiers **/\\n\\n modifier commitmentLender(uint256 _commitmentId) {\\n require(\\n commitments[_commitmentId].lender == _msgSender(),\\n \\\"unauthorized commitment lender\\\"\\n );\\n _;\\n }\\n\\n\\n function getCommitmentLender(uint256 _commitmentId) public returns (address lender_){\\n lender_ = commitments[_commitmentId].lender;\\n }\\n\\n function validateCommitment(Commitment storage _commitment) internal {\\n require(\\n _commitment.expiration > uint32(block.timestamp),\\n \\\"expired commitment\\\"\\n );\\n require(\\n _commitment.maxPrincipal > 0,\\n \\\"commitment principal allocation 0\\\"\\n );\\n\\n if (_commitment.collateralTokenType != CommitmentCollateralType.NONE) {\\n require(\\n _commitment.maxPrincipalPerCollateralAmount > 0,\\n \\\"commitment collateral ratio 0\\\"\\n );\\n\\n if (\\n _commitment.collateralTokenType ==\\n CommitmentCollateralType.ERC20\\n ) {\\n require(\\n _commitment.collateralTokenId == 0,\\n \\\"commitment collateral token id must be 0 for ERC20\\\"\\n );\\n }\\n }\\n }\\n\\n /** External Functions **/\\n\\n constructor(address _protocolAddress, address _marketRegistry)\\n TellerV2MarketForwarder(_protocolAddress, _marketRegistry)\\n {}\\n\\n /**\\n * @notice Creates a loan commitment from a lender for a market.\\n * @param _commitment The new commitment data expressed as a struct\\n * @param borrowerAllowlistManager The address of the allowlist contract \\n * @return commitmentId_ returns the commitmentId for the created commitment\\n */\\n function createCommitment(\\n Commitment calldata _commitment,\\n address borrowerAllowlistManager\\n ) public returns (uint256 commitmentId_) {\\n commitmentId_ = commitmentCount++;\\n\\n require(\\n _commitment.lender == _msgSender(),\\n \\\"unauthorized commitment creator\\\"\\n );\\n\\n commitments[commitmentId_] = _commitment;\\n commitmentAllowListManagers[commitmentId_] = borrowerAllowlistManager;\\n\\n validateCommitment(commitments[commitmentId_]);\\n\\n //_addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList);\\n\\n emit CreatedCommitment(\\n commitmentId_,\\n _commitment.lender,\\n _commitment.marketId,\\n _commitment.principalTokenAddress,\\n _commitment.maxPrincipal\\n );\\n\\n emit UpdatedAllowlistManager(\\n commitmentId_,\\n borrowerAllowlistManager\\n );\\n }\\n\\n /**\\n * @notice Updates the commitment of a lender to a market.\\n * @param _commitmentId The Id of the commitment to update.\\n * @param _commitment The new commitment data expressed as a struct\\n */\\n function updateCommitment(\\n uint256 _commitmentId,\\n Commitment calldata _commitment\\n ) public commitmentLender(_commitmentId) {\\n require(\\n _commitment.principalTokenAddress ==\\n commitments[_commitmentId].principalTokenAddress,\\n \\\"Principal token address cannot be updated.\\\"\\n );\\n require(\\n _commitment.marketId == commitments[_commitmentId].marketId,\\n \\\"Market Id cannot be updated.\\\"\\n );\\n\\n commitments[_commitmentId] = _commitment;\\n\\n validateCommitment(commitments[_commitmentId]);\\n\\n emit UpdatedCommitment(\\n _commitmentId,\\n _commitment.lender,\\n _commitment.marketId,\\n _commitment.principalTokenAddress,\\n _commitment.maxPrincipal\\n );\\n }\\n\\n function updateAllowlistManager(\\n uint256 _commitmentId,\\n address _allowlistManager\\n ) public commitmentLender(_commitmentId) {\\n \\n commitmentAllowListManagers[_commitmentId] = _allowlistManager;\\n\\n emit UpdatedAllowlistManager(_commitmentId,_allowlistManager);\\n }\\n \\n\\n /**\\n * @notice Removes the commitment of a lender to a market.\\n * @param _commitmentId The id of the commitment to delete.\\n */\\n function deleteCommitment(uint256 _commitmentId)\\n public\\n commitmentLender(_commitmentId)\\n {\\n delete commitments[_commitmentId];\\n //delete commitmentBorrowersList[_commitmentId];\\n emit DeletedCommitment(_commitmentId);\\n }\\n\\n /**\\n * @notice Reduces the commitment amount for a lender to a market.\\n * @param _commitmentId The id of the commitment to modify.\\n * @param _tokenAmountDelta The amount of change in the maxPrincipal.\\n */\\n function _decrementCommitment(\\n uint256 _commitmentId,\\n uint256 _tokenAmountDelta\\n ) internal {\\n commitments[_commitmentId].maxPrincipal -= _tokenAmountDelta;\\n }\\n\\n /**\\n * @notice Accept the commitment to submitBid and acceptBid using the funds\\n * @dev LoanDuration must be longer than the market payment cycle\\n * @param _commitmentId The id of the commitment being accepted.\\n * @param _principalAmount The amount of currency to borrow for the loan.\\n * @param _collateralAmount The amount of collateral to use for the loan.\\n * @param _collateralTokenId The tokenId of collateral to use for the loan if ERC721 or ERC1155.\\n * @param _collateralTokenAddress The contract address to use for the loan collateral tokens.\\n * @param _interestRate The interest rate APY to use for the loan in basis points.\\n * @param _loanDuration The overall duration for the loan. Must be longer than market payment cycle duration.\\n * @return bidId The ID of the loan that was created on TellerV2\\n */\\n function acceptCommitment(\\n uint256 _commitmentId,\\n uint256 _principalAmount,\\n uint256 _collateralAmount,\\n uint256 _collateralTokenId,\\n address _collateralTokenAddress,\\n uint16 _interestRate,\\n uint32 _loanDuration\\n ) external returns (uint256 bidId) {\\n address borrower = _msgSender();\\n\\n Commitment storage commitment = commitments[_commitmentId];\\n\\n validateCommitment(commitment);\\n\\n require(\\n _collateralTokenAddress == commitment.collateralTokenAddress,\\n \\\"Mismatching collateral token\\\"\\n );\\n require(\\n _interestRate >= commitment.minInterestRate,\\n \\\"Invalid interest rate\\\"\\n );\\n require(\\n _loanDuration <= commitment.maxDuration,\\n \\\"Invalid loan max duration\\\"\\n );\\n\\n require(\\n __commitmentBorrowersList[_commitmentId].length() == 0 ||\\n commitmentAllowListManagers[_commitmentId] != address(0),\\n \\\"Commitments with legacy borrower list must now set an allow list manager\\\"\\n ); \\n \\n\\n require(commitmentAllowListManagers[_commitmentId] == address(0) ||\\n IAllowlistManager(commitmentAllowListManagers[_commitmentId]).addressIsAllowed(\\n _commitmentId, borrower\\n ),\\n \\\"Borrower not allowlisted\\\"\\n );\\n \\n\\n if (_principalAmount > commitment.maxPrincipal) {\\n revert InsufficientCommitmentAllocation({\\n allocated: commitment.maxPrincipal,\\n requested: _principalAmount\\n });\\n }\\n\\n uint256 requiredCollateral = getRequiredCollateral(\\n _principalAmount,\\n commitment.maxPrincipalPerCollateralAmount,\\n commitment.collateralTokenType,\\n commitment.collateralTokenAddress,\\n commitment.principalTokenAddress\\n );\\n if (_collateralAmount < requiredCollateral) {\\n revert InsufficientBorrowerCollateral({\\n required: requiredCollateral,\\n actual: _collateralAmount\\n });\\n }\\n\\n if (\\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\\n commitment.collateralTokenType ==\\n CommitmentCollateralType.ERC721_ANY_ID\\n ) {\\n require(\\n _collateralAmount == 1,\\n \\\"invalid commitment collateral amount for ERC721\\\"\\n );\\n }\\n\\n if (\\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\\n commitment.collateralTokenType == CommitmentCollateralType.ERC1155\\n ) {\\n require(\\n commitment.collateralTokenId == _collateralTokenId,\\n \\\"invalid commitment collateral tokenId\\\"\\n );\\n }\\n\\n bidId = _submitBidFromCommitment(\\n borrower,\\n commitment.marketId,\\n commitment.principalTokenAddress,\\n _principalAmount,\\n commitment.collateralTokenAddress,\\n _collateralAmount,\\n _collateralTokenId,\\n commitment.collateralTokenType,\\n _loanDuration,\\n _interestRate\\n );\\n\\n _acceptBid(bidId, commitment.lender);\\n\\n _decrementCommitment(_commitmentId, _principalAmount);\\n\\n emit ExercisedCommitment(\\n _commitmentId,\\n borrower,\\n _principalAmount,\\n bidId\\n );\\n }\\n\\n \\n\\n /**\\n * @notice Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\\n * @param _principalAmount The amount of currency to borrow for the loan.\\n * @param _maxPrincipalPerCollateralAmount The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\\n * @param _collateralTokenType The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\\n * @param _collateralTokenAddress The contract address for the collateral for the loan.\\n * @param _principalTokenAddress The contract address for the principal for the loan.\\n */\\n function getRequiredCollateral(\\n uint256 _principalAmount,\\n uint256 _maxPrincipalPerCollateralAmount,\\n CommitmentCollateralType _collateralTokenType,\\n address _collateralTokenAddress,\\n address _principalTokenAddress\\n ) public view virtual returns (uint256) {\\n if (_collateralTokenType == CommitmentCollateralType.NONE) {\\n return 0;\\n }\\n\\n uint8 collateralDecimals;\\n uint8 principalDecimals = IERC20MetadataUpgradeable(\\n _principalTokenAddress\\n ).decimals();\\n\\n if (_collateralTokenType == CommitmentCollateralType.ERC20) {\\n collateralDecimals = IERC20MetadataUpgradeable(\\n _collateralTokenAddress\\n ).decimals();\\n }\\n\\n /*\\n * The principalAmount is expanded by (collateralDecimals+principalDecimals) to increase precision\\n * and then it is divided by _maxPrincipalPerCollateralAmount which should already been expanded by principalDecimals\\n */\\n return\\n MathUpgradeable.mulDiv(\\n _principalAmount,\\n (10**(collateralDecimals + principalDecimals)),\\n _maxPrincipalPerCollateralAmount,\\n MathUpgradeable.Rounding.Up\\n );\\n }\\n\\n /**\\n * @notice Return the array of borrowers that are allowlisted for a commitment\\n * @param _commitmentId The commitment id for the commitment to query.\\n * @return borrowers_ An array of addresses restricted to accept the commitment. Empty array means unrestricted.\\n */\\n /* function getCommitmentBorrowers(uint256 _commitmentId)\\n external\\n view\\n returns (address[] memory borrowers_)\\n {\\n borrowers_ = commitmentBorrowersList[_commitmentId].values();\\n }*/\\n\\n /**\\n * @notice Internal function to submit a bid to the lending protocol using a commitment\\n * @param _borrower The address of the borrower for the loan.\\n * @param _marketId The id for the market of the loan in the lending protocol.\\n * @param _principalTokenAddress The contract address for the principal token.\\n * @param _principalAmount The amount of principal to borrow for the loan.\\n * @param _collateralTokenAddress The contract address for the collateral token.\\n * @param _collateralAmount The amount of collateral to use for the loan.\\n * @param _collateralTokenId The tokenId for the collateral (if it is ERC721 or ERC1155).\\n * @param _collateralTokenType The type of collateral token (ERC20,ERC721,ERC1177,None).\\n * @param _loanDuration The duration of the loan in seconds delta. Must be longer than loan payment cycle for the market.\\n * @param _interestRate The amount of interest APY for the loan expressed in basis points.\\n */\\n function _submitBidFromCommitment(\\n address _borrower,\\n uint256 _marketId,\\n address _principalTokenAddress,\\n uint256 _principalAmount,\\n address _collateralTokenAddress,\\n uint256 _collateralAmount,\\n uint256 _collateralTokenId,\\n CommitmentCollateralType _collateralTokenType,\\n uint32 _loanDuration,\\n uint16 _interestRate\\n ) internal returns (uint256 bidId) {\\n CreateLoanArgs memory createLoanArgs;\\n createLoanArgs.marketId = _marketId;\\n createLoanArgs.lendingToken = _principalTokenAddress;\\n createLoanArgs.principal = _principalAmount;\\n createLoanArgs.duration = _loanDuration;\\n createLoanArgs.interestRate = _interestRate;\\n\\n Collateral[] memory collateralInfo;\\n if (_collateralTokenType != CommitmentCollateralType.NONE) {\\n collateralInfo = new Collateral[](1);\\n collateralInfo[0] = Collateral({\\n _collateralType: _getEscrowCollateralType(_collateralTokenType),\\n _tokenId: _collateralTokenId,\\n _amount: _collateralAmount,\\n _collateralAddress: _collateralTokenAddress\\n });\\n }\\n\\n bidId = _submitBidWithCollateral(\\n createLoanArgs,\\n collateralInfo,\\n _borrower\\n );\\n }\\n\\n /**\\n * @notice Return the collateral type based on the commitmentcollateral type. Collateral type is used in the base lending protocol.\\n * @param _type The type of collateral to be used for the loan.\\n */\\n function _getEscrowCollateralType(CommitmentCollateralType _type)\\n internal\\n pure\\n returns (CollateralType)\\n {\\n if (_type == CommitmentCollateralType.ERC20) {\\n return CollateralType.ERC20;\\n }\\n if (\\n _type == CommitmentCollateralType.ERC721 ||\\n _type == CommitmentCollateralType.ERC721_ANY_ID\\n ) {\\n return CollateralType.ERC721;\\n }\\n if (\\n _type == CommitmentCollateralType.ERC1155 ||\\n _type == CommitmentCollateralType.ERC1155_ANY_ID\\n ) {\\n return CollateralType.ERC1155;\\n }\\n\\n revert(\\\"Unknown Collateral Type\\\");\\n }\\n}\\n\",\"keccak256\":\"0x293718cdb83f512ae6002fe788f366ad3e0d5d827e811754c2e30c26117d3b7f\",\"license\":\"MIT\"},\"contracts/TellerV2MarketForwarder.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\n\\nimport \\\"./interfaces/IMarketRegistry.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\\\";\\n\\n/**\\n * @dev Simple helper contract to forward an encoded function call to the TellerV2 contract. See {TellerV2Context}\\n */\\nabstract contract TellerV2MarketForwarder is Initializable, ContextUpgradeable {\\n using AddressUpgradeable for address;\\n\\n address public immutable _tellerV2;\\n address public immutable _marketRegistry;\\n\\n struct CreateLoanArgs {\\n uint256 marketId;\\n address lendingToken;\\n uint256 principal;\\n uint32 duration;\\n uint16 interestRate;\\n string metadataURI;\\n address recipient;\\n }\\n\\n constructor(address _protocolAddress, address _marketRegistryAddress) {\\n _tellerV2 = _protocolAddress;\\n _marketRegistry = _marketRegistryAddress;\\n }\\n\\n function getTellerV2() public view returns (address) {\\n return _tellerV2;\\n }\\n\\n function getMarketRegistry() public view returns (address) {\\n return _marketRegistry;\\n }\\n\\n function getTellerV2MarketOwner(uint256 marketId) public returns (address) {\\n return IMarketRegistry(getMarketRegistry()).getMarketOwner(marketId);\\n }\\n\\n /**\\n * @dev Performs function call to the TellerV2 contract by appending an address to the calldata.\\n * @param _data The encoded function calldata on TellerV2.\\n * @param _msgSender The address that should be treated as the underlying function caller.\\n * @return The encoded response from the called function.\\n *\\n * Requirements:\\n * - The {_msgSender} address must set an approval on TellerV2 for this forwarder contract __before__ making this call.\\n */\\n function _forwardCall(bytes memory _data, address _msgSender)\\n internal\\n returns (bytes memory)\\n {\\n return\\n address(_tellerV2).functionCall(\\n abi.encodePacked(_data, _msgSender)\\n );\\n }\\n\\n /**\\n * @notice Creates a new loan using the TellerV2 lending protocol.\\n * @param _createLoanArgs Details describing the loan agreement.]\\n * @param _borrower The borrower address for the new loan.\\n */\\n function _submitBid(\\n CreateLoanArgs memory _createLoanArgs,\\n address _borrower\\n ) internal virtual returns (uint256 bidId) {\\n bytes memory responseData;\\n\\n responseData = _forwardCall(\\n abi.encodeWithSignature(\\n \\\"submitBid(address,uint256,uint256,uint32,uint16,string,address)\\\",\\n _createLoanArgs.lendingToken,\\n _createLoanArgs.marketId,\\n _createLoanArgs.principal,\\n _createLoanArgs.duration,\\n _createLoanArgs.interestRate,\\n _createLoanArgs.metadataURI,\\n _createLoanArgs.recipient\\n ),\\n _borrower\\n );\\n\\n return abi.decode(responseData, (uint256));\\n }\\n\\n /**\\n * @notice Creates a new loan using the TellerV2 lending protocol.\\n * @param _createLoanArgs Details describing the loan agreement.]\\n * @param _borrower The borrower address for the new loan.\\n */\\n function _submitBidWithCollateral(\\n CreateLoanArgs memory _createLoanArgs,\\n Collateral[] memory _collateralInfo,\\n address _borrower\\n ) internal virtual returns (uint256 bidId) {\\n bytes memory responseData;\\n\\n responseData = _forwardCall(\\n abi.encodeWithSignature(\\n \\\"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\\\",\\n _createLoanArgs.lendingToken,\\n _createLoanArgs.marketId,\\n _createLoanArgs.principal,\\n _createLoanArgs.duration,\\n _createLoanArgs.interestRate,\\n _createLoanArgs.metadataURI,\\n _createLoanArgs.recipient,\\n _collateralInfo\\n ),\\n _borrower\\n );\\n\\n return abi.decode(responseData, (uint256));\\n }\\n\\n /**\\n * @notice Accepts a new loan using the TellerV2 lending protocol.\\n * @param _bidId The id of the new loan.\\n * @param _lender The address of the lender who will provide funds for the new loan.\\n */\\n function _acceptBid(uint256 _bidId, address _lender)\\n internal\\n virtual\\n returns (bool)\\n {\\n // Approve the borrower's loan\\n _forwardCall(\\n abi.encodeWithSelector(ITellerV2.lenderAcceptBid.selector, _bidId),\\n _lender\\n );\\n\\n return true;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0xa5820f997a7e78d2902d3d35eadcbff28a589b5545d023b07acd085f8fc089e8\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\\n external\\n view\\n returns (uint256 _amount);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x27778a3446cdbfed6356d5047f9926231261b37def2712a3cc63e3779350e5e4\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderCommitmentForwarder.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\n \\ninterface ILenderCommitmentForwarder {\\n\\n function getCommitmentLender(uint256 _commitmentId) external returns (address lender_);\\n\\n}\\n\",\"keccak256\":\"0x9f9fad9535bd1750d3dad338aa8394f805fd1be13859b12a65a75fc1e8c36f76\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanLiquidateable(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n\\n function getLoanSummary(uint256 _bidId)\\n external\\n view\\n returns (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n );\\n}\\n\",\"keccak256\":\"0x2750d9717451e34323ef523810ff2a3a6285f146009955220d3860a7c4326077\",\"license\":\"MIT\"},\"contracts/interfaces/allowlist/IAllowlistManager.sol\":{\"content\":\"\\n\\n\\ninterface IAllowlistManager {\\n\\n \\n function addressIsAllowed(uint256 _commitmentId,address _account) external returns (bool allowed_) ;\\n \\n}\",\"keccak256\":\"0x98b599ad422554ec62b370cad7c7c976a8698b4eb416229e07282f7fc0925ad5\"},\"contracts/interfaces/allowlist/IEnumerableSetAllowlist.sol\":{\"content\":\"\\n\\n\\ninterface IEnumerableSetAllowlist {\\n \\n function setAllowlist(\\n uint256 _commitmentId,\\n address[] calldata _addressList\\n ) external;\\n \\n}\",\"keccak256\":\"0x4958565de4c7816382725a8603ed7bbabe32c9e13150f16ae0fbafe7d8cd3027\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b506040516200216a3803806200216a833981016040819052620000349162000069565b6001600160a01b039182166080521660a052620000a1565b80516001600160a01b03811681146200006457600080fd5b919050565b600080604083850312156200007d57600080fd5b62000088836200004c565b915062000098602084016200004c565b90509250929050565b60805160a051612087620000e36000396000818161029f0152818161031501526105560152600081816102c5015281816102ee015261156001526120876000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c80637f11eb9f1161008c578063c66b8ed211610066578063c66b8ed21461029d578063dc003d5a146102c3578063eafef46e146102e9578063fd7b2d911461031057600080fd5b80637f11eb9f1461024e5780639acf779614610261578063bfb40bc01461028a57600080fd5b806349ce8997116100c857806349ce899714610165578063592113d0146102075780637479208b146102285780637956aa181461023b57600080fd5b80631409a2e4146100ef5780631dcaa70d146101045780632888115a14610134575b600080fd5b6101026100fd366004611808565b610337565b005b610117610112366004611836565b610535565b6040516001600160a01b0390911681526020015b60405180910390f35b610117610142366004611836565b60009081526065602052604090206004015461010090046001600160a01b031690565b6101f0610173366004611836565b6065602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154949563ffffffff8086169664010000000087049091169561ffff600160401b820416956001600160a01b03600160501b9092048216959094909360ff8216936101009092048316929091168b565b60405161012b9b9a99989796959493929190611865565b61021a610215366004611938565b6105d6565b60405190815260200161012b565b61021a6102363660046119b7565b610b97565b610102610249366004611a16565b610ced565b61021a61025c366004611a46565b610d8b565b61011761026f366004611836565b6068602052600090815260409020546001600160a01b031681565b610102610298366004611836565b610f22565b7f0000000000000000000000000000000000000000000000000000000000000000610117565b7f0000000000000000000000000000000000000000000000000000000000000000610117565b6101177f000000000000000000000000000000000000000000000000000000000000000081565b6101177f000000000000000000000000000000000000000000000000000000000000000081565b60008281526065602052604090206004015482906001600160a01b036101009091041633146103815760405162461bcd60e51b815260040161037890611a75565b60405180910390fd5b6000838152606560205260409020600601546001600160a01b03166103ae61016084016101408501611aac565b6001600160a01b0316146104175760405162461bcd60e51b815260206004820152602a60248201527f5072696e636970616c20746f6b656e20616464726573732063616e6e6f74206260448201526932903ab83230ba32b21760b11b6064820152608401610378565b6000838152606560205260409020600501546101208301351461047c5760405162461bcd60e51b815260206004820152601c60248201527f4d61726b65742049642063616e6e6f7420626520757064617465642e000000006044820152606401610378565b600083815260656020526040902082906104968282611b20565b505060008381526065602052604090206104af90610fe9565b827f3639fd8e82fc21d99ff6df2a4a03995fa53f752fddd525d8a9aadccefa788aa06104e361012085016101008601611aac565b6101208501356104fb61016087016101408801611aac565b604080516001600160a01b0394851681526020810193909352921691810191909152843560608201526080015b60405180910390a2505050565b604051633d36902960e01b8152600481018290526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633d3690299060240160206040518083038186803b15801561059857600080fd5b505afa1580156105ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d09190611ca6565b92915050565b600087815260656020526040812033906105ef81610fe9565b60018101546001600160a01b03878116600160501b90920416146106555760405162461bcd60e51b815260206004820152601c60248201527f4d69736d61746368696e6720636f6c6c61746572616c20746f6b656e000000006044820152606401610378565b600181015461ffff600160401b909104811690861610156106b05760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420696e746572657374207261746560581b6044820152606401610378565b600181015463ffffffff640100000000909104811690851611156107165760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964206c6f616e206d6178206475726174696f6e000000000000006044820152606401610378565b60008a815260676020526040902061072d90611197565b158061074f575060008a8152606860205260409020546001600160a01b031615155b6107d25760405162461bcd60e51b815260206004820152604860248201527f436f6d6d69746d656e74732077697468206c656761637920626f72726f77657260448201527f206c697374206d757374206e6f772073657420616e20616c6c6f77206c6973746064820152671036b0b730b3b2b960c11b608482015260a401610378565b60008a8152606860205260409020546001600160a01b03161580610884575060008a8152606860205260409081902054905163b0b5316d60e01b8152600481018c90526001600160a01b0384811660248301529091169063b0b5316d90604401602060405180830381600087803b15801561084c57600080fd5b505af1158015610860573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108849190611cc3565b6108d05760405162461bcd60e51b815260206004820152601860248201527f426f72726f776572206e6f7420616c6c6f776c697374656400000000000000006044820152606401610378565b80548911156108ff5780546040516375d44cf160e11b81526004810191909152602481018a9052604401610378565b600381015460048201546001830154600684015460009361093d938e93919260ff909116916001600160a01b03600160501b90910481169116610b97565b90508089101561096a5760405163b744c71960e01b815260048101829052602481018a9052604401610378565b6002600483015460ff1660058111156109855761098561184f565b14806109a8575060048083015460ff1660058111156109a6576109a661184f565b145b15610a155788600114610a155760405162461bcd60e51b815260206004820152602f60248201527f696e76616c696420636f6d6d69746d656e7420636f6c6c61746572616c20616d60448201526e6f756e7420666f722045524337323160881b6064820152608401610378565b6002600483015460ff166005811115610a3057610a3061184f565b1480610a5457506003600483015460ff166005811115610a5257610a5261184f565b145b15610aba5787826002015414610aba5760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420636f6d6d69746d656e7420636f6c6c61746572616c20746f6044820152641ad95b925960da1b6064820152608401610378565b610b0f8383600501548460060160009054906101000a90046001600160a01b03168d86600101600a9054906101000a90046001600160a01b03168e8e8960040160009054906101000a900460ff168d8f6111a1565b9350610b32848360040160019054906101000a90046001600160a01b03166112cb565b50610b3d8b8b61132d565b604080516001600160a01b0385168152602081018c90529081018590528b907f7839c0e772fbc0df2f1be83221fb8cd10f50be73dac060cbb277ee5c856219309060600160405180910390a2505050979650505050505050565b600080846005811115610bac57610bac61184f565b1415610bba57506000610ce4565b600080836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610bf657600080fd5b505afa158015610c0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2e9190611ce5565b90506001866005811115610c4457610c4461184f565b1415610cbe57846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8357600080fd5b505afa158015610c97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbb9190611ce5565b91505b610cdf88610ccc8385611d1e565b610cd790600a611e27565b896001611354565b925050505b95945050505050565b60008281526065602052604090206004015482906001600160a01b03610100909104163314610d2e5760405162461bcd60e51b815260040161037890611a75565b60008381526068602090815260409182902080546001600160a01b0319166001600160a01b038616908117909155915191825284917f4748b005ebf397dce7fe43edc3263879cc81595cca1c87c5dd29cba5a8c613199101610528565b6066805460009182610d9c83611e36565b90915550905033610db561012085016101008601611aac565b6001600160a01b031614610e0b5760405162461bcd60e51b815260206004820152601f60248201527f756e617574686f72697a656420636f6d6d69746d656e742063726561746f72006044820152606401610378565b60008181526065602052604090208390610e258282611b20565b5050600081815260686020908152604080832080546001600160a01b0319166001600160a01b03871617905560659091529020610e6190610fe9565b807f16b531d6c0bbff6da27b922e61fc528bb3ae5b435f9e56fb87e399afb6ae520a610e9561012086016101008701611aac565b610120860135610ead61016088016101408901611aac565b604080516001600160a01b03948516815260208101939093529216818301528635606082015290519081900360800190a26040516001600160a01b038316815281907f4748b005ebf397dce7fe43edc3263879cc81595cca1c87c5dd29cba5a8c613199060200160405180910390a292915050565b60008181526065602052604090206004015481906001600160a01b03610100909104163314610f635760405162461bcd60e51b815260040161037890611a75565b6000828152606560205260408082208281556001810180546001600160f01b031916905560028101839055600381018390556004810180546001600160a81b03191690556005810183905560060180546001600160a01b03191690555183917fd278ecade1e148fd8320435541f72d6a02dff654c1577ae2cadecba16e8ef21491a25050565b600181015463ffffffff42811691161161103a5760405162461bcd60e51b8152602060048201526012602482015271195e1c1a5c99590818dbdb5b5a5d1b595b9d60721b6044820152606401610378565b80546110925760405162461bcd60e51b815260206004820152602160248201527f636f6d6d69746d656e74207072696e636970616c20616c6c6f636174696f6e206044820152600360fc1b6064820152608401610378565b6000600482015460ff1660058111156110ad576110ad61184f565b146111945760008160030154116111065760405162461bcd60e51b815260206004820152601d60248201527f636f6d6d69746d656e7420636f6c6c61746572616c20726174696f20300000006044820152606401610378565b6001600482015460ff1660058111156111215761112161184f565b1415611194576002810154156111945760405162461bcd60e51b815260206004820152603260248201527f636f6d6d69746d656e7420636f6c6c61746572616c20746f6b656e206964206d6044820152710757374206265203020666f722045524332360741b6064820152608401610378565b50565b60006105d0825490565b6040805160e081018252606060a08201819052600060c083018190528c83526001600160a01b038c1660208401529282018a905263ffffffff85168183015261ffff84166080830152828660058111156111fd576111fd61184f565b146112af5760408051600180825281830190925290816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816112175790505090506040518060800160405280611261886113b3565b60028111156112725761127261184f565b81526020018981526020018881526020018a6001600160a01b0316815250816000815181106112a3576112a3611e51565b60200260200101819052505b6112ba82828f61149b565b9d9c50505050505050505050505050565b600061132363a8cb5d6860e01b846040516024016112eb91815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091528361152e565b5060019392505050565b6000828152606560205260408120805483929061134b908490611e67565b90915550505050565b600080611362868686611586565b905060018360028111156113785761137861184f565b14801561139557506000848061139057611390611e7e565b868809115b156113a8576113a5600182611e94565b90505b90505b949350505050565b600060018260058111156113c9576113c961184f565b14156113d757506000919050565b60028260058111156113eb576113eb61184f565b1480611408575060048260058111156114065761140661184f565b145b1561141557506001919050565b60038260058111156114295761142961184f565b1480611446575060058260058111156114445761144461184f565b145b1561145357506002919050565b60405162461bcd60e51b815260206004820152601760248201527f556e6b6e6f776e20436f6c6c61746572616c20547970650000000000000000006044820152606401610378565b6000606061150d856020015186600001518760400151886060015189608001518a60a001518b60c001518b6040516024016114dd989796959493929190611f08565b60408051601f198184030181529190526020810180516001600160e01b0316637bbd53d760e01b1790528461152e565b9050808060200190518101906115239190611fd2565b9150505b9392505050565b60606115278383604051602001611546929190611feb565b60408051601f198184030181529190526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690611636565b6000808060001985870985870292508281108382030391505080600014156115c1578382816115b7576115b7611e7e565b0492505050611527565b8084116115cd57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6060611527838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c656400008152506060824710156116d65760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610378565b600080866001600160a01b031685876040516116f29190612022565b60006040518083038185875af1925050503d806000811461172f576040519150601f19603f3d011682016040523d82523d6000602084013e611734565b606091505b509150915061174587838387611750565b979650505050505050565b606083156117bc5782516117b5576001600160a01b0385163b6117b55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610378565b50816113ab565b6113ab83838151156117d15781518083602001fd5b8060405162461bcd60e51b8152600401610378919061203e565b5050565b6000610160828403121561180257600080fd5b50919050565b600080610180838503121561181c57600080fd5b8235915061182d84602085016117ef565b90509250929050565b60006020828403121561184857600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b8b815263ffffffff8b811660208301528a16604082015261ffff891660608201526001600160a01b038816608082015260a0810187905260c081018690526101608101600686106118b8576118b861184f565b8560e08301526118d46101008301866001600160a01b03169052565b836101208301526118f16101408301846001600160a01b03169052565b9c9b505050505050505050505050565b6001600160a01b038116811461119457600080fd5b61ffff8116811461119457600080fd5b63ffffffff8116811461119457600080fd5b600080600080600080600060e0888a03121561195357600080fd5b87359650602088013595506040880135945060608801359350608088013561197a81611901565b925060a088013561198a81611916565b915060c088013561199a81611926565b8091505092959891949750929550565b6006811061119457600080fd5b600080600080600060a086880312156119cf57600080fd5b853594506020860135935060408601356119e8816119aa565b925060608601356119f881611901565b91506080860135611a0881611901565b809150509295509295909350565b60008060408385031215611a2957600080fd5b823591506020830135611a3b81611901565b809150509250929050565b6000806101808385031215611a5a57600080fd5b611a6484846117ef565b9150610160830135611a3b81611901565b6020808252601e908201527f756e617574686f72697a656420636f6d6d69746d656e74206c656e6465720000604082015260600190565b600060208284031215611abe57600080fd5b813561152781611901565b600081356105d081611926565b600081356105d081611916565b600081356105d081611901565b600081356105d0816119aa565b60068210611b0d57611b0d61184f565b60ff1981541660ff831681178255505050565b8135815560018101611b4e611b3760208501611ac9565b825463ffffffff191663ffffffff91909116178255565b611b7f611b5d60408501611ac9565b825467ffffffff00000000191660209190911b67ffffffff0000000016178255565b611bb4611b8e60608501611ad6565b825469ffff0000000000000000191660409190911b69ffff000000000000000016178255565b611c02611bc360808501611ae3565b8280547fffff0000000000000000000000000000000000000000ffffffffffffffffffff1660509290921b600160501b600160f01b0316919091179055565b5060a0820135600282015560c0820135600382015560048101611c30611c2a60e08501611af0565b82611afd565b611c66611c406101008501611ae3565b828054610100600160a81b03191660089290921b610100600160a81b0316919091179055565b5061012082013560058201556117eb611c826101408401611ae3565b6006830180546001600160a01b0319166001600160a01b0392909216919091179055565b600060208284031215611cb857600080fd5b815161152781611901565b600060208284031215611cd557600080fd5b8151801515811461152757600080fd5b600060208284031215611cf757600080fd5b815160ff8116811461152757600080fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff84168060ff03821115611d3b57611d3b611d08565b019392505050565b600181815b80851115611d7e578160001904821115611d6457611d64611d08565b80851615611d7157918102915b93841c9390800290611d48565b509250929050565b600082611d95575060016105d0565b81611da2575060006105d0565b8160018114611db85760028114611dc257611dde565b60019150506105d0565b60ff841115611dd357611dd3611d08565b50506001821b6105d0565b5060208310610133831016604e8410600b8410161715611e01575081810a6105d0565b611e0b8383611d43565b8060001904821115611e1f57611e1f611d08565b029392505050565b600061152760ff841683611d86565b6000600019821415611e4a57611e4a611d08565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600082821015611e7957611e79611d08565b500390565b634e487b7160e01b600052601260045260246000fd5b60008219821115611ea757611ea7611d08565b500190565b60005b83811015611ec7578181015183820152602001611eaf565b83811115611ed6576000848401525b50505050565b60008151808452611ef4816020860160208601611eac565b601f01601f19169290920160200192915050565b600061010060018060a01b03808c16845260208b8186015260408b81870152606063ffffffff8c1681880152608061ffff8c16818901528560a0890152611f518689018c611edc565b8a861660c08a015288810360e08a01528951808252858b0197509085019060005b81811015611fb9578851805160038110611f8e57611f8e61184f565b8452808801518885015286810151878501528501518816858401529786019791830191600101611f72565b5050809750505050505050509998505050505050505050565b600060208284031215611fe457600080fd5b5051919050565b60008351611ffd818460208801611eac565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b60008251612034818460208701611eac565b9190910192915050565b6020815260006115276020830184611edc56fea26469706673582212203d766775453e4e48efd310661867416367d245084d95e61c39505644fd67cb5664736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80637f11eb9f1161008c578063c66b8ed211610066578063c66b8ed21461029d578063dc003d5a146102c3578063eafef46e146102e9578063fd7b2d911461031057600080fd5b80637f11eb9f1461024e5780639acf779614610261578063bfb40bc01461028a57600080fd5b806349ce8997116100c857806349ce899714610165578063592113d0146102075780637479208b146102285780637956aa181461023b57600080fd5b80631409a2e4146100ef5780631dcaa70d146101045780632888115a14610134575b600080fd5b6101026100fd366004611808565b610337565b005b610117610112366004611836565b610535565b6040516001600160a01b0390911681526020015b60405180910390f35b610117610142366004611836565b60009081526065602052604090206004015461010090046001600160a01b031690565b6101f0610173366004611836565b6065602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154949563ffffffff8086169664010000000087049091169561ffff600160401b820416956001600160a01b03600160501b9092048216959094909360ff8216936101009092048316929091168b565b60405161012b9b9a99989796959493929190611865565b61021a610215366004611938565b6105d6565b60405190815260200161012b565b61021a6102363660046119b7565b610b97565b610102610249366004611a16565b610ced565b61021a61025c366004611a46565b610d8b565b61011761026f366004611836565b6068602052600090815260409020546001600160a01b031681565b610102610298366004611836565b610f22565b7f0000000000000000000000000000000000000000000000000000000000000000610117565b7f0000000000000000000000000000000000000000000000000000000000000000610117565b6101177f000000000000000000000000000000000000000000000000000000000000000081565b6101177f000000000000000000000000000000000000000000000000000000000000000081565b60008281526065602052604090206004015482906001600160a01b036101009091041633146103815760405162461bcd60e51b815260040161037890611a75565b60405180910390fd5b6000838152606560205260409020600601546001600160a01b03166103ae61016084016101408501611aac565b6001600160a01b0316146104175760405162461bcd60e51b815260206004820152602a60248201527f5072696e636970616c20746f6b656e20616464726573732063616e6e6f74206260448201526932903ab83230ba32b21760b11b6064820152608401610378565b6000838152606560205260409020600501546101208301351461047c5760405162461bcd60e51b815260206004820152601c60248201527f4d61726b65742049642063616e6e6f7420626520757064617465642e000000006044820152606401610378565b600083815260656020526040902082906104968282611b20565b505060008381526065602052604090206104af90610fe9565b827f3639fd8e82fc21d99ff6df2a4a03995fa53f752fddd525d8a9aadccefa788aa06104e361012085016101008601611aac565b6101208501356104fb61016087016101408801611aac565b604080516001600160a01b0394851681526020810193909352921691810191909152843560608201526080015b60405180910390a2505050565b604051633d36902960e01b8152600481018290526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633d3690299060240160206040518083038186803b15801561059857600080fd5b505afa1580156105ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d09190611ca6565b92915050565b600087815260656020526040812033906105ef81610fe9565b60018101546001600160a01b03878116600160501b90920416146106555760405162461bcd60e51b815260206004820152601c60248201527f4d69736d61746368696e6720636f6c6c61746572616c20746f6b656e000000006044820152606401610378565b600181015461ffff600160401b909104811690861610156106b05760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420696e746572657374207261746560581b6044820152606401610378565b600181015463ffffffff640100000000909104811690851611156107165760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964206c6f616e206d6178206475726174696f6e000000000000006044820152606401610378565b60008a815260676020526040902061072d90611197565b158061074f575060008a8152606860205260409020546001600160a01b031615155b6107d25760405162461bcd60e51b815260206004820152604860248201527f436f6d6d69746d656e74732077697468206c656761637920626f72726f77657260448201527f206c697374206d757374206e6f772073657420616e20616c6c6f77206c6973746064820152671036b0b730b3b2b960c11b608482015260a401610378565b60008a8152606860205260409020546001600160a01b03161580610884575060008a8152606860205260409081902054905163b0b5316d60e01b8152600481018c90526001600160a01b0384811660248301529091169063b0b5316d90604401602060405180830381600087803b15801561084c57600080fd5b505af1158015610860573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108849190611cc3565b6108d05760405162461bcd60e51b815260206004820152601860248201527f426f72726f776572206e6f7420616c6c6f776c697374656400000000000000006044820152606401610378565b80548911156108ff5780546040516375d44cf160e11b81526004810191909152602481018a9052604401610378565b600381015460048201546001830154600684015460009361093d938e93919260ff909116916001600160a01b03600160501b90910481169116610b97565b90508089101561096a5760405163b744c71960e01b815260048101829052602481018a9052604401610378565b6002600483015460ff1660058111156109855761098561184f565b14806109a8575060048083015460ff1660058111156109a6576109a661184f565b145b15610a155788600114610a155760405162461bcd60e51b815260206004820152602f60248201527f696e76616c696420636f6d6d69746d656e7420636f6c6c61746572616c20616d60448201526e6f756e7420666f722045524337323160881b6064820152608401610378565b6002600483015460ff166005811115610a3057610a3061184f565b1480610a5457506003600483015460ff166005811115610a5257610a5261184f565b145b15610aba5787826002015414610aba5760405162461bcd60e51b815260206004820152602560248201527f696e76616c696420636f6d6d69746d656e7420636f6c6c61746572616c20746f6044820152641ad95b925960da1b6064820152608401610378565b610b0f8383600501548460060160009054906101000a90046001600160a01b03168d86600101600a9054906101000a90046001600160a01b03168e8e8960040160009054906101000a900460ff168d8f6111a1565b9350610b32848360040160019054906101000a90046001600160a01b03166112cb565b50610b3d8b8b61132d565b604080516001600160a01b0385168152602081018c90529081018590528b907f7839c0e772fbc0df2f1be83221fb8cd10f50be73dac060cbb277ee5c856219309060600160405180910390a2505050979650505050505050565b600080846005811115610bac57610bac61184f565b1415610bba57506000610ce4565b600080836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610bf657600080fd5b505afa158015610c0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2e9190611ce5565b90506001866005811115610c4457610c4461184f565b1415610cbe57846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8357600080fd5b505afa158015610c97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbb9190611ce5565b91505b610cdf88610ccc8385611d1e565b610cd790600a611e27565b896001611354565b925050505b95945050505050565b60008281526065602052604090206004015482906001600160a01b03610100909104163314610d2e5760405162461bcd60e51b815260040161037890611a75565b60008381526068602090815260409182902080546001600160a01b0319166001600160a01b038616908117909155915191825284917f4748b005ebf397dce7fe43edc3263879cc81595cca1c87c5dd29cba5a8c613199101610528565b6066805460009182610d9c83611e36565b90915550905033610db561012085016101008601611aac565b6001600160a01b031614610e0b5760405162461bcd60e51b815260206004820152601f60248201527f756e617574686f72697a656420636f6d6d69746d656e742063726561746f72006044820152606401610378565b60008181526065602052604090208390610e258282611b20565b5050600081815260686020908152604080832080546001600160a01b0319166001600160a01b03871617905560659091529020610e6190610fe9565b807f16b531d6c0bbff6da27b922e61fc528bb3ae5b435f9e56fb87e399afb6ae520a610e9561012086016101008701611aac565b610120860135610ead61016088016101408901611aac565b604080516001600160a01b03948516815260208101939093529216818301528635606082015290519081900360800190a26040516001600160a01b038316815281907f4748b005ebf397dce7fe43edc3263879cc81595cca1c87c5dd29cba5a8c613199060200160405180910390a292915050565b60008181526065602052604090206004015481906001600160a01b03610100909104163314610f635760405162461bcd60e51b815260040161037890611a75565b6000828152606560205260408082208281556001810180546001600160f01b031916905560028101839055600381018390556004810180546001600160a81b03191690556005810183905560060180546001600160a01b03191690555183917fd278ecade1e148fd8320435541f72d6a02dff654c1577ae2cadecba16e8ef21491a25050565b600181015463ffffffff42811691161161103a5760405162461bcd60e51b8152602060048201526012602482015271195e1c1a5c99590818dbdb5b5a5d1b595b9d60721b6044820152606401610378565b80546110925760405162461bcd60e51b815260206004820152602160248201527f636f6d6d69746d656e74207072696e636970616c20616c6c6f636174696f6e206044820152600360fc1b6064820152608401610378565b6000600482015460ff1660058111156110ad576110ad61184f565b146111945760008160030154116111065760405162461bcd60e51b815260206004820152601d60248201527f636f6d6d69746d656e7420636f6c6c61746572616c20726174696f20300000006044820152606401610378565b6001600482015460ff1660058111156111215761112161184f565b1415611194576002810154156111945760405162461bcd60e51b815260206004820152603260248201527f636f6d6d69746d656e7420636f6c6c61746572616c20746f6b656e206964206d6044820152710757374206265203020666f722045524332360741b6064820152608401610378565b50565b60006105d0825490565b6040805160e081018252606060a08201819052600060c083018190528c83526001600160a01b038c1660208401529282018a905263ffffffff85168183015261ffff84166080830152828660058111156111fd576111fd61184f565b146112af5760408051600180825281830190925290816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816112175790505090506040518060800160405280611261886113b3565b60028111156112725761127261184f565b81526020018981526020018881526020018a6001600160a01b0316815250816000815181106112a3576112a3611e51565b60200260200101819052505b6112ba82828f61149b565b9d9c50505050505050505050505050565b600061132363a8cb5d6860e01b846040516024016112eb91815260200190565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091528361152e565b5060019392505050565b6000828152606560205260408120805483929061134b908490611e67565b90915550505050565b600080611362868686611586565b905060018360028111156113785761137861184f565b14801561139557506000848061139057611390611e7e565b868809115b156113a8576113a5600182611e94565b90505b90505b949350505050565b600060018260058111156113c9576113c961184f565b14156113d757506000919050565b60028260058111156113eb576113eb61184f565b1480611408575060048260058111156114065761140661184f565b145b1561141557506001919050565b60038260058111156114295761142961184f565b1480611446575060058260058111156114445761144461184f565b145b1561145357506002919050565b60405162461bcd60e51b815260206004820152601760248201527f556e6b6e6f776e20436f6c6c61746572616c20547970650000000000000000006044820152606401610378565b6000606061150d856020015186600001518760400151886060015189608001518a60a001518b60c001518b6040516024016114dd989796959493929190611f08565b60408051601f198184030181529190526020810180516001600160e01b0316637bbd53d760e01b1790528461152e565b9050808060200190518101906115239190611fd2565b9150505b9392505050565b60606115278383604051602001611546929190611feb565b60408051601f198184030181529190526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690611636565b6000808060001985870985870292508281108382030391505080600014156115c1578382816115b7576115b7611e7e565b0492505050611527565b8084116115cd57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6060611527838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c656400008152506060824710156116d65760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610378565b600080866001600160a01b031685876040516116f29190612022565b60006040518083038185875af1925050503d806000811461172f576040519150601f19603f3d011682016040523d82523d6000602084013e611734565b606091505b509150915061174587838387611750565b979650505050505050565b606083156117bc5782516117b5576001600160a01b0385163b6117b55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610378565b50816113ab565b6113ab83838151156117d15781518083602001fd5b8060405162461bcd60e51b8152600401610378919061203e565b5050565b6000610160828403121561180257600080fd5b50919050565b600080610180838503121561181c57600080fd5b8235915061182d84602085016117ef565b90509250929050565b60006020828403121561184857600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b8b815263ffffffff8b811660208301528a16604082015261ffff891660608201526001600160a01b038816608082015260a0810187905260c081018690526101608101600686106118b8576118b861184f565b8560e08301526118d46101008301866001600160a01b03169052565b836101208301526118f16101408301846001600160a01b03169052565b9c9b505050505050505050505050565b6001600160a01b038116811461119457600080fd5b61ffff8116811461119457600080fd5b63ffffffff8116811461119457600080fd5b600080600080600080600060e0888a03121561195357600080fd5b87359650602088013595506040880135945060608801359350608088013561197a81611901565b925060a088013561198a81611916565b915060c088013561199a81611926565b8091505092959891949750929550565b6006811061119457600080fd5b600080600080600060a086880312156119cf57600080fd5b853594506020860135935060408601356119e8816119aa565b925060608601356119f881611901565b91506080860135611a0881611901565b809150509295509295909350565b60008060408385031215611a2957600080fd5b823591506020830135611a3b81611901565b809150509250929050565b6000806101808385031215611a5a57600080fd5b611a6484846117ef565b9150610160830135611a3b81611901565b6020808252601e908201527f756e617574686f72697a656420636f6d6d69746d656e74206c656e6465720000604082015260600190565b600060208284031215611abe57600080fd5b813561152781611901565b600081356105d081611926565b600081356105d081611916565b600081356105d081611901565b600081356105d0816119aa565b60068210611b0d57611b0d61184f565b60ff1981541660ff831681178255505050565b8135815560018101611b4e611b3760208501611ac9565b825463ffffffff191663ffffffff91909116178255565b611b7f611b5d60408501611ac9565b825467ffffffff00000000191660209190911b67ffffffff0000000016178255565b611bb4611b8e60608501611ad6565b825469ffff0000000000000000191660409190911b69ffff000000000000000016178255565b611c02611bc360808501611ae3565b8280547fffff0000000000000000000000000000000000000000ffffffffffffffffffff1660509290921b600160501b600160f01b0316919091179055565b5060a0820135600282015560c0820135600382015560048101611c30611c2a60e08501611af0565b82611afd565b611c66611c406101008501611ae3565b828054610100600160a81b03191660089290921b610100600160a81b0316919091179055565b5061012082013560058201556117eb611c826101408401611ae3565b6006830180546001600160a01b0319166001600160a01b0392909216919091179055565b600060208284031215611cb857600080fd5b815161152781611901565b600060208284031215611cd557600080fd5b8151801515811461152757600080fd5b600060208284031215611cf757600080fd5b815160ff8116811461152757600080fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff84168060ff03821115611d3b57611d3b611d08565b019392505050565b600181815b80851115611d7e578160001904821115611d6457611d64611d08565b80851615611d7157918102915b93841c9390800290611d48565b509250929050565b600082611d95575060016105d0565b81611da2575060006105d0565b8160018114611db85760028114611dc257611dde565b60019150506105d0565b60ff841115611dd357611dd3611d08565b50506001821b6105d0565b5060208310610133831016604e8410600b8410161715611e01575081810a6105d0565b611e0b8383611d43565b8060001904821115611e1f57611e1f611d08565b029392505050565b600061152760ff841683611d86565b6000600019821415611e4a57611e4a611d08565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600082821015611e7957611e79611d08565b500390565b634e487b7160e01b600052601260045260246000fd5b60008219821115611ea757611ea7611d08565b500190565b60005b83811015611ec7578181015183820152602001611eaf565b83811115611ed6576000848401525b50505050565b60008151808452611ef4816020860160208601611eac565b601f01601f19169290920160200192915050565b600061010060018060a01b03808c16845260208b8186015260408b81870152606063ffffffff8c1681880152608061ffff8c16818901528560a0890152611f518689018c611edc565b8a861660c08a015288810360e08a01528951808252858b0197509085019060005b81811015611fb9578851805160038110611f8e57611f8e61184f565b8452808801518885015286810151878501528501518816858401529786019791830191600101611f72565b5050809750505050505050509998505050505050505050565b600060208284031215611fe457600080fd5b5051919050565b60008351611ffd818460208801611eac565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b60008251612034818460208701611eac565b9190910192915050565b6020815260006115276020830184611edc56fea26469706673582212203d766775453e4e48efd310661867416367d245084d95e61c39505644fd67cb5664736f6c63430008090033", "devdoc": { "events": { "CreatedCommitment(uint256,address,uint256,address,uint256)": { @@ -697,21 +735,21 @@ "details": "LoanDuration must be longer than the market payment cycle", "params": { "_collateralAmount": "The amount of collateral to use for the loan.", - "_collateralTokenAddress": "The contract address to use for the loan collateral token.s", + "_collateralTokenAddress": "The contract address to use for the loan collateral tokens.", "_collateralTokenId": "The tokenId of collateral to use for the loan if ERC721 or ERC1155.", "_commitmentId": "The id of the commitment being accepted.", "_interestRate": "The interest rate APY to use for the loan in basis points.", - "_loanDuration": "The overall duratiion for the loan. Must be longer than market payment cycle duration.", + "_loanDuration": "The overall duration for the loan. Must be longer than market payment cycle duration.", "_principalAmount": "The amount of currency to borrow for the loan." }, "returns": { "bidId": "The ID of the loan that was created on TellerV2" } }, - "createCommitment((uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address),address[])": { + "createCommitment((uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address),address)": { "params": { - "_borrowerAddressList": "The array of borrowers that are allowed to accept loans using this commitment", - "_commitment": "The new commitment data expressed as a struct" + "_commitment": "The new commitment data expressed as a struct", + "borrowerAllowlistManager": "The address of the allowlist contract " }, "returns": { "commitmentId_": "returns the commitmentId for the created commitment" @@ -722,14 +760,6 @@ "_commitmentId": "The id of the commitment to delete." } }, - "getCommitmentBorrowers(uint256)": { - "params": { - "_commitmentId": "The commitment id for the commitment to query." - }, - "returns": { - "borrowers_": "An array of addresses restricted to accept the commitment. Empty array means unrestricted." - } - }, "getRequiredCollateral(uint256,uint256,uint8,address,address)": { "params": { "_collateralTokenAddress": "The contract address for the collateral for the loan.", @@ -744,12 +774,6 @@ "_commitment": "The new commitment data expressed as a struct", "_commitmentId": "The Id of the commitment to update." } - }, - "updateCommitmentBorrowers(uint256,address[])": { - "params": { - "_borrowerAddressList": "The array of borrowers that are allowed to accept loans using this commitment", - "_commitmentId": "The Id of the commitment to update." - } } }, "version": 1 @@ -780,23 +804,17 @@ "constructor": { "notice": "External Functions *" }, - "createCommitment((uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address),address[])": { + "createCommitment((uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address),address)": { "notice": "Creates a loan commitment from a lender for a market." }, "deleteCommitment(uint256)": { "notice": "Removes the commitment of a lender to a market." }, - "getCommitmentBorrowers(uint256)": { - "notice": "Return the array of borrowers that are allowlisted for a commitment" - }, "getRequiredCollateral(uint256,uint256,uint8,address,address)": { "notice": "Calculate the amount of collateral required to borrow a loan with _principalAmount of principal" }, "updateCommitment(uint256,(uint256,uint32,uint32,uint16,address,uint256,uint256,uint8,address,uint256,address))": { "notice": "Updates the commitment of a lender to a market." - }, - "updateCommitmentBorrowers(uint256,address[])": { - "notice": "Updates the borrowers allowed to accept a commitment" } }, "version": 1 @@ -804,7 +822,7 @@ "storageLayout": { "storage": [ { - "astId": 1625, + "astId": 326, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "_initialized", "offset": 0, @@ -812,7 +830,7 @@ "type": "t_uint8" }, { - "astId": 1628, + "astId": 329, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "_initializing", "offset": 1, @@ -820,7 +838,7 @@ "type": "t_bool" }, { - "astId": 3912, + "astId": 2613, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "__gap", "offset": 0, @@ -828,7 +846,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 23566, + "astId": 22784, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "__gap", "offset": 0, @@ -836,15 +854,15 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 17113, + "astId": 15493, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "commitments", "offset": 0, "slot": "101", - "type": "t_mapping(t_uint256,t_struct(Commitment)17108_storage)" + "type": "t_mapping(t_uint256,t_struct(Commitment)15488_storage)" }, { - "astId": 17115, + "astId": 15495, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "commitmentCount", "offset": 0, @@ -852,12 +870,20 @@ "type": "t_uint256" }, { - "astId": 17120, + "astId": 15500, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", - "label": "commitmentBorrowersList", + "label": "__commitmentBorrowersList", "offset": 0, "slot": "103", - "type": "t_mapping(t_uint256,t_struct(AddressSet)5846_storage)" + "type": "t_mapping(t_uint256,t_struct(AddressSet)4547_storage)" + }, + { + "astId": 15504, + "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", + "label": "commitmentAllowListManagers", + "offset": 0, + "slot": "104", + "type": "t_mapping(t_uint256,t_address)" } ], "types": { @@ -888,7 +914,7 @@ "label": "bytes32", "numberOfBytes": "32" }, - "t_enum(CommitmentCollateralType)17084": { + "t_enum(CommitmentCollateralType)15464": { "encoding": "inplace", "label": "enum LenderCommitmentForwarder.CommitmentCollateralType", "numberOfBytes": "1" @@ -900,41 +926,48 @@ "numberOfBytes": "32", "value": "t_uint256" }, - "t_mapping(t_uint256,t_struct(AddressSet)5846_storage)": { + "t_mapping(t_uint256,t_address)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_uint256,t_struct(AddressSet)4547_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct EnumerableSetUpgradeable.AddressSet)", "numberOfBytes": "32", - "value": "t_struct(AddressSet)5846_storage" + "value": "t_struct(AddressSet)4547_storage" }, - "t_mapping(t_uint256,t_struct(Commitment)17108_storage)": { + "t_mapping(t_uint256,t_struct(Commitment)15488_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct LenderCommitmentForwarder.Commitment)", "numberOfBytes": "32", - "value": "t_struct(Commitment)17108_storage" + "value": "t_struct(Commitment)15488_storage" }, - "t_struct(AddressSet)5846_storage": { + "t_struct(AddressSet)4547_storage": { "encoding": "inplace", "label": "struct EnumerableSetUpgradeable.AddressSet", "members": [ { - "astId": 5845, + "astId": 4546, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "_inner", "offset": 0, "slot": "0", - "type": "t_struct(Set)5531_storage" + "type": "t_struct(Set)4232_storage" } ], "numberOfBytes": "64" }, - "t_struct(Commitment)17108_storage": { + "t_struct(Commitment)15488_storage": { "encoding": "inplace", "label": "struct LenderCommitmentForwarder.Commitment", "members": [ { - "astId": 17086, + "astId": 15466, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "maxPrincipal", "offset": 0, @@ -942,7 +975,7 @@ "type": "t_uint256" }, { - "astId": 17088, + "astId": 15468, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "expiration", "offset": 0, @@ -950,7 +983,7 @@ "type": "t_uint32" }, { - "astId": 17090, + "astId": 15470, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "maxDuration", "offset": 4, @@ -958,7 +991,7 @@ "type": "t_uint32" }, { - "astId": 17092, + "astId": 15472, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "minInterestRate", "offset": 8, @@ -966,7 +999,7 @@ "type": "t_uint16" }, { - "astId": 17094, + "astId": 15474, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "collateralTokenAddress", "offset": 10, @@ -974,7 +1007,7 @@ "type": "t_address" }, { - "astId": 17096, + "astId": 15476, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "collateralTokenId", "offset": 0, @@ -982,7 +1015,7 @@ "type": "t_uint256" }, { - "astId": 17098, + "astId": 15478, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "maxPrincipalPerCollateralAmount", "offset": 0, @@ -990,15 +1023,15 @@ "type": "t_uint256" }, { - "astId": 17101, + "astId": 15481, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "collateralTokenType", "offset": 0, "slot": "4", - "type": "t_enum(CommitmentCollateralType)17084" + "type": "t_enum(CommitmentCollateralType)15464" }, { - "astId": 17103, + "astId": 15483, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "lender", "offset": 1, @@ -1006,7 +1039,7 @@ "type": "t_address" }, { - "astId": 17105, + "astId": 15485, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "marketId", "offset": 0, @@ -1014,7 +1047,7 @@ "type": "t_uint256" }, { - "astId": 17107, + "astId": 15487, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "principalTokenAddress", "offset": 0, @@ -1024,12 +1057,12 @@ ], "numberOfBytes": "224" }, - "t_struct(Set)5531_storage": { + "t_struct(Set)4232_storage": { "encoding": "inplace", "label": "struct EnumerableSetUpgradeable.Set", "members": [ { - "astId": 5526, + "astId": 4227, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "_values", "offset": 0, @@ -1037,7 +1070,7 @@ "type": "t_array(t_bytes32)dyn_storage" }, { - "astId": 5530, + "astId": 4231, "contract": "contracts/LenderCommitmentForwarder.sol:LenderCommitmentForwarder", "label": "_indexes", "offset": 0, diff --git a/packages/contracts/deployments/goerli/LenderCommitmentForwarder_Proxy.json b/packages/contracts/deployments/goerli/LenderCommitmentForwarder_Proxy.json index c659a977c..e78256ded 100644 --- a/packages/contracts/deployments/goerli/LenderCommitmentForwarder_Proxy.json +++ b/packages/contracts/deployments/goerli/LenderCommitmentForwarder_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", + "address": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", "abi": [ { "inputs": [ @@ -146,51 +146,51 @@ "type": "receive" } ], - "transactionHash": "0x2717d02f52012bc65b1d7979940cc7e019c3d92f39c3cecb99ce13e60ea49e8b", + "transactionHash": "0x53a3ae41c6e989dc6a38427e85049cfa332cdb413c79c701dc1dffe2ed70a700", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", - "transactionIndex": 7, - "gasUsed": "720430", - "logsBloom": "0x00200000000000000000000000000000400000000000000000010000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000004000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000000000000000000000040000000000000000000000000000000000040000000000000000", - "blockHash": "0x1c51fff4435d0a45908768428917c2e14f74c3770cef9b00aa6f4f58f5b16ec1", - "transactionHash": "0x2717d02f52012bc65b1d7979940cc7e019c3d92f39c3cecb99ce13e60ea49e8b", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", + "transactionIndex": 17, + "gasUsed": "720722", + "logsBloom": "0x00000000000008000000004000000000400000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000002000000000000000000000000000000000000000000000000000000000000400000000000800000000000000000000000000000000000020000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xb13d51d8e894e9f4220c89716af0f30f226627b77a537e5ca8c98b0891924a51", + "transactionHash": "0x53a3ae41c6e989dc6a38427e85049cfa332cdb413c79c701dc1dffe2ed70a700", "logs": [ { - "transactionIndex": 7, - "blockNumber": 8538455, - "transactionHash": "0x2717d02f52012bc65b1d7979940cc7e019c3d92f39c3cecb99ce13e60ea49e8b", - "address": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", + "transactionIndex": 17, + "blockNumber": 8688917, + "transactionHash": "0x53a3ae41c6e989dc6a38427e85049cfa332cdb413c79c701dc1dffe2ed70a700", + "address": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000095aa87944d9464056228de311b40dcabce22a43" + "0x0000000000000000000000007abf7096c6b287cd81dc7c80de5a7c968fdcb614" ], "data": "0x", "logIndex": 0, - "blockHash": "0x1c51fff4435d0a45908768428917c2e14f74c3770cef9b00aa6f4f58f5b16ec1" + "blockHash": "0xb13d51d8e894e9f4220c89716af0f30f226627b77a537e5ca8c98b0891924a51" }, { - "transactionIndex": 7, - "blockNumber": 8538455, - "transactionHash": "0x2717d02f52012bc65b1d7979940cc7e019c3d92f39c3cecb99ce13e60ea49e8b", - "address": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", + "transactionIndex": 17, + "blockNumber": 8688917, + "transactionHash": "0x53a3ae41c6e989dc6a38427e85049cfa332cdb413c79c701dc1dffe2ed70a700", + "address": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 1, - "blockHash": "0x1c51fff4435d0a45908768428917c2e14f74c3770cef9b00aa6f4f58f5b16ec1" + "blockHash": "0xb13d51d8e894e9f4220c89716af0f30f226627b77a537e5ca8c98b0891924a51" } ], - "blockNumber": 8538455, - "cumulativeGasUsed": "867430", + "blockNumber": 8688917, + "cumulativeGasUsed": "1077722", "status": 1, "byzantium": true }, "args": [ - "0x095aA87944D9464056228DE311B40DcabCe22A43", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0x7abF7096C6B287cd81dc7c80DE5a7c968fdcB614", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x" ], "numDeployments": 1, diff --git a/packages/contracts/deployments/goerli/LenderManager.json b/packages/contracts/deployments/goerli/LenderManager.json index 7ecde2e2f..0c356eccf 100644 --- a/packages/contracts/deployments/goerli/LenderManager.json +++ b/packages/contracts/deployments/goerli/LenderManager.json @@ -1,5 +1,5 @@ { - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "abi": [ { "anonymous": false, @@ -579,85 +579,89 @@ "type": "constructor" } ], - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x98Ca52786e967d1469090AdC075416948Ca004A7", - "transactionIndex": 2, - "gasUsed": "815356", - "logsBloom": "0x00000000000000000000000000008000400000000000000000800000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000002000101000000000000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000010000080000000000000080000000000000800000000000000000000000000000200400000000000000000000000000000000000000000820000100000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000004000000000000000", - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f", - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", + "transactionIndex": 8, + "gasUsed": "815650", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000000000000000000000080000000000000000000000000000000000000000000000000000000000000200000002000000002000001000000000000000000000000100000000000020000000000000000000800000000800000000000000000000000400000100000000000000000000000000000000000000080000000000000800000000000000000000000000000000400008000000000000000000000000000000000000020000000000000000000040000004000000400000000000000000020000000200000000000000000000000000000000000000000000200000000000000", + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4", + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", "logs": [ { - "transactionIndex": 2, - "blockNumber": 8538444, - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "transactionIndex": 8, + "blockNumber": 8688913, + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x00000000000000000000000017d521925336b024da8014e15291853854bd7d5f" + "0x0000000000000000000000006f537a17a315910176598d0de17a44dabf25477a" ], "data": "0x", "logIndex": 0, - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f" + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4" }, { - "transactionIndex": 2, - "blockNumber": 8538444, - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "transactionIndex": 8, + "blockNumber": 8688913, + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", "logIndex": 1, - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f" + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4" }, { - "transactionIndex": 2, - "blockNumber": 8538444, - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "transactionIndex": 8, + "blockNumber": 8688913, + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 2, - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f" + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4" }, { - "transactionIndex": 2, - "blockNumber": 8538444, - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "transactionIndex": 8, + "blockNumber": 8688913, + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 3, - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f" + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4" } ], - "blockNumber": 8538444, - "cumulativeGasUsed": "857356", + "blockNumber": 8688913, + "cumulativeGasUsed": "983650", "status": 1, "byzantium": true }, "args": [ - "0x17d521925336b024DA8014e15291853854bd7D5F", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0x6f537A17A315910176598D0dE17a44DabF25477a", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x8129fc1c" ], - "numDeployments": 2, + "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", - "implementation": "0x2806584eEb812F8F3E15BEF9986db27752679263", + "execute": { + "methodName": "initialize", + "args": [] + }, + "implementation": "0x6f537A17A315910176598D0dE17a44DabF25477a", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/LenderManager_Implementation.json b/packages/contracts/deployments/goerli/LenderManager_Implementation.json index 007b563a5..ae6c34aa2 100644 --- a/packages/contracts/deployments/goerli/LenderManager_Implementation.json +++ b/packages/contracts/deployments/goerli/LenderManager_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0x2806584eEb812F8F3E15BEF9986db27752679263", + "address": "0x6f537A17A315910176598D0dE17a44DabF25477a", "abi": [ { "inputs": [ @@ -446,30 +446,30 @@ "type": "function" } ], - "transactionHash": "0xf261b13b36373d9d8c8f7b201eb7f360d760b2f3bbadc2ae6153bb86cebeef92", + "transactionHash": "0xaeb5a29da6a21e58648f89a12e61f14f1ab48614f193fdabf125e972bc8a82e0", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x2806584eEb812F8F3E15BEF9986db27752679263", - "transactionIndex": 2, - "gasUsed": "1496503", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x6f537A17A315910176598D0dE17a44DabF25477a", + "transactionIndex": 21, + "gasUsed": "1496945", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x977f41a687374ec9c9d9863d8320550da9f6673ef6b357b189efcab3fab3df46", - "transactionHash": "0xf261b13b36373d9d8c8f7b201eb7f360d760b2f3bbadc2ae6153bb86cebeef92", + "blockHash": "0x71ad7e0939774bba5a1c87a40ff8b8691abbcfc657b5509498cd9d5467a329b4", + "transactionHash": "0xaeb5a29da6a21e58648f89a12e61f14f1ab48614f193fdabf125e972bc8a82e0", "logs": [], - "blockNumber": 8579791, - "cumulativeGasUsed": "1569001", + "blockNumber": 8688912, + "cumulativeGasUsed": "2078445", "status": 1, "byzantium": true }, "args": [ - "0x74FFC87282ab32c8E0969E26F93C820a213ae146" + "0x04F6908B97E4E985b849174f9904FaF0a0E50413" ], - "numDeployments": 2, - "solcInputHash": "976bca259bf89d14d50591c72cf76420", - "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IMarketRegistry\",\"name\":\"_marketRegistry\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketRegistry\",\"outputs\":[{\"internalType\":\"contract IMarketRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_newLender\",\"type\":\"address\"}],\"name\":\"registerLoan\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address,uint256)\":{\"details\":\"See {IERC721-approve}.\"},\"balanceOf(address)\":{\"details\":\"See {IERC721-balanceOf}.\"},\"getApproved(uint256)\":{\"details\":\"See {IERC721-getApproved}.\"},\"isApprovedForAll(address,address)\":{\"details\":\"See {IERC721-isApprovedForAll}.\"},\"name()\":{\"details\":\"See {IERC721Metadata-name}.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"ownerOf(uint256)\":{\"details\":\"See {IERC721-ownerOf}.\"},\"registerLoan(uint256,address)\":{\"params\":{\"_bidId\":\"The id for the loan to set.\",\"_newLender\":\"The address of the new active lender.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"safeTransferFrom(address,address,uint256)\":{\"details\":\"See {IERC721-safeTransferFrom}.\"},\"safeTransferFrom(address,address,uint256,bytes)\":{\"details\":\"See {IERC721-safeTransferFrom}.\"},\"setApprovalForAll(address,bool)\":{\"details\":\"See {IERC721-setApprovalForAll}.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"},\"symbol()\":{\"details\":\"See {IERC721Metadata-symbol}.\"},\"tokenURI(uint256)\":{\"details\":\"See {IERC721Metadata-tokenURI}.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC721-transferFrom}.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"registerLoan(uint256,address)\":{\"notice\":\"Registers a new active lender for a loan, minting the nft\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/LenderManager.sol\":\"LenderManager\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC721Upgradeable.sol\\\";\\nimport \\\"./IERC721ReceiverUpgradeable.sol\\\";\\nimport \\\"./extensions/IERC721MetadataUpgradeable.sol\\\";\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../utils/StringsUpgradeable.sol\\\";\\nimport \\\"../../utils/introspection/ERC165Upgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\\n * {ERC721Enumerable}.\\n */\\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\\n using AddressUpgradeable for address;\\n using StringsUpgradeable for uint256;\\n\\n // Token name\\n string private _name;\\n\\n // Token symbol\\n string private _symbol;\\n\\n // Mapping from token ID to owner address\\n mapping(uint256 => address) private _owners;\\n\\n // Mapping owner address to token count\\n mapping(address => uint256) private _balances;\\n\\n // Mapping from token ID to approved address\\n mapping(uint256 => address) private _tokenApprovals;\\n\\n // Mapping from owner to operator approvals\\n mapping(address => mapping(address => bool)) private _operatorApprovals;\\n\\n /**\\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\\n */\\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\\n __ERC721_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\\n return\\n interfaceId == type(IERC721Upgradeable).interfaceId ||\\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\\n super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev See {IERC721-balanceOf}.\\n */\\n function balanceOf(address owner) public view virtual override returns (uint256) {\\n require(owner != address(0), \\\"ERC721: address zero is not a valid owner\\\");\\n return _balances[owner];\\n }\\n\\n /**\\n * @dev See {IERC721-ownerOf}.\\n */\\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\\n address owner = _ownerOf(tokenId);\\n require(owner != address(0), \\\"ERC721: invalid token ID\\\");\\n return owner;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-name}.\\n */\\n function name() public view virtual override returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-symbol}.\\n */\\n function symbol() public view virtual override returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-tokenURI}.\\n */\\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\\n _requireMinted(tokenId);\\n\\n string memory baseURI = _baseURI();\\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \\\"\\\";\\n }\\n\\n /**\\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\\n * by default, can be overridden in child contracts.\\n */\\n function _baseURI() internal view virtual returns (string memory) {\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev See {IERC721-approve}.\\n */\\n function approve(address to, uint256 tokenId) public virtual override {\\n address owner = ERC721Upgradeable.ownerOf(tokenId);\\n require(to != owner, \\\"ERC721: approval to current owner\\\");\\n\\n require(\\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\\n \\\"ERC721: approve caller is not token owner or approved for all\\\"\\n );\\n\\n _approve(to, tokenId);\\n }\\n\\n /**\\n * @dev See {IERC721-getApproved}.\\n */\\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\\n _requireMinted(tokenId);\\n\\n return _tokenApprovals[tokenId];\\n }\\n\\n /**\\n * @dev See {IERC721-setApprovalForAll}.\\n */\\n function setApprovalForAll(address operator, bool approved) public virtual override {\\n _setApprovalForAll(_msgSender(), operator, approved);\\n }\\n\\n /**\\n * @dev See {IERC721-isApprovedForAll}.\\n */\\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\\n return _operatorApprovals[owner][operator];\\n }\\n\\n /**\\n * @dev See {IERC721-transferFrom}.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) public virtual override {\\n //solhint-disable-next-line max-line-length\\n require(_isApprovedOrOwner(_msgSender(), tokenId), \\\"ERC721: caller is not token owner or approved\\\");\\n\\n _transfer(from, to, tokenId);\\n }\\n\\n /**\\n * @dev See {IERC721-safeTransferFrom}.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) public virtual override {\\n safeTransferFrom(from, to, tokenId, \\\"\\\");\\n }\\n\\n /**\\n * @dev See {IERC721-safeTransferFrom}.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes memory data\\n ) public virtual override {\\n require(_isApprovedOrOwner(_msgSender(), tokenId), \\\"ERC721: caller is not token owner or approved\\\");\\n _safeTransfer(from, to, tokenId, data);\\n }\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\\n *\\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\\n * implement alternative mechanisms to perform token transfer, such as signature-based.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _safeTransfer(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes memory data\\n ) internal virtual {\\n _transfer(from, to, tokenId);\\n require(_checkOnERC721Received(from, to, tokenId, data), \\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n }\\n\\n /**\\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\\n */\\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\\n return _owners[tokenId];\\n }\\n\\n /**\\n * @dev Returns whether `tokenId` exists.\\n *\\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\\n *\\n * Tokens start existing when they are minted (`_mint`),\\n * and stop existing when they are burned (`_burn`).\\n */\\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\\n return _ownerOf(tokenId) != address(0);\\n }\\n\\n /**\\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\\n address owner = ERC721Upgradeable.ownerOf(tokenId);\\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\\n }\\n\\n /**\\n * @dev Safely mints `tokenId` and transfers it to `to`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _safeMint(address to, uint256 tokenId) internal virtual {\\n _safeMint(to, tokenId, \\\"\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\\n */\\n function _safeMint(\\n address to,\\n uint256 tokenId,\\n bytes memory data\\n ) internal virtual {\\n _mint(to, tokenId);\\n require(\\n _checkOnERC721Received(address(0), to, tokenId, data),\\n \\\"ERC721: transfer to non ERC721Receiver implementer\\\"\\n );\\n }\\n\\n /**\\n * @dev Mints `tokenId` and transfers it to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - `to` cannot be the zero address.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _mint(address to, uint256 tokenId) internal virtual {\\n require(to != address(0), \\\"ERC721: mint to the zero address\\\");\\n require(!_exists(tokenId), \\\"ERC721: token already minted\\\");\\n\\n _beforeTokenTransfer(address(0), to, tokenId, 1);\\n\\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\\n require(!_exists(tokenId), \\\"ERC721: token already minted\\\");\\n\\n unchecked {\\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\\n // Given that tokens are minted one by one, it is impossible in practice that\\n // this ever happens. Might change if we allow batch minting.\\n // The ERC fails to describe this case.\\n _balances[to] += 1;\\n }\\n\\n _owners[tokenId] = to;\\n\\n emit Transfer(address(0), to, tokenId);\\n\\n _afterTokenTransfer(address(0), to, tokenId, 1);\\n }\\n\\n /**\\n * @dev Destroys `tokenId`.\\n * The approval is cleared when the token is burned.\\n * This is an internal function that does not check if the sender is authorized to operate on the token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _burn(uint256 tokenId) internal virtual {\\n address owner = ERC721Upgradeable.ownerOf(tokenId);\\n\\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\\n\\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\\n owner = ERC721Upgradeable.ownerOf(tokenId);\\n\\n // Clear approvals\\n delete _tokenApprovals[tokenId];\\n\\n unchecked {\\n // Cannot overflow, as that would require more tokens to be burned/transferred\\n // out than the owner initially received through minting and transferring in.\\n _balances[owner] -= 1;\\n }\\n delete _owners[tokenId];\\n\\n emit Transfer(owner, address(0), tokenId);\\n\\n _afterTokenTransfer(owner, address(0), tokenId, 1);\\n }\\n\\n /**\\n * @dev Transfers `tokenId` from `from` to `to`.\\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 tokenId\\n ) internal virtual {\\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \\\"ERC721: transfer from incorrect owner\\\");\\n require(to != address(0), \\\"ERC721: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, tokenId, 1);\\n\\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \\\"ERC721: transfer from incorrect owner\\\");\\n\\n // Clear approvals from the previous owner\\n delete _tokenApprovals[tokenId];\\n\\n unchecked {\\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\\n // `from`'s balance is the number of token held, which is at least one before the current\\n // transfer.\\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\\n // all 2**256 token ids to be minted, which in practice is impossible.\\n _balances[from] -= 1;\\n _balances[to] += 1;\\n }\\n _owners[tokenId] = to;\\n\\n emit Transfer(from, to, tokenId);\\n\\n _afterTokenTransfer(from, to, tokenId, 1);\\n }\\n\\n /**\\n * @dev Approve `to` to operate on `tokenId`\\n *\\n * Emits an {Approval} event.\\n */\\n function _approve(address to, uint256 tokenId) internal virtual {\\n _tokenApprovals[tokenId] = to;\\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\\n }\\n\\n /**\\n * @dev Approve `operator` to operate on all of `owner` tokens\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function _setApprovalForAll(\\n address owner,\\n address operator,\\n bool approved\\n ) internal virtual {\\n require(owner != operator, \\\"ERC721: approve to caller\\\");\\n _operatorApprovals[owner][operator] = approved;\\n emit ApprovalForAll(owner, operator, approved);\\n }\\n\\n /**\\n * @dev Reverts if the `tokenId` has not been minted yet.\\n */\\n function _requireMinted(uint256 tokenId) internal view virtual {\\n require(_exists(tokenId), \\\"ERC721: invalid token ID\\\");\\n }\\n\\n /**\\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\\n * The call is not executed if the target address is not a contract.\\n *\\n * @param from address representing the previous owner of the given token ID\\n * @param to target address that will receive the tokens\\n * @param tokenId uint256 ID of the token to be transferred\\n * @param data bytes optional data to send along with the call\\n * @return bool whether the call correctly returned the expected magic value\\n */\\n function _checkOnERC721Received(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes memory data\\n ) private returns (bool) {\\n if (to.isContract()) {\\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\\n } catch (bytes memory reason) {\\n if (reason.length == 0) {\\n revert(\\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n } else {\\n /// @solidity memory-safe-assembly\\n assembly {\\n revert(add(32, reason), mload(reason))\\n }\\n }\\n }\\n } else {\\n return true;\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\\n * - When `from` is zero, the tokens will be minted for `to`.\\n * - When `to` is zero, ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n * - `batchSize` is non-zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256, /* firstTokenId */\\n uint256 batchSize\\n ) internal virtual {\\n if (batchSize > 1) {\\n if (from != address(0)) {\\n _balances[from] -= batchSize;\\n }\\n if (to != address(0)) {\\n _balances[to] += batchSize;\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\\n * - When `from` is zero, the tokens were minted for `to`.\\n * - When `to` is zero, ``from``'s tokens were burned.\\n * - `from` and `to` are never both zero.\\n * - `batchSize` is non-zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 firstTokenId,\\n uint256 batchSize\\n ) internal virtual {}\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[44] private __gap;\\n}\\n\",\"keccak256\":\"0x2a6a0b9fd2d316dcb4141159a9d13be92654066d6c0ae92757ed908ecdfecff0\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721ReceiverUpgradeable {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xbb2ed8106d94aeae6858e2551a1e7174df73994b77b13ebd120ccaaef80155f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC721Upgradeable.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x95a471796eb5f030fdc438660bebec121ad5d063763e64d92376ffb4b5ce8b70\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0x6b9a5d35b744b25529a2856a8093e7c03fb35a34b1c4fb5499e560f8ade140da\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165Upgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\\n function __ERC165_init() internal onlyInitializing {\\n }\\n\\n function __ERC165_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165Upgradeable).interfaceId;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x9a3b990bd56d139df3e454a9edf1c64668530b5a77fc32eb063bc206f958274a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/LenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// Contracts\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\\\";\\n\\n// Interfaces\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\nimport \\\"./interfaces/IMarketRegistry.sol\\\";\\n\\ncontract LenderManager is\\n Initializable,\\n OwnableUpgradeable,\\n ERC721Upgradeable,\\n ILenderManager\\n{\\n IMarketRegistry public immutable marketRegistry;\\n\\n constructor(IMarketRegistry _marketRegistry) {\\n marketRegistry = _marketRegistry;\\n }\\n\\n function initialize() external initializer {\\n __LenderManager_init();\\n }\\n\\n function __LenderManager_init() internal onlyInitializing {\\n __Ownable_init();\\n __ERC721_init(\\\"TellerLoan\\\", \\\"TLN\\\");\\n }\\n\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender)\\n public\\n override\\n onlyOwner\\n {\\n _mint(_newLender, _bidId);\\n }\\n\\n /**\\n * @notice Returns the address of the lender that owns a given loan/bid.\\n * @param _bidId The id of the bid of which to return the market id\\n */\\n function _getLoanMarketId(uint256 _bidId) internal view returns (uint256) {\\n return ITellerV2(owner()).getLoanMarketId(_bidId);\\n }\\n\\n /**\\n * @notice Returns the verification status of a lender for a market.\\n * @param _lender The address of the lender which should be verified by the market\\n * @param _bidId The id of the bid of which to return the market id\\n */\\n function _hasMarketVerification(address _lender, uint256 _bidId)\\n internal\\n view\\n virtual\\n returns (bool isVerified_)\\n {\\n uint256 _marketId = _getLoanMarketId(_bidId);\\n\\n (isVerified_, ) = marketRegistry.isVerifiedLender(_marketId, _lender);\\n }\\n\\n /** ERC721 Functions **/\\n\\n function _beforeTokenTransfer(address, address to, uint256 tokenId, uint256)\\n internal\\n override\\n {\\n require(_hasMarketVerification(to, tokenId), \\\"Not approved by market\\\");\\n }\\n\\n function _baseURI() internal view override returns (string memory) {\\n return \\\"\\\";\\n }\\n}\\n\",\"keccak256\":\"0x72262bc29f5a18a73dbe0b9ebb2fea028b62922b3a122c79e2521fa148e0f09e\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x549d37cb1390adad543f2e7b1ad46104c4326c4af7dbccda35116833103a6465\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x62c61e6811becc51d0d644e54c342279565e9d8ff5a386cde5a784440a404da7\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60a060405234801561001057600080fd5b50604051611aa6380380611aa683398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051611a14610092600039600081816102b301526112970152611a146000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c80638129fc1c116100ad578063b88d4fde11610071578063b88d4fde1461024c578063c87b56dd1461025f578063e985e9c514610272578063ecb96fe6146102ae578063f2fde38b146102d557600080fd5b80638129fc1c146102055780638da5cb5b1461020d57806395d89b411461021e57806396c9983014610226578063a22cb4651461023957600080fd5b806323b872dd116100f457806323b872dd146101a357806342842e0e146101b65780636352211e146101c957806370a08231146101dc578063715018a6146101fd57600080fd5b806301ffc9a71461012657806306fdde031461014e578063081812fc14610163578063095ea7b31461018e575b600080fd5b6101396101343660046114d9565b6102e8565b60405190151581526020015b60405180910390f35b61015661033a565b604051610145919061154e565b610176610171366004611561565b6103cc565b6040516001600160a01b039091168152602001610145565b6101a161019c366004611596565b6103f3565b005b6101a16101b13660046115c0565b61050e565b6101a16101c43660046115c0565b61053f565b6101766101d7366004611561565b61055a565b6101ef6101ea3660046115fc565b6105ba565b604051908152602001610145565b6101a1610640565b6101a1610654565b6033546001600160a01b0316610176565b610156610765565b6101a1610234366004611617565b610774565b6101a1610247366004611651565b61078a565b6101a161025a36600461169e565b610795565b61015661026d366004611561565b6107cd565b61013961028036600461177a565b6001600160a01b039182166000908152609c6020908152604080832093909416825291909152205460ff1690565b6101767f000000000000000000000000000000000000000000000000000000000000000081565b6101a16102e33660046115fc565b610841565b60006001600160e01b031982166380ac58cd60e01b148061031957506001600160e01b03198216635b5e139f60e01b145b8061033457506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060978054610349906117a4565b80601f0160208091040260200160405190810160405280929190818152602001828054610375906117a4565b80156103c25780601f10610397576101008083540402835291602001916103c2565b820191906000526020600020905b8154815290600101906020018083116103a557829003601f168201915b5050505050905090565b60006103d7826108b7565b506000908152609b60205260409020546001600160a01b031690565b60006103fe8261055a565b9050806001600160a01b0316836001600160a01b031614156104715760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061048d575061048d8133610280565b6104ff5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610468565b6105098383610916565b505050565b6105183382610984565b6105345760405162461bcd60e51b8152600401610468906117df565b610509838383610a03565b61050983838360405180602001604052806000815250610795565b6000818152609960205260408120546001600160a01b0316806103345760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610468565b60006001600160a01b0382166106245760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610468565b506001600160a01b03166000908152609a602052604090205490565b610648610b74565b6106526000610bce565b565b600054610100900460ff16158080156106745750600054600160ff909116105b8061068e5750303b15801561068e575060005460ff166001145b6106f15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610468565b6000805460ff191660011790558015610714576000805461ff0019166101001790555b61071c610c20565b8015610762576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b606060988054610349906117a4565b61077c610b74565b6107868183610c96565b5050565b610786338383610e2f565b61079f3383610984565b6107bb5760405162461bcd60e51b8152600401610468906117df565b6107c784848484610efe565b50505050565b60606107d8826108b7565b60006107ef60408051602081019091526000815290565b9050600081511161080f576040518060200160405280600081525061083a565b8061081984610f31565b60405160200161082a92919061182c565b6040516020818303038152906040525b9392505050565b610849610b74565b6001600160a01b0381166108ae5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610468565b61076281610bce565b6000818152609960205260409020546001600160a01b03166107625760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610468565b6000818152609b6020526040902080546001600160a01b0319166001600160a01b038416908117909155819061094b8261055a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806109908361055a565b9050806001600160a01b0316846001600160a01b031614806109d757506001600160a01b038082166000908152609c602090815260408083209388168352929052205460ff165b806109fb5750836001600160a01b03166109f0846103cc565b6001600160a01b0316145b949350505050565b826001600160a01b0316610a168261055a565b6001600160a01b031614610a3c5760405162461bcd60e51b81526004016104689061185b565b6001600160a01b038216610a9e5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610468565b610aab8383836001610fce565b826001600160a01b0316610abe8261055a565b6001600160a01b031614610ae45760405162461bcd60e51b81526004016104689061185b565b6000818152609b6020908152604080832080546001600160a01b03199081169091556001600160a01b03878116808652609a8552838620805460001901905590871680865283862080546001019055868652609990945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6033546001600160a01b031633146106525760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610468565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610c475760405162461bcd60e51b8152600401610468906118a0565b610c4f61101d565b6106526040518060400160405280600a8152602001692a32b63632b92637b0b760b11b815250604051806040016040528060038152602001622a262760e91b81525061104c565b6001600160a01b038216610cec5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610468565b6000818152609960205260409020546001600160a01b031615610d515760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610468565b610d5f600083836001610fce565b6000818152609960205260409020546001600160a01b031615610dc45760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610468565b6001600160a01b0382166000818152609a6020908152604080832080546001019055848352609990915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b816001600160a01b0316836001600160a01b03161415610e915760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610468565b6001600160a01b038381166000818152609c6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610f09848484610a03565b610f158484848461107d565b6107c75760405162461bcd60e51b8152600401610468906118eb565b60606000610f3e8361118a565b600101905060008167ffffffffffffffff811115610f5e57610f5e611688565b6040519080825280601f01601f191660200182016040528015610f88576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610fc157610fc6565b610f92565b509392505050565b610fd88383611262565b6107c75760405162461bcd60e51b8152602060048201526016602482015275139bdd08185c1c1c9bdd995908189e481b585c9ad95d60521b6044820152606401610468565b600054610100900460ff166110445760405162461bcd60e51b8152600401610468906118a0565b61065261131b565b600054610100900460ff166110735760405162461bcd60e51b8152600401610468906118a0565b610786828261134b565b60006001600160a01b0384163b1561117f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906110c190339089908890889060040161193d565b602060405180830381600087803b1580156110db57600080fd5b505af192505050801561110b575060408051601f3d908101601f191682019092526111089181019061197a565b60015b611165573d808015611139576040519150601f19603f3d011682016040523d82523d6000602084013e61113e565b606091505b50805161115d5760405162461bcd60e51b8152600401610468906118eb565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506109fb565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106111c95772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106111f5576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061121357662386f26fc10000830492506010015b6305f5e100831061122b576305f5e100830492506008015b612710831061123f57612710830492506004015b60648310611251576064830492506002015b600a83106103345760010192915050565b60008061126e83611399565b604051633ef19a9b60e01b8152600481018290526001600160a01b0386811660248301529192507f000000000000000000000000000000000000000000000000000000000000000090911690633ef19a9b90604401604080518083038186803b1580156112da57600080fd5b505afa1580156112ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113129190611997565b50949350505050565b600054610100900460ff166113425760405162461bcd60e51b8152600401610468906118a0565b61065233610bce565b600054610100900460ff166113725760405162461bcd60e51b8152600401610468906118a0565b815161138590609790602085019061142a565b50805161050990609890602084019061142a565b60006113ad6033546001600160a01b031690565b6001600160a01b03166340910c70836040518263ffffffff1660e01b81526004016113da91815260200190565b60206040518083038186803b1580156113f257600080fd5b505afa158015611406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033491906119c5565b828054611436906117a4565b90600052602060002090601f016020900481019282611458576000855561149e565b82601f1061147157805160ff191683800117855561149e565b8280016001018555821561149e579182015b8281111561149e578251825591602001919060010190611483565b506114aa9291506114ae565b5090565b5b808211156114aa57600081556001016114af565b6001600160e01b03198116811461076257600080fd5b6000602082840312156114eb57600080fd5b813561083a816114c3565b60005b838110156115115781810151838201526020016114f9565b838111156107c75750506000910152565b6000815180845261153a8160208601602086016114f6565b601f01601f19169290920160200192915050565b60208152600061083a6020830184611522565b60006020828403121561157357600080fd5b5035919050565b80356001600160a01b038116811461159157600080fd5b919050565b600080604083850312156115a957600080fd5b6115b28361157a565b946020939093013593505050565b6000806000606084860312156115d557600080fd5b6115de8461157a565b92506115ec6020850161157a565b9150604084013590509250925092565b60006020828403121561160e57600080fd5b61083a8261157a565b6000806040838503121561162a57600080fd5b8235915061163a6020840161157a565b90509250929050565b801515811461076257600080fd5b6000806040838503121561166457600080fd5b61166d8361157a565b9150602083013561167d81611643565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080608085870312156116b457600080fd5b6116bd8561157a565b93506116cb6020860161157a565b925060408501359150606085013567ffffffffffffffff808211156116ef57600080fd5b818701915087601f83011261170357600080fd5b81358181111561171557611715611688565b604051601f8201601f19908116603f0116810190838211818310171561173d5761173d611688565b816040528281528a602084870101111561175657600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561178d57600080fd5b6117968361157a565b915061163a6020840161157a565b600181811c908216806117b857607f821691505b602082108114156117d957634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b6000835161183e8184602088016114f6565b8351908301906118528183602088016114f6565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061197090830184611522565b9695505050505050565b60006020828403121561198c57600080fd5b815161083a816114c3565b600080604083850312156119aa57600080fd5b82516119b581611643565b6020939093015192949293505050565b6000602082840312156119d757600080fd5b505191905056fea264697066735822122081492d617fe232f4b830115f4a5a4964f28b2a1128d2a6d4fe009d9ceacde1d564736f6c63430008090033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101215760003560e01c80638129fc1c116100ad578063b88d4fde11610071578063b88d4fde1461024c578063c87b56dd1461025f578063e985e9c514610272578063ecb96fe6146102ae578063f2fde38b146102d557600080fd5b80638129fc1c146102055780638da5cb5b1461020d57806395d89b411461021e57806396c9983014610226578063a22cb4651461023957600080fd5b806323b872dd116100f457806323b872dd146101a357806342842e0e146101b65780636352211e146101c957806370a08231146101dc578063715018a6146101fd57600080fd5b806301ffc9a71461012657806306fdde031461014e578063081812fc14610163578063095ea7b31461018e575b600080fd5b6101396101343660046114d9565b6102e8565b60405190151581526020015b60405180910390f35b61015661033a565b604051610145919061154e565b610176610171366004611561565b6103cc565b6040516001600160a01b039091168152602001610145565b6101a161019c366004611596565b6103f3565b005b6101a16101b13660046115c0565b61050e565b6101a16101c43660046115c0565b61053f565b6101766101d7366004611561565b61055a565b6101ef6101ea3660046115fc565b6105ba565b604051908152602001610145565b6101a1610640565b6101a1610654565b6033546001600160a01b0316610176565b610156610765565b6101a1610234366004611617565b610774565b6101a1610247366004611651565b61078a565b6101a161025a36600461169e565b610795565b61015661026d366004611561565b6107cd565b61013961028036600461177a565b6001600160a01b039182166000908152609c6020908152604080832093909416825291909152205460ff1690565b6101767f000000000000000000000000000000000000000000000000000000000000000081565b6101a16102e33660046115fc565b610841565b60006001600160e01b031982166380ac58cd60e01b148061031957506001600160e01b03198216635b5e139f60e01b145b8061033457506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060978054610349906117a4565b80601f0160208091040260200160405190810160405280929190818152602001828054610375906117a4565b80156103c25780601f10610397576101008083540402835291602001916103c2565b820191906000526020600020905b8154815290600101906020018083116103a557829003601f168201915b5050505050905090565b60006103d7826108b7565b506000908152609b60205260409020546001600160a01b031690565b60006103fe8261055a565b9050806001600160a01b0316836001600160a01b031614156104715760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061048d575061048d8133610280565b6104ff5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610468565b6105098383610916565b505050565b6105183382610984565b6105345760405162461bcd60e51b8152600401610468906117df565b610509838383610a03565b61050983838360405180602001604052806000815250610795565b6000818152609960205260408120546001600160a01b0316806103345760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610468565b60006001600160a01b0382166106245760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610468565b506001600160a01b03166000908152609a602052604090205490565b610648610b74565b6106526000610bce565b565b600054610100900460ff16158080156106745750600054600160ff909116105b8061068e5750303b15801561068e575060005460ff166001145b6106f15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610468565b6000805460ff191660011790558015610714576000805461ff0019166101001790555b61071c610c20565b8015610762576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b606060988054610349906117a4565b61077c610b74565b6107868183610c96565b5050565b610786338383610e2f565b61079f3383610984565b6107bb5760405162461bcd60e51b8152600401610468906117df565b6107c784848484610efe565b50505050565b60606107d8826108b7565b60006107ef60408051602081019091526000815290565b9050600081511161080f576040518060200160405280600081525061083a565b8061081984610f31565b60405160200161082a92919061182c565b6040516020818303038152906040525b9392505050565b610849610b74565b6001600160a01b0381166108ae5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610468565b61076281610bce565b6000818152609960205260409020546001600160a01b03166107625760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610468565b6000818152609b6020526040902080546001600160a01b0319166001600160a01b038416908117909155819061094b8261055a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806109908361055a565b9050806001600160a01b0316846001600160a01b031614806109d757506001600160a01b038082166000908152609c602090815260408083209388168352929052205460ff165b806109fb5750836001600160a01b03166109f0846103cc565b6001600160a01b0316145b949350505050565b826001600160a01b0316610a168261055a565b6001600160a01b031614610a3c5760405162461bcd60e51b81526004016104689061185b565b6001600160a01b038216610a9e5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610468565b610aab8383836001610fce565b826001600160a01b0316610abe8261055a565b6001600160a01b031614610ae45760405162461bcd60e51b81526004016104689061185b565b6000818152609b6020908152604080832080546001600160a01b03199081169091556001600160a01b03878116808652609a8552838620805460001901905590871680865283862080546001019055868652609990945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6033546001600160a01b031633146106525760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610468565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610c475760405162461bcd60e51b8152600401610468906118a0565b610c4f61101d565b6106526040518060400160405280600a8152602001692a32b63632b92637b0b760b11b815250604051806040016040528060038152602001622a262760e91b81525061104c565b6001600160a01b038216610cec5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610468565b6000818152609960205260409020546001600160a01b031615610d515760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610468565b610d5f600083836001610fce565b6000818152609960205260409020546001600160a01b031615610dc45760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610468565b6001600160a01b0382166000818152609a6020908152604080832080546001019055848352609990915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b816001600160a01b0316836001600160a01b03161415610e915760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610468565b6001600160a01b038381166000818152609c6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610f09848484610a03565b610f158484848461107d565b6107c75760405162461bcd60e51b8152600401610468906118eb565b60606000610f3e8361118a565b600101905060008167ffffffffffffffff811115610f5e57610f5e611688565b6040519080825280601f01601f191660200182016040528015610f88576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610fc157610fc6565b610f92565b509392505050565b610fd88383611262565b6107c75760405162461bcd60e51b8152602060048201526016602482015275139bdd08185c1c1c9bdd995908189e481b585c9ad95d60521b6044820152606401610468565b600054610100900460ff166110445760405162461bcd60e51b8152600401610468906118a0565b61065261131b565b600054610100900460ff166110735760405162461bcd60e51b8152600401610468906118a0565b610786828261134b565b60006001600160a01b0384163b1561117f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906110c190339089908890889060040161193d565b602060405180830381600087803b1580156110db57600080fd5b505af192505050801561110b575060408051601f3d908101601f191682019092526111089181019061197a565b60015b611165573d808015611139576040519150601f19603f3d011682016040523d82523d6000602084013e61113e565b606091505b50805161115d5760405162461bcd60e51b8152600401610468906118eb565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506109fb565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106111c95772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106111f5576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061121357662386f26fc10000830492506010015b6305f5e100831061122b576305f5e100830492506008015b612710831061123f57612710830492506004015b60648310611251576064830492506002015b600a83106103345760010192915050565b60008061126e83611399565b604051633ef19a9b60e01b8152600481018290526001600160a01b0386811660248301529192507f000000000000000000000000000000000000000000000000000000000000000090911690633ef19a9b90604401604080518083038186803b1580156112da57600080fd5b505afa1580156112ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113129190611997565b50949350505050565b600054610100900460ff166113425760405162461bcd60e51b8152600401610468906118a0565b61065233610bce565b600054610100900460ff166113725760405162461bcd60e51b8152600401610468906118a0565b815161138590609790602085019061142a565b50805161050990609890602084019061142a565b60006113ad6033546001600160a01b031690565b6001600160a01b03166340910c70836040518263ffffffff1660e01b81526004016113da91815260200190565b60206040518083038186803b1580156113f257600080fd5b505afa158015611406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033491906119c5565b828054611436906117a4565b90600052602060002090601f016020900481019282611458576000855561149e565b82601f1061147157805160ff191683800117855561149e565b8280016001018555821561149e579182015b8281111561149e578251825591602001919060010190611483565b506114aa9291506114ae565b5090565b5b808211156114aa57600081556001016114af565b6001600160e01b03198116811461076257600080fd5b6000602082840312156114eb57600080fd5b813561083a816114c3565b60005b838110156115115781810151838201526020016114f9565b838111156107c75750506000910152565b6000815180845261153a8160208601602086016114f6565b601f01601f19169290920160200192915050565b60208152600061083a6020830184611522565b60006020828403121561157357600080fd5b5035919050565b80356001600160a01b038116811461159157600080fd5b919050565b600080604083850312156115a957600080fd5b6115b28361157a565b946020939093013593505050565b6000806000606084860312156115d557600080fd5b6115de8461157a565b92506115ec6020850161157a565b9150604084013590509250925092565b60006020828403121561160e57600080fd5b61083a8261157a565b6000806040838503121561162a57600080fd5b8235915061163a6020840161157a565b90509250929050565b801515811461076257600080fd5b6000806040838503121561166457600080fd5b61166d8361157a565b9150602083013561167d81611643565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080608085870312156116b457600080fd5b6116bd8561157a565b93506116cb6020860161157a565b925060408501359150606085013567ffffffffffffffff808211156116ef57600080fd5b818701915087601f83011261170357600080fd5b81358181111561171557611715611688565b604051601f8201601f19908116603f0116810190838211818310171561173d5761173d611688565b816040528281528a602084870101111561175657600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561178d57600080fd5b6117968361157a565b915061163a6020840161157a565b600181811c908216806117b857607f821691505b602082108114156117d957634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b6000835161183e8184602088016114f6565b8351908301906118528183602088016114f6565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061197090830184611522565b9695505050505050565b60006020828403121561198c57600080fd5b815161083a816114c3565b600080604083850312156119aa57600080fd5b82516119b581611643565b6020939093015192949293505050565b6000602082840312156119d757600080fd5b505191905056fea264697066735822122081492d617fe232f4b830115f4a5a4964f28b2a1128d2a6d4fe009d9ceacde1d564736f6c63430008090033", + "numDeployments": 1, + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IMarketRegistry\",\"name\":\"_marketRegistry\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketRegistry\",\"outputs\":[{\"internalType\":\"contract IMarketRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_newLender\",\"type\":\"address\"}],\"name\":\"registerLoan\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address,uint256)\":{\"details\":\"See {IERC721-approve}.\"},\"balanceOf(address)\":{\"details\":\"See {IERC721-balanceOf}.\"},\"getApproved(uint256)\":{\"details\":\"See {IERC721-getApproved}.\"},\"isApprovedForAll(address,address)\":{\"details\":\"See {IERC721-isApprovedForAll}.\"},\"name()\":{\"details\":\"See {IERC721Metadata-name}.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"ownerOf(uint256)\":{\"details\":\"See {IERC721-ownerOf}.\"},\"registerLoan(uint256,address)\":{\"params\":{\"_bidId\":\"The id for the loan to set.\",\"_newLender\":\"The address of the new active lender.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"safeTransferFrom(address,address,uint256)\":{\"details\":\"See {IERC721-safeTransferFrom}.\"},\"safeTransferFrom(address,address,uint256,bytes)\":{\"details\":\"See {IERC721-safeTransferFrom}.\"},\"setApprovalForAll(address,bool)\":{\"details\":\"See {IERC721-setApprovalForAll}.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"},\"symbol()\":{\"details\":\"See {IERC721Metadata-symbol}.\"},\"tokenURI(uint256)\":{\"details\":\"See {IERC721Metadata-tokenURI}.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC721-transferFrom}.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"registerLoan(uint256,address)\":{\"notice\":\"Registers a new active lender for a loan, minting the nft\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/LenderManager.sol\":\"LenderManager\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC721Upgradeable.sol\\\";\\nimport \\\"./IERC721ReceiverUpgradeable.sol\\\";\\nimport \\\"./extensions/IERC721MetadataUpgradeable.sol\\\";\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../utils/StringsUpgradeable.sol\\\";\\nimport \\\"../../utils/introspection/ERC165Upgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\\n * {ERC721Enumerable}.\\n */\\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\\n using AddressUpgradeable for address;\\n using StringsUpgradeable for uint256;\\n\\n // Token name\\n string private _name;\\n\\n // Token symbol\\n string private _symbol;\\n\\n // Mapping from token ID to owner address\\n mapping(uint256 => address) private _owners;\\n\\n // Mapping owner address to token count\\n mapping(address => uint256) private _balances;\\n\\n // Mapping from token ID to approved address\\n mapping(uint256 => address) private _tokenApprovals;\\n\\n // Mapping from owner to operator approvals\\n mapping(address => mapping(address => bool)) private _operatorApprovals;\\n\\n /**\\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\\n */\\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\\n __ERC721_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\\n return\\n interfaceId == type(IERC721Upgradeable).interfaceId ||\\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\\n super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev See {IERC721-balanceOf}.\\n */\\n function balanceOf(address owner) public view virtual override returns (uint256) {\\n require(owner != address(0), \\\"ERC721: address zero is not a valid owner\\\");\\n return _balances[owner];\\n }\\n\\n /**\\n * @dev See {IERC721-ownerOf}.\\n */\\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\\n address owner = _ownerOf(tokenId);\\n require(owner != address(0), \\\"ERC721: invalid token ID\\\");\\n return owner;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-name}.\\n */\\n function name() public view virtual override returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-symbol}.\\n */\\n function symbol() public view virtual override returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-tokenURI}.\\n */\\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\\n _requireMinted(tokenId);\\n\\n string memory baseURI = _baseURI();\\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \\\"\\\";\\n }\\n\\n /**\\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\\n * by default, can be overridden in child contracts.\\n */\\n function _baseURI() internal view virtual returns (string memory) {\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev See {IERC721-approve}.\\n */\\n function approve(address to, uint256 tokenId) public virtual override {\\n address owner = ERC721Upgradeable.ownerOf(tokenId);\\n require(to != owner, \\\"ERC721: approval to current owner\\\");\\n\\n require(\\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\\n \\\"ERC721: approve caller is not token owner or approved for all\\\"\\n );\\n\\n _approve(to, tokenId);\\n }\\n\\n /**\\n * @dev See {IERC721-getApproved}.\\n */\\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\\n _requireMinted(tokenId);\\n\\n return _tokenApprovals[tokenId];\\n }\\n\\n /**\\n * @dev See {IERC721-setApprovalForAll}.\\n */\\n function setApprovalForAll(address operator, bool approved) public virtual override {\\n _setApprovalForAll(_msgSender(), operator, approved);\\n }\\n\\n /**\\n * @dev See {IERC721-isApprovedForAll}.\\n */\\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\\n return _operatorApprovals[owner][operator];\\n }\\n\\n /**\\n * @dev See {IERC721-transferFrom}.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) public virtual override {\\n //solhint-disable-next-line max-line-length\\n require(_isApprovedOrOwner(_msgSender(), tokenId), \\\"ERC721: caller is not token owner or approved\\\");\\n\\n _transfer(from, to, tokenId);\\n }\\n\\n /**\\n * @dev See {IERC721-safeTransferFrom}.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) public virtual override {\\n safeTransferFrom(from, to, tokenId, \\\"\\\");\\n }\\n\\n /**\\n * @dev See {IERC721-safeTransferFrom}.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes memory data\\n ) public virtual override {\\n require(_isApprovedOrOwner(_msgSender(), tokenId), \\\"ERC721: caller is not token owner or approved\\\");\\n _safeTransfer(from, to, tokenId, data);\\n }\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\\n *\\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\\n * implement alternative mechanisms to perform token transfer, such as signature-based.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _safeTransfer(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes memory data\\n ) internal virtual {\\n _transfer(from, to, tokenId);\\n require(_checkOnERC721Received(from, to, tokenId, data), \\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n }\\n\\n /**\\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\\n */\\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\\n return _owners[tokenId];\\n }\\n\\n /**\\n * @dev Returns whether `tokenId` exists.\\n *\\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\\n *\\n * Tokens start existing when they are minted (`_mint`),\\n * and stop existing when they are burned (`_burn`).\\n */\\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\\n return _ownerOf(tokenId) != address(0);\\n }\\n\\n /**\\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\\n address owner = ERC721Upgradeable.ownerOf(tokenId);\\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\\n }\\n\\n /**\\n * @dev Safely mints `tokenId` and transfers it to `to`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _safeMint(address to, uint256 tokenId) internal virtual {\\n _safeMint(to, tokenId, \\\"\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\\n */\\n function _safeMint(\\n address to,\\n uint256 tokenId,\\n bytes memory data\\n ) internal virtual {\\n _mint(to, tokenId);\\n require(\\n _checkOnERC721Received(address(0), to, tokenId, data),\\n \\\"ERC721: transfer to non ERC721Receiver implementer\\\"\\n );\\n }\\n\\n /**\\n * @dev Mints `tokenId` and transfers it to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - `to` cannot be the zero address.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _mint(address to, uint256 tokenId) internal virtual {\\n require(to != address(0), \\\"ERC721: mint to the zero address\\\");\\n require(!_exists(tokenId), \\\"ERC721: token already minted\\\");\\n\\n _beforeTokenTransfer(address(0), to, tokenId, 1);\\n\\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\\n require(!_exists(tokenId), \\\"ERC721: token already minted\\\");\\n\\n unchecked {\\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\\n // Given that tokens are minted one by one, it is impossible in practice that\\n // this ever happens. Might change if we allow batch minting.\\n // The ERC fails to describe this case.\\n _balances[to] += 1;\\n }\\n\\n _owners[tokenId] = to;\\n\\n emit Transfer(address(0), to, tokenId);\\n\\n _afterTokenTransfer(address(0), to, tokenId, 1);\\n }\\n\\n /**\\n * @dev Destroys `tokenId`.\\n * The approval is cleared when the token is burned.\\n * This is an internal function that does not check if the sender is authorized to operate on the token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _burn(uint256 tokenId) internal virtual {\\n address owner = ERC721Upgradeable.ownerOf(tokenId);\\n\\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\\n\\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\\n owner = ERC721Upgradeable.ownerOf(tokenId);\\n\\n // Clear approvals\\n delete _tokenApprovals[tokenId];\\n\\n unchecked {\\n // Cannot overflow, as that would require more tokens to be burned/transferred\\n // out than the owner initially received through minting and transferring in.\\n _balances[owner] -= 1;\\n }\\n delete _owners[tokenId];\\n\\n emit Transfer(owner, address(0), tokenId);\\n\\n _afterTokenTransfer(owner, address(0), tokenId, 1);\\n }\\n\\n /**\\n * @dev Transfers `tokenId` from `from` to `to`.\\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 tokenId\\n ) internal virtual {\\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \\\"ERC721: transfer from incorrect owner\\\");\\n require(to != address(0), \\\"ERC721: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, tokenId, 1);\\n\\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \\\"ERC721: transfer from incorrect owner\\\");\\n\\n // Clear approvals from the previous owner\\n delete _tokenApprovals[tokenId];\\n\\n unchecked {\\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\\n // `from`'s balance is the number of token held, which is at least one before the current\\n // transfer.\\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\\n // all 2**256 token ids to be minted, which in practice is impossible.\\n _balances[from] -= 1;\\n _balances[to] += 1;\\n }\\n _owners[tokenId] = to;\\n\\n emit Transfer(from, to, tokenId);\\n\\n _afterTokenTransfer(from, to, tokenId, 1);\\n }\\n\\n /**\\n * @dev Approve `to` to operate on `tokenId`\\n *\\n * Emits an {Approval} event.\\n */\\n function _approve(address to, uint256 tokenId) internal virtual {\\n _tokenApprovals[tokenId] = to;\\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\\n }\\n\\n /**\\n * @dev Approve `operator` to operate on all of `owner` tokens\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function _setApprovalForAll(\\n address owner,\\n address operator,\\n bool approved\\n ) internal virtual {\\n require(owner != operator, \\\"ERC721: approve to caller\\\");\\n _operatorApprovals[owner][operator] = approved;\\n emit ApprovalForAll(owner, operator, approved);\\n }\\n\\n /**\\n * @dev Reverts if the `tokenId` has not been minted yet.\\n */\\n function _requireMinted(uint256 tokenId) internal view virtual {\\n require(_exists(tokenId), \\\"ERC721: invalid token ID\\\");\\n }\\n\\n /**\\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\\n * The call is not executed if the target address is not a contract.\\n *\\n * @param from address representing the previous owner of the given token ID\\n * @param to target address that will receive the tokens\\n * @param tokenId uint256 ID of the token to be transferred\\n * @param data bytes optional data to send along with the call\\n * @return bool whether the call correctly returned the expected magic value\\n */\\n function _checkOnERC721Received(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes memory data\\n ) private returns (bool) {\\n if (to.isContract()) {\\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\\n } catch (bytes memory reason) {\\n if (reason.length == 0) {\\n revert(\\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n } else {\\n /// @solidity memory-safe-assembly\\n assembly {\\n revert(add(32, reason), mload(reason))\\n }\\n }\\n }\\n } else {\\n return true;\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\\n * - When `from` is zero, the tokens will be minted for `to`.\\n * - When `to` is zero, ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n * - `batchSize` is non-zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256, /* firstTokenId */\\n uint256 batchSize\\n ) internal virtual {\\n if (batchSize > 1) {\\n if (from != address(0)) {\\n _balances[from] -= batchSize;\\n }\\n if (to != address(0)) {\\n _balances[to] += batchSize;\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\\n * - When `from` is zero, the tokens were minted for `to`.\\n * - When `to` is zero, ``from``'s tokens were burned.\\n * - `from` and `to` are never both zero.\\n * - `batchSize` is non-zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 firstTokenId,\\n uint256 batchSize\\n ) internal virtual {}\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[44] private __gap;\\n}\\n\",\"keccak256\":\"0x2a6a0b9fd2d316dcb4141159a9d13be92654066d6c0ae92757ed908ecdfecff0\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721ReceiverUpgradeable {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xbb2ed8106d94aeae6858e2551a1e7174df73994b77b13ebd120ccaaef80155f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC721Upgradeable.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0x95a471796eb5f030fdc438660bebec121ad5d063763e64d92376ffb4b5ce8b70\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0x6b9a5d35b744b25529a2856a8093e7c03fb35a34b1c4fb5499e560f8ade140da\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165Upgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\\n function __ERC165_init() internal onlyInitializing {\\n }\\n\\n function __ERC165_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165Upgradeable).interfaceId;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x9a3b990bd56d139df3e454a9edf1c64668530b5a77fc32eb063bc206f958274a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/LenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// Contracts\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\\\";\\n\\n// Interfaces\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\nimport \\\"./interfaces/IMarketRegistry.sol\\\";\\n\\ncontract LenderManager is\\n Initializable,\\n OwnableUpgradeable,\\n ERC721Upgradeable,\\n ILenderManager\\n{\\n IMarketRegistry public immutable marketRegistry;\\n\\n constructor(IMarketRegistry _marketRegistry) {\\n marketRegistry = _marketRegistry;\\n }\\n\\n function initialize() external initializer {\\n __LenderManager_init();\\n }\\n\\n function __LenderManager_init() internal onlyInitializing {\\n __Ownable_init();\\n __ERC721_init(\\\"TellerLoan\\\", \\\"TLN\\\");\\n }\\n\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender)\\n public\\n override\\n onlyOwner\\n {\\n _mint(_newLender, _bidId);\\n }\\n\\n /**\\n * @notice Returns the address of the lender that owns a given loan/bid.\\n * @param _bidId The id of the bid of which to return the market id\\n */\\n function _getLoanMarketId(uint256 _bidId) internal view returns (uint256) {\\n return ITellerV2(owner()).getLoanMarketId(_bidId);\\n }\\n\\n /**\\n * @notice Returns the verification status of a lender for a market.\\n * @param _lender The address of the lender which should be verified by the market\\n * @param _bidId The id of the bid of which to return the market id\\n */\\n function _hasMarketVerification(address _lender, uint256 _bidId)\\n internal\\n view\\n virtual\\n returns (bool isVerified_)\\n {\\n uint256 _marketId = _getLoanMarketId(_bidId);\\n\\n (isVerified_, ) = marketRegistry.isVerifiedLender(_marketId, _lender);\\n }\\n\\n /** ERC721 Functions **/\\n\\n function _beforeTokenTransfer(address, address to, uint256 tokenId, uint256)\\n internal\\n override\\n {\\n require(_hasMarketVerification(to, tokenId), \\\"Not approved by market\\\");\\n }\\n\\n function _baseURI() internal view override returns (string memory) {\\n return \\\"\\\";\\n }\\n}\\n\",\"keccak256\":\"0x72262bc29f5a18a73dbe0b9ebb2fea028b62922b3a122c79e2521fa148e0f09e\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\\n external\\n view\\n returns (uint256 _amount);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x27778a3446cdbfed6356d5047f9926231261b37def2712a3cc63e3779350e5e4\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanLiquidateable(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n\\n function getLoanSummary(uint256 _bidId)\\n external\\n view\\n returns (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n );\\n}\\n\",\"keccak256\":\"0x2750d9717451e34323ef523810ff2a3a6285f146009955220d3860a7c4326077\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405234801561001057600080fd5b50604051611aa6380380611aa683398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051611a14610092600039600081816102b301526112970152611a146000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c80638129fc1c116100ad578063b88d4fde11610071578063b88d4fde1461024c578063c87b56dd1461025f578063e985e9c514610272578063ecb96fe6146102ae578063f2fde38b146102d557600080fd5b80638129fc1c146102055780638da5cb5b1461020d57806395d89b411461021e57806396c9983014610226578063a22cb4651461023957600080fd5b806323b872dd116100f457806323b872dd146101a357806342842e0e146101b65780636352211e146101c957806370a08231146101dc578063715018a6146101fd57600080fd5b806301ffc9a71461012657806306fdde031461014e578063081812fc14610163578063095ea7b31461018e575b600080fd5b6101396101343660046114d9565b6102e8565b60405190151581526020015b60405180910390f35b61015661033a565b604051610145919061154e565b610176610171366004611561565b6103cc565b6040516001600160a01b039091168152602001610145565b6101a161019c366004611596565b6103f3565b005b6101a16101b13660046115c0565b61050e565b6101a16101c43660046115c0565b61053f565b6101766101d7366004611561565b61055a565b6101ef6101ea3660046115fc565b6105ba565b604051908152602001610145565b6101a1610640565b6101a1610654565b6033546001600160a01b0316610176565b610156610765565b6101a1610234366004611617565b610774565b6101a1610247366004611651565b61078a565b6101a161025a36600461169e565b610795565b61015661026d366004611561565b6107cd565b61013961028036600461177a565b6001600160a01b039182166000908152609c6020908152604080832093909416825291909152205460ff1690565b6101767f000000000000000000000000000000000000000000000000000000000000000081565b6101a16102e33660046115fc565b610841565b60006001600160e01b031982166380ac58cd60e01b148061031957506001600160e01b03198216635b5e139f60e01b145b8061033457506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060978054610349906117a4565b80601f0160208091040260200160405190810160405280929190818152602001828054610375906117a4565b80156103c25780601f10610397576101008083540402835291602001916103c2565b820191906000526020600020905b8154815290600101906020018083116103a557829003601f168201915b5050505050905090565b60006103d7826108b7565b506000908152609b60205260409020546001600160a01b031690565b60006103fe8261055a565b9050806001600160a01b0316836001600160a01b031614156104715760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061048d575061048d8133610280565b6104ff5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610468565b6105098383610916565b505050565b6105183382610984565b6105345760405162461bcd60e51b8152600401610468906117df565b610509838383610a03565b61050983838360405180602001604052806000815250610795565b6000818152609960205260408120546001600160a01b0316806103345760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610468565b60006001600160a01b0382166106245760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610468565b506001600160a01b03166000908152609a602052604090205490565b610648610b74565b6106526000610bce565b565b600054610100900460ff16158080156106745750600054600160ff909116105b8061068e5750303b15801561068e575060005460ff166001145b6106f15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610468565b6000805460ff191660011790558015610714576000805461ff0019166101001790555b61071c610c20565b8015610762576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b606060988054610349906117a4565b61077c610b74565b6107868183610c96565b5050565b610786338383610e2f565b61079f3383610984565b6107bb5760405162461bcd60e51b8152600401610468906117df565b6107c784848484610efe565b50505050565b60606107d8826108b7565b60006107ef60408051602081019091526000815290565b9050600081511161080f576040518060200160405280600081525061083a565b8061081984610f31565b60405160200161082a92919061182c565b6040516020818303038152906040525b9392505050565b610849610b74565b6001600160a01b0381166108ae5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610468565b61076281610bce565b6000818152609960205260409020546001600160a01b03166107625760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610468565b6000818152609b6020526040902080546001600160a01b0319166001600160a01b038416908117909155819061094b8261055a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806109908361055a565b9050806001600160a01b0316846001600160a01b031614806109d757506001600160a01b038082166000908152609c602090815260408083209388168352929052205460ff165b806109fb5750836001600160a01b03166109f0846103cc565b6001600160a01b0316145b949350505050565b826001600160a01b0316610a168261055a565b6001600160a01b031614610a3c5760405162461bcd60e51b81526004016104689061185b565b6001600160a01b038216610a9e5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610468565b610aab8383836001610fce565b826001600160a01b0316610abe8261055a565b6001600160a01b031614610ae45760405162461bcd60e51b81526004016104689061185b565b6000818152609b6020908152604080832080546001600160a01b03199081169091556001600160a01b03878116808652609a8552838620805460001901905590871680865283862080546001019055868652609990945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6033546001600160a01b031633146106525760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610468565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610c475760405162461bcd60e51b8152600401610468906118a0565b610c4f61101d565b6106526040518060400160405280600a8152602001692a32b63632b92637b0b760b11b815250604051806040016040528060038152602001622a262760e91b81525061104c565b6001600160a01b038216610cec5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610468565b6000818152609960205260409020546001600160a01b031615610d515760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610468565b610d5f600083836001610fce565b6000818152609960205260409020546001600160a01b031615610dc45760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610468565b6001600160a01b0382166000818152609a6020908152604080832080546001019055848352609990915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b816001600160a01b0316836001600160a01b03161415610e915760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610468565b6001600160a01b038381166000818152609c6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610f09848484610a03565b610f158484848461107d565b6107c75760405162461bcd60e51b8152600401610468906118eb565b60606000610f3e8361118a565b600101905060008167ffffffffffffffff811115610f5e57610f5e611688565b6040519080825280601f01601f191660200182016040528015610f88576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610fc157610fc6565b610f92565b509392505050565b610fd88383611262565b6107c75760405162461bcd60e51b8152602060048201526016602482015275139bdd08185c1c1c9bdd995908189e481b585c9ad95d60521b6044820152606401610468565b600054610100900460ff166110445760405162461bcd60e51b8152600401610468906118a0565b61065261131b565b600054610100900460ff166110735760405162461bcd60e51b8152600401610468906118a0565b610786828261134b565b60006001600160a01b0384163b1561117f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906110c190339089908890889060040161193d565b602060405180830381600087803b1580156110db57600080fd5b505af192505050801561110b575060408051601f3d908101601f191682019092526111089181019061197a565b60015b611165573d808015611139576040519150601f19603f3d011682016040523d82523d6000602084013e61113e565b606091505b50805161115d5760405162461bcd60e51b8152600401610468906118eb565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506109fb565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106111c95772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106111f5576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061121357662386f26fc10000830492506010015b6305f5e100831061122b576305f5e100830492506008015b612710831061123f57612710830492506004015b60648310611251576064830492506002015b600a83106103345760010192915050565b60008061126e83611399565b604051633ef19a9b60e01b8152600481018290526001600160a01b0386811660248301529192507f000000000000000000000000000000000000000000000000000000000000000090911690633ef19a9b90604401604080518083038186803b1580156112da57600080fd5b505afa1580156112ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113129190611997565b50949350505050565b600054610100900460ff166113425760405162461bcd60e51b8152600401610468906118a0565b61065233610bce565b600054610100900460ff166113725760405162461bcd60e51b8152600401610468906118a0565b815161138590609790602085019061142a565b50805161050990609890602084019061142a565b60006113ad6033546001600160a01b031690565b6001600160a01b03166340910c70836040518263ffffffff1660e01b81526004016113da91815260200190565b60206040518083038186803b1580156113f257600080fd5b505afa158015611406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033491906119c5565b828054611436906117a4565b90600052602060002090601f016020900481019282611458576000855561149e565b82601f1061147157805160ff191683800117855561149e565b8280016001018555821561149e579182015b8281111561149e578251825591602001919060010190611483565b506114aa9291506114ae565b5090565b5b808211156114aa57600081556001016114af565b6001600160e01b03198116811461076257600080fd5b6000602082840312156114eb57600080fd5b813561083a816114c3565b60005b838110156115115781810151838201526020016114f9565b838111156107c75750506000910152565b6000815180845261153a8160208601602086016114f6565b601f01601f19169290920160200192915050565b60208152600061083a6020830184611522565b60006020828403121561157357600080fd5b5035919050565b80356001600160a01b038116811461159157600080fd5b919050565b600080604083850312156115a957600080fd5b6115b28361157a565b946020939093013593505050565b6000806000606084860312156115d557600080fd5b6115de8461157a565b92506115ec6020850161157a565b9150604084013590509250925092565b60006020828403121561160e57600080fd5b61083a8261157a565b6000806040838503121561162a57600080fd5b8235915061163a6020840161157a565b90509250929050565b801515811461076257600080fd5b6000806040838503121561166457600080fd5b61166d8361157a565b9150602083013561167d81611643565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080608085870312156116b457600080fd5b6116bd8561157a565b93506116cb6020860161157a565b925060408501359150606085013567ffffffffffffffff808211156116ef57600080fd5b818701915087601f83011261170357600080fd5b81358181111561171557611715611688565b604051601f8201601f19908116603f0116810190838211818310171561173d5761173d611688565b816040528281528a602084870101111561175657600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561178d57600080fd5b6117968361157a565b915061163a6020840161157a565b600181811c908216806117b857607f821691505b602082108114156117d957634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b6000835161183e8184602088016114f6565b8351908301906118528183602088016114f6565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061197090830184611522565b9695505050505050565b60006020828403121561198c57600080fd5b815161083a816114c3565b600080604083850312156119aa57600080fd5b82516119b581611643565b6020939093015192949293505050565b6000602082840312156119d757600080fd5b505191905056fea26469706673582212208e0db6725c30428d4b5360745cbb02f505d2464a02a23fe3efbcf6b4194632e564736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101215760003560e01c80638129fc1c116100ad578063b88d4fde11610071578063b88d4fde1461024c578063c87b56dd1461025f578063e985e9c514610272578063ecb96fe6146102ae578063f2fde38b146102d557600080fd5b80638129fc1c146102055780638da5cb5b1461020d57806395d89b411461021e57806396c9983014610226578063a22cb4651461023957600080fd5b806323b872dd116100f457806323b872dd146101a357806342842e0e146101b65780636352211e146101c957806370a08231146101dc578063715018a6146101fd57600080fd5b806301ffc9a71461012657806306fdde031461014e578063081812fc14610163578063095ea7b31461018e575b600080fd5b6101396101343660046114d9565b6102e8565b60405190151581526020015b60405180910390f35b61015661033a565b604051610145919061154e565b610176610171366004611561565b6103cc565b6040516001600160a01b039091168152602001610145565b6101a161019c366004611596565b6103f3565b005b6101a16101b13660046115c0565b61050e565b6101a16101c43660046115c0565b61053f565b6101766101d7366004611561565b61055a565b6101ef6101ea3660046115fc565b6105ba565b604051908152602001610145565b6101a1610640565b6101a1610654565b6033546001600160a01b0316610176565b610156610765565b6101a1610234366004611617565b610774565b6101a1610247366004611651565b61078a565b6101a161025a36600461169e565b610795565b61015661026d366004611561565b6107cd565b61013961028036600461177a565b6001600160a01b039182166000908152609c6020908152604080832093909416825291909152205460ff1690565b6101767f000000000000000000000000000000000000000000000000000000000000000081565b6101a16102e33660046115fc565b610841565b60006001600160e01b031982166380ac58cd60e01b148061031957506001600160e01b03198216635b5e139f60e01b145b8061033457506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060978054610349906117a4565b80601f0160208091040260200160405190810160405280929190818152602001828054610375906117a4565b80156103c25780601f10610397576101008083540402835291602001916103c2565b820191906000526020600020905b8154815290600101906020018083116103a557829003601f168201915b5050505050905090565b60006103d7826108b7565b506000908152609b60205260409020546001600160a01b031690565b60006103fe8261055a565b9050806001600160a01b0316836001600160a01b031614156104715760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061048d575061048d8133610280565b6104ff5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610468565b6105098383610916565b505050565b6105183382610984565b6105345760405162461bcd60e51b8152600401610468906117df565b610509838383610a03565b61050983838360405180602001604052806000815250610795565b6000818152609960205260408120546001600160a01b0316806103345760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610468565b60006001600160a01b0382166106245760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610468565b506001600160a01b03166000908152609a602052604090205490565b610648610b74565b6106526000610bce565b565b600054610100900460ff16158080156106745750600054600160ff909116105b8061068e5750303b15801561068e575060005460ff166001145b6106f15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610468565b6000805460ff191660011790558015610714576000805461ff0019166101001790555b61071c610c20565b8015610762576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b606060988054610349906117a4565b61077c610b74565b6107868183610c96565b5050565b610786338383610e2f565b61079f3383610984565b6107bb5760405162461bcd60e51b8152600401610468906117df565b6107c784848484610efe565b50505050565b60606107d8826108b7565b60006107ef60408051602081019091526000815290565b9050600081511161080f576040518060200160405280600081525061083a565b8061081984610f31565b60405160200161082a92919061182c565b6040516020818303038152906040525b9392505050565b610849610b74565b6001600160a01b0381166108ae5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610468565b61076281610bce565b6000818152609960205260409020546001600160a01b03166107625760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610468565b6000818152609b6020526040902080546001600160a01b0319166001600160a01b038416908117909155819061094b8261055a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806109908361055a565b9050806001600160a01b0316846001600160a01b031614806109d757506001600160a01b038082166000908152609c602090815260408083209388168352929052205460ff165b806109fb5750836001600160a01b03166109f0846103cc565b6001600160a01b0316145b949350505050565b826001600160a01b0316610a168261055a565b6001600160a01b031614610a3c5760405162461bcd60e51b81526004016104689061185b565b6001600160a01b038216610a9e5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610468565b610aab8383836001610fce565b826001600160a01b0316610abe8261055a565b6001600160a01b031614610ae45760405162461bcd60e51b81526004016104689061185b565b6000818152609b6020908152604080832080546001600160a01b03199081169091556001600160a01b03878116808652609a8552838620805460001901905590871680865283862080546001019055868652609990945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6033546001600160a01b031633146106525760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610468565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610c475760405162461bcd60e51b8152600401610468906118a0565b610c4f61101d565b6106526040518060400160405280600a8152602001692a32b63632b92637b0b760b11b815250604051806040016040528060038152602001622a262760e91b81525061104c565b6001600160a01b038216610cec5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610468565b6000818152609960205260409020546001600160a01b031615610d515760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610468565b610d5f600083836001610fce565b6000818152609960205260409020546001600160a01b031615610dc45760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610468565b6001600160a01b0382166000818152609a6020908152604080832080546001019055848352609990915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b816001600160a01b0316836001600160a01b03161415610e915760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610468565b6001600160a01b038381166000818152609c6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610f09848484610a03565b610f158484848461107d565b6107c75760405162461bcd60e51b8152600401610468906118eb565b60606000610f3e8361118a565b600101905060008167ffffffffffffffff811115610f5e57610f5e611688565b6040519080825280601f01601f191660200182016040528015610f88576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610fc157610fc6565b610f92565b509392505050565b610fd88383611262565b6107c75760405162461bcd60e51b8152602060048201526016602482015275139bdd08185c1c1c9bdd995908189e481b585c9ad95d60521b6044820152606401610468565b600054610100900460ff166110445760405162461bcd60e51b8152600401610468906118a0565b61065261131b565b600054610100900460ff166110735760405162461bcd60e51b8152600401610468906118a0565b610786828261134b565b60006001600160a01b0384163b1561117f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906110c190339089908890889060040161193d565b602060405180830381600087803b1580156110db57600080fd5b505af192505050801561110b575060408051601f3d908101601f191682019092526111089181019061197a565b60015b611165573d808015611139576040519150601f19603f3d011682016040523d82523d6000602084013e61113e565b606091505b50805161115d5760405162461bcd60e51b8152600401610468906118eb565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506109fb565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106111c95772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106111f5576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061121357662386f26fc10000830492506010015b6305f5e100831061122b576305f5e100830492506008015b612710831061123f57612710830492506004015b60648310611251576064830492506002015b600a83106103345760010192915050565b60008061126e83611399565b604051633ef19a9b60e01b8152600481018290526001600160a01b0386811660248301529192507f000000000000000000000000000000000000000000000000000000000000000090911690633ef19a9b90604401604080518083038186803b1580156112da57600080fd5b505afa1580156112ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113129190611997565b50949350505050565b600054610100900460ff166113425760405162461bcd60e51b8152600401610468906118a0565b61065233610bce565b600054610100900460ff166113725760405162461bcd60e51b8152600401610468906118a0565b815161138590609790602085019061142a565b50805161050990609890602084019061142a565b60006113ad6033546001600160a01b031690565b6001600160a01b03166340910c70836040518263ffffffff1660e01b81526004016113da91815260200190565b60206040518083038186803b1580156113f257600080fd5b505afa158015611406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033491906119c5565b828054611436906117a4565b90600052602060002090601f016020900481019282611458576000855561149e565b82601f1061147157805160ff191683800117855561149e565b8280016001018555821561149e579182015b8281111561149e578251825591602001919060010190611483565b506114aa9291506114ae565b5090565b5b808211156114aa57600081556001016114af565b6001600160e01b03198116811461076257600080fd5b6000602082840312156114eb57600080fd5b813561083a816114c3565b60005b838110156115115781810151838201526020016114f9565b838111156107c75750506000910152565b6000815180845261153a8160208601602086016114f6565b601f01601f19169290920160200192915050565b60208152600061083a6020830184611522565b60006020828403121561157357600080fd5b5035919050565b80356001600160a01b038116811461159157600080fd5b919050565b600080604083850312156115a957600080fd5b6115b28361157a565b946020939093013593505050565b6000806000606084860312156115d557600080fd5b6115de8461157a565b92506115ec6020850161157a565b9150604084013590509250925092565b60006020828403121561160e57600080fd5b61083a8261157a565b6000806040838503121561162a57600080fd5b8235915061163a6020840161157a565b90509250929050565b801515811461076257600080fd5b6000806040838503121561166457600080fd5b61166d8361157a565b9150602083013561167d81611643565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080608085870312156116b457600080fd5b6116bd8561157a565b93506116cb6020860161157a565b925060408501359150606085013567ffffffffffffffff808211156116ef57600080fd5b818701915087601f83011261170357600080fd5b81358181111561171557611715611688565b604051601f8201601f19908116603f0116810190838211818310171561173d5761173d611688565b816040528281528a602084870101111561175657600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806040838503121561178d57600080fd5b6117968361157a565b915061163a6020840161157a565b600181811c908216806117b857607f821691505b602082108114156117d957634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b6000835161183e8184602088016114f6565b8351908301906118528183602088016114f6565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061197090830184611522565b9695505050505050565b60006020828403121561198c57600080fd5b815161083a816114c3565b600080604083850312156119aa57600080fd5b82516119b581611643565b6020939093015192949293505050565b6000602082840312156119d757600080fd5b505191905056fea26469706673582212208e0db6725c30428d4b5360745cbb02f505d2464a02a23fe3efbcf6b4194632e564736f6c63430008090033", "devdoc": { "kind": "dev", "methods": { @@ -542,7 +542,7 @@ "storageLayout": { "storage": [ { - "astId": 1625, + "astId": 326, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_initialized", "offset": 0, @@ -550,7 +550,7 @@ "type": "t_uint8" }, { - "astId": 1628, + "astId": 329, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_initializing", "offset": 1, @@ -558,7 +558,7 @@ "type": "t_bool" }, { - "astId": 3912, + "astId": 2613, "contract": "contracts/LenderManager.sol:LenderManager", "label": "__gap", "offset": 0, @@ -566,7 +566,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 1309, + "astId": 10, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_owner", "offset": 0, @@ -574,7 +574,7 @@ "type": "t_address" }, { - "astId": 1429, + "astId": 130, "contract": "contracts/LenderManager.sol:LenderManager", "label": "__gap", "offset": 0, @@ -582,7 +582,7 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 4642, + "astId": 3343, "contract": "contracts/LenderManager.sol:LenderManager", "label": "__gap", "offset": 0, @@ -590,7 +590,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 2485, + "astId": 1186, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_name", "offset": 0, @@ -598,7 +598,7 @@ "type": "t_string_storage" }, { - "astId": 2487, + "astId": 1188, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_symbol", "offset": 0, @@ -606,7 +606,7 @@ "type": "t_string_storage" }, { - "astId": 2491, + "astId": 1192, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_owners", "offset": 0, @@ -614,7 +614,7 @@ "type": "t_mapping(t_uint256,t_address)" }, { - "astId": 2495, + "astId": 1196, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_balances", "offset": 0, @@ -622,7 +622,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 2499, + "astId": 1200, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_tokenApprovals", "offset": 0, @@ -630,7 +630,7 @@ "type": "t_mapping(t_uint256,t_address)" }, { - "astId": 2505, + "astId": 1206, "contract": "contracts/LenderManager.sol:LenderManager", "label": "_operatorApprovals", "offset": 0, @@ -638,7 +638,7 @@ "type": "t_mapping(t_address,t_mapping(t_address,t_bool))" }, { - "astId": 3425, + "astId": 2126, "contract": "contracts/LenderManager.sol:LenderManager", "label": "__gap", "offset": 0, diff --git a/packages/contracts/deployments/goerli/LenderManager_Proxy.json b/packages/contracts/deployments/goerli/LenderManager_Proxy.json index e65fb21f3..d65376ef3 100644 --- a/packages/contracts/deployments/goerli/LenderManager_Proxy.json +++ b/packages/contracts/deployments/goerli/LenderManager_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "abi": [ { "inputs": [ @@ -146,77 +146,77 @@ "type": "receive" } ], - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x98Ca52786e967d1469090AdC075416948Ca004A7", - "transactionIndex": 2, - "gasUsed": "815356", - "logsBloom": "0x00000000000000000000000000008000400000000000000000800000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000002000101000000000000000000000000000000000000020000000000000000000800000000800000000000000000000000400000000000000000000000010000080000000000000080000000000000800000000000000000000000000000200400000000000000000000000000000000000000000820000100000000000000040000000000000400000000000000000020000000000000000000000000000000000000000000000000004000000000000000", - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f", - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", + "transactionIndex": 8, + "gasUsed": "815650", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000000000000000000000080000000000000000000000000000000000000000000000000000000000000200000002000000002000001000000000000000000000000100000000000020000000000000000000800000000800000000000000000000000400000100000000000000000000000000000000000000080000000000000800000000000000000000000000000000400008000000000000000000000000000000000000020000000000000000000040000004000000400000000000000000020000000200000000000000000000000000000000000000000000200000000000000", + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4", + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", "logs": [ { - "transactionIndex": 2, - "blockNumber": 8538444, - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "transactionIndex": 8, + "blockNumber": 8688913, + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x00000000000000000000000017d521925336b024da8014e15291853854bd7d5f" + "0x0000000000000000000000006f537a17a315910176598d0de17a44dabf25477a" ], "data": "0x", "logIndex": 0, - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f" + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4" }, { - "transactionIndex": 2, - "blockNumber": 8538444, - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "transactionIndex": 8, + "blockNumber": 8688913, + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", "logIndex": 1, - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f" + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4" }, { - "transactionIndex": 2, - "blockNumber": 8538444, - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "transactionIndex": 8, + "blockNumber": 8688913, + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 2, - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f" + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4" }, { - "transactionIndex": 2, - "blockNumber": 8538444, - "transactionHash": "0x9729dacca6e861ac8144340bea469cb975796bfc33416ed377348f6832cacdf5", - "address": "0x98Ca52786e967d1469090AdC075416948Ca004A7", + "transactionIndex": 8, + "blockNumber": 8688913, + "transactionHash": "0x77ed6493fada3474b15a235093efc50a97fce1524c9a8b85bc2281f307c94199", + "address": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 3, - "blockHash": "0x2ef7bde7d78eaa25d5ad184a989aeca2061f82bcd6d52c14a5558ee32feefe5f" + "blockHash": "0x9f52725fb42549da6c5944004ab60b1e5dd9618cbf0fa8187ee01ccf592842d4" } ], - "blockNumber": 8538444, - "cumulativeGasUsed": "857356", + "blockNumber": 8688913, + "cumulativeGasUsed": "983650", "status": 1, "byzantium": true }, "args": [ - "0x17d521925336b024DA8014e15291853854bd7D5F", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0x6f537A17A315910176598D0dE17a44DabF25477a", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x8129fc1c" ], "numDeployments": 1, diff --git a/packages/contracts/deployments/goerli/MarketLiquidityRewards.json b/packages/contracts/deployments/goerli/MarketLiquidityRewards.json index 5702131c1..fbe18f1b3 100644 --- a/packages/contracts/deployments/goerli/MarketLiquidityRewards.json +++ b/packages/contracts/deployments/goerli/MarketLiquidityRewards.json @@ -1,5 +1,5 @@ { - "address": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", + "address": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", "abi": [ { "anonymous": false, @@ -542,63 +542,63 @@ "type": "constructor" } ], - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", - "transactionIndex": 0, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", + "transactionIndex": 20, "gasUsed": "745965", - "logsBloom": "0x00000000000000080000000020000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000100000020000000000000000000040000000000000400000000000000000000000000100000000000001000000000000000000001000000000000000000000000", - "blockHash": "0xd4a305d0afa01a819bcbd899b2c30c2da544daf08f98fe080fce144e6320258b", - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", + "logsBloom": "0x00000000000000000000000000000000400000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000140000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000080040000000000000400000000000000000000000000000000000001000000000000000000000000000000000000000000100000", + "blockHash": "0x933b881484a8721cace56ab8c162e378842bbd1dabb3bc7c19e8d362c014432e", + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", "logs": [ { - "transactionIndex": 0, - "blockNumber": 8667201, - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", - "address": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", + "transactionIndex": 20, + "blockNumber": 8689044, + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", + "address": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000001a8f9c4d62a1e36381058ae376b19ea07d7f4c3b" + "0x00000000000000000000000090418c2438c66e8f0d9712ea0447c23c80fe0441" ], "data": "0x", "logIndex": 0, - "blockHash": "0xd4a305d0afa01a819bcbd899b2c30c2da544daf08f98fe080fce144e6320258b" + "blockHash": "0x933b881484a8721cace56ab8c162e378842bbd1dabb3bc7c19e8d362c014432e" }, { - "transactionIndex": 0, - "blockNumber": 8667201, - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", - "address": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", + "transactionIndex": 20, + "blockNumber": 8689044, + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", + "address": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 1, - "blockHash": "0xd4a305d0afa01a819bcbd899b2c30c2da544daf08f98fe080fce144e6320258b" + "blockHash": "0x933b881484a8721cace56ab8c162e378842bbd1dabb3bc7c19e8d362c014432e" }, { - "transactionIndex": 0, - "blockNumber": 8667201, - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", - "address": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", + "transactionIndex": 20, + "blockNumber": 8689044, + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", + "address": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 2, - "blockHash": "0xd4a305d0afa01a819bcbd899b2c30c2da544daf08f98fe080fce144e6320258b" + "blockHash": "0x933b881484a8721cace56ab8c162e378842bbd1dabb3bc7c19e8d362c014432e" } ], - "blockNumber": 8667201, - "cumulativeGasUsed": "745965", + "blockNumber": 8689044, + "cumulativeGasUsed": "1165965", "status": 1, "byzantium": true }, "args": [ - "0x1a8f9C4D62A1E36381058ae376b19ea07d7F4C3B", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0x90418C2438c66e8f0d9712Ea0447c23c80fe0441", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x8129fc1c" ], "numDeployments": 1, @@ -610,7 +610,7 @@ "methodName": "initialize", "args": [] }, - "implementation": "0x1a8f9C4D62A1E36381058ae376b19ea07d7F4C3B", + "implementation": "0x90418C2438c66e8f0d9712Ea0447c23c80fe0441", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/MarketLiquidityRewards_Implementation.json b/packages/contracts/deployments/goerli/MarketLiquidityRewards_Implementation.json index f9dd8c011..79456d30c 100644 --- a/packages/contracts/deployments/goerli/MarketLiquidityRewards_Implementation.json +++ b/packages/contracts/deployments/goerli/MarketLiquidityRewards_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0x1a8f9C4D62A1E36381058ae376b19ea07d7F4C3B", + "address": "0x90418C2438c66e8f0d9712Ea0447c23c80fe0441", "abi": [ { "inputs": [ @@ -419,29 +419,29 @@ "type": "function" } ], - "transactionHash": "0x783d3c8ce111e38d2dc95d5fc9f329acf71a1179f3063780f09924233b32b3f8", + "transactionHash": "0x49197d25a3cb65ad3998b4ec93ea6212c5285b0583333abfa8232bcd8c1dcafc", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x1a8f9C4D62A1E36381058ae376b19ea07d7F4C3B", - "transactionIndex": 0, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x90418C2438c66e8f0d9712Ea0447c23c80fe0441", + "transactionIndex": 11, "gasUsed": "1399715", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xd4c8af925c76fbf87e7e51d2288379550c646e0dc65ee3767cc599fb12012a2d", - "transactionHash": "0x783d3c8ce111e38d2dc95d5fc9f329acf71a1179f3063780f09924233b32b3f8", + "blockHash": "0xa6dc1dcca6073e4cdda27e69e69ebd4e6b0cf70af53181fa81b24fa7beeb7de0", + "transactionHash": "0x49197d25a3cb65ad3998b4ec93ea6212c5285b0583333abfa8232bcd8c1dcafc", "logs": [], - "blockNumber": 8667200, - "cumulativeGasUsed": "1399715", + "blockNumber": 8689043, + "cumulativeGasUsed": "2064649", "status": 1, "byzantium": true }, "args": [ - "0x195c6608705546725DF0629dd60690Cf2b367734", - "0x74FFC87282ab32c8E0969E26F93C820a213ae146", - "0xD66de8b25C4165dA2e7696e15E8436380823B118" + "0x3a8C417a743A60ECfF3988C34783D65362b62915", + "0x04F6908B97E4E985b849174f9904FaF0a0E50413", + "0x62824Ff0BDbc42874e23f3cA9966866659F39b09" ], "numDeployments": 1, - "solcInputHash": "704ec39527d925eea3260ddc4e8d1e8a", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tellerV2\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_marketRegistry\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_collateralManager\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"allocationId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ClaimedRewards\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"allocationId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"allocator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"CreatedAllocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"allocationId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DecreasedAllocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"allocationId\",\"type\":\"uint256\"}],\"name\":\"DeletedAllocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"allocationId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"IncreasedAllocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"allocationId\",\"type\":\"uint256\"}],\"name\":\"UpdatedAllocation\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"allocator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"rewardTokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"requiredPrincipalTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"requiredCollateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minimumCollateralPerPrincipalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardPerLoanPrincipalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bidStartTimeMin\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"bidStartTimeMax\",\"type\":\"uint32\"},{\"internalType\":\"enum IMarketLiquidityRewards.AllocationStrategy\",\"name\":\"allocationStrategy\",\"type\":\"uint8\"}],\"internalType\":\"struct IMarketLiquidityRewards.RewardAllocation\",\"name\":\"_allocation\",\"type\":\"tuple\"}],\"name\":\"allocateRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"allocationId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"allocatedRewards\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"allocator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"rewardTokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"requiredPrincipalTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"requiredCollateralTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minimumCollateralPerPrincipalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rewardPerLoanPrincipalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bidStartTimeMin\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"bidStartTimeMax\",\"type\":\"uint32\"},{\"internalType\":\"enum IMarketLiquidityRewards.AllocationStrategy\",\"name\":\"allocationStrategy\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_allocationId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"claimRewards\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_allocationId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenAmount\",\"type\":\"uint256\"}],\"name\":\"deallocateRewards\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_allocationId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenAmount\",\"type\":\"uint256\"}],\"name\":\"increaseAllocationAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"rewardClaimedForBid\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_allocationId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_minimumCollateralPerPrincipalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_rewardPerLoanPrincipalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_bidStartTimeMin\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_bidStartTimeMax\",\"type\":\"uint32\"}],\"name\":\"updateAllocation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"allocateRewards((address,address,uint256,uint256,address,address,uint256,uint256,uint32,uint32,uint8))\":{\"params\":{\"_allocation\":\"- The RewardAllocation struct data to create\"},\"returns\":{\"allocationId_\":\"allocationId_\"}},\"claimRewards(uint256,uint256)\":{\"params\":{\"_allocationId\":\"- The id for the reward allocation\",\"_bidId\":\"- The id for the loan. Each loan only grants one reward per allocation.\"}},\"deallocateRewards(uint256,uint256)\":{\"params\":{\"_allocationId\":\"- The id for the allocation\",\"_tokenAmount\":\"- The amount of tokens to withdraw\"}},\"increaseAllocationAmount(uint256,uint256)\":{\"params\":{\"_allocationId\":\"- The id for the allocation\",\"_tokenAmount\":\"- The amount of tokens to add\"}},\"updateAllocation(uint256,uint256,uint256,uint32,uint32)\":{\"params\":{\"_allocationId\":\"- The id for the allocation\",\"_bidStartTimeMax\":\"- The block timestamp that loans must have been accepted before to claim rewards\",\"_bidStartTimeMin\":\"- The block timestamp that loans must have been accepted after to claim rewards\",\"_minimumCollateralPerPrincipalAmount\":\"- The required collateralization ratio\",\"_rewardPerLoanPrincipalAmount\":\"- The reward to give per principal amount\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"allocateRewards((address,address,uint256,uint256,address,address,uint256,uint256,uint32,uint32,uint8))\":{\"notice\":\"Creates a new token allocation and transfers the token amount into escrow in this contract\"},\"claimRewards(uint256,uint256)\":{\"notice\":\"Allows a borrower or lender to withdraw the allocated ERC20 reward for their loan\"},\"deallocateRewards(uint256,uint256)\":{\"notice\":\"Allows the allocator to withdraw some or all of the funds within an allocation\"},\"increaseAllocationAmount(uint256,uint256)\":{\"notice\":\"Allows anyone to add tokens to an allocation\"},\"updateAllocation(uint256,uint256,uint256,uint32,uint32)\":{\"notice\":\"Allows the allocator to update properties of an allocation\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/MarketLiquidityRewards.sol\":\"MarketLiquidityRewards\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x605434219ebbe4653f703640f06969faa5a1d78f0bfef878e5ddbb1ca369ceeb\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/MarketLiquidityRewards.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\n\\nimport \\\"./interfaces/IMarketLiquidityRewards.sol\\\";\\n\\nimport \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\n\\nimport { BidState } from \\\"./TellerV2Storage.sol\\\";\\n\\n// Libraries\\nimport { MathUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\\\";\\n\\n/*\\n- Claim reward for a loan based on loanId (use a brand new contract)\\n- This contract holds the reward tokens in escrow.\\n- There will be an allocateReward() function, only called by marketOwner, deposits tokens in escrow\\n- There will be a claimReward() function -> reads state of loans , only called by borrower -> withdraws tokens from escrow and makes those loans as having claimed rewards\\n- unallocateReward()\\n\\nThis contract could give out 1 OHM when someone takes out a loan (for every 1000 USDC)\\n\\n\\n ryan ideas : \\n\\n\\n1. the claimer could be the lender or borrower \\nie we might be incentivizing one or the other, or both (or some other address? idk a use case yet tho)\\nprincipalTokenAddress\\n2.ie the loan had to be made in USDC or x token\\ncollateralTokenAddress\\nie Olympus wants to incentivize holders to lock up gOHM as collateral\\nmaxPrincipalPerCollateral\\n3. ie we might incentivize a collateral ratio greater than or less than some number. or this might be blank (would not use an oracle but raw units ? )\\n\\n4. make sure loans are REPAID before any reward \\n\\n*/\\n\\ncontract MarketLiquidityRewards is IMarketLiquidityRewards, Initializable {\\n address immutable tellerV2;\\n address immutable marketRegistry;\\n address immutable collateralManager;\\n\\n uint256 allocationCount;\\n\\n //allocationId => rewardAllocation\\n mapping(uint256 => RewardAllocation) public allocatedRewards;\\n\\n //bidId => allocationId => rewardWasClaimed\\n mapping(uint256 => mapping(uint256 => bool)) public rewardClaimedForBid;\\n\\n modifier onlyMarketOwner(uint256 _marketId) {\\n require(\\n msg.sender ==\\n IMarketRegistry(marketRegistry).getMarketOwner(_marketId),\\n \\\"Only market owner can call this function.\\\"\\n );\\n _;\\n }\\n\\n event CreatedAllocation(\\n uint256 allocationId,\\n address allocator,\\n uint256 marketId\\n );\\n\\n event UpdatedAllocation(uint256 allocationId);\\n\\n event IncreasedAllocation(uint256 allocationId, uint256 amount);\\n\\n event DecreasedAllocation(uint256 allocationId, uint256 amount);\\n\\n event DeletedAllocation(uint256 allocationId);\\n\\n event ClaimedRewards(\\n uint256 allocationId,\\n uint256 bidId,\\n address recipient,\\n uint256 amount\\n );\\n\\n constructor(\\n address _tellerV2,\\n address _marketRegistry,\\n address _collateralManager\\n ) {\\n tellerV2 = _tellerV2;\\n marketRegistry = _marketRegistry;\\n collateralManager = _collateralManager;\\n }\\n\\n function initialize() external initializer {}\\n\\n /**\\n * @notice Creates a new token allocation and transfers the token amount into escrow in this contract\\n * @param _allocation - The RewardAllocation struct data to create\\n * @return allocationId_\\n */\\n function allocateRewards(RewardAllocation calldata _allocation)\\n public\\n virtual\\n returns (uint256 allocationId_)\\n {\\n allocationId_ = allocationCount++;\\n\\n require(\\n _allocation.allocator == msg.sender,\\n \\\"Invalid allocator address\\\"\\n );\\n\\n IERC20Upgradeable(_allocation.rewardTokenAddress).transferFrom(\\n msg.sender,\\n address(this),\\n _allocation.rewardTokenAmount\\n );\\n\\n allocatedRewards[allocationId_] = _allocation;\\n\\n emit CreatedAllocation(\\n allocationId_,\\n _allocation.allocator,\\n _allocation.marketId\\n );\\n }\\n\\n /**\\n * @notice Allows the allocator to update properties of an allocation\\n * @param _allocationId - The id for the allocation\\n * @param _minimumCollateralPerPrincipalAmount - The required collateralization ratio\\n * @param _rewardPerLoanPrincipalAmount - The reward to give per principal amount\\n * @param _bidStartTimeMin - The block timestamp that loans must have been accepted after to claim rewards\\n * @param _bidStartTimeMax - The block timestamp that loans must have been accepted before to claim rewards\\n */\\n function updateAllocation(\\n uint256 _allocationId,\\n uint256 _minimumCollateralPerPrincipalAmount,\\n uint256 _rewardPerLoanPrincipalAmount,\\n uint32 _bidStartTimeMin,\\n uint32 _bidStartTimeMax\\n ) public virtual {\\n RewardAllocation storage allocation = allocatedRewards[_allocationId];\\n\\n require(\\n msg.sender == allocation.allocator,\\n \\\"Only the allocator can update allocation rewards.\\\"\\n );\\n\\n allocation\\n .minimumCollateralPerPrincipalAmount = _minimumCollateralPerPrincipalAmount;\\n allocation.rewardPerLoanPrincipalAmount = _rewardPerLoanPrincipalAmount;\\n allocation.bidStartTimeMin = _bidStartTimeMin;\\n allocation.bidStartTimeMax = _bidStartTimeMax;\\n\\n emit UpdatedAllocation(_allocationId);\\n }\\n\\n /**\\n * @notice Allows anyone to add tokens to an allocation\\n * @param _allocationId - The id for the allocation\\n * @param _tokenAmount - The amount of tokens to add\\n */\\n function increaseAllocationAmount(\\n uint256 _allocationId,\\n uint256 _tokenAmount\\n ) public virtual {\\n IERC20Upgradeable(allocatedRewards[_allocationId].rewardTokenAddress)\\n .transferFrom(msg.sender, address(this), _tokenAmount);\\n allocatedRewards[_allocationId].rewardTokenAmount += _tokenAmount;\\n\\n emit IncreasedAllocation(_allocationId, _tokenAmount);\\n }\\n\\n /**\\n * @notice Allows the allocator to withdraw some or all of the funds within an allocation\\n * @param _allocationId - The id for the allocation\\n * @param _tokenAmount - The amount of tokens to withdraw\\n */\\n function deallocateRewards(uint256 _allocationId, uint256 _tokenAmount)\\n public\\n virtual\\n {\\n require(\\n msg.sender == allocatedRewards[_allocationId].allocator,\\n \\\"Only the allocator can deallocate rewards.\\\"\\n );\\n\\n if (_tokenAmount > allocatedRewards[_allocationId].rewardTokenAmount) {\\n _tokenAmount = allocatedRewards[_allocationId].rewardTokenAmount;\\n }\\n\\n //subtract amount reward before transfer\\n _decrementAllocatedAmount(_allocationId, _tokenAmount);\\n\\n IERC20Upgradeable(allocatedRewards[_allocationId].rewardTokenAddress)\\n .transfer(msg.sender, _tokenAmount);\\n\\n if (allocatedRewards[_allocationId].rewardTokenAmount == 0) {\\n delete allocatedRewards[_allocationId];\\n\\n emit DeletedAllocation(_allocationId);\\n } else {\\n emit DecreasedAllocation(_allocationId, _tokenAmount);\\n }\\n }\\n\\n /**\\n * @notice Allows a borrower or lender to withdraw the allocated ERC20 reward for their loan\\n * @param _allocationId - The id for the reward allocation\\n * @param _bidId - The id for the loan. Each loan only grants one reward per allocation.\\n */\\n function claimRewards(uint256 _allocationId, uint256 _bidId)\\n external\\n virtual\\n {\\n RewardAllocation storage allocatedReward = allocatedRewards[\\n _allocationId\\n ];\\n\\n require(\\n !rewardClaimedForBid[_bidId][_allocationId],\\n \\\"reward already claimed\\\"\\n );\\n rewardClaimedForBid[_bidId][_allocationId] = true; // leave this here to defend against re-entrancy\\n\\n (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n ) = ITellerV2(tellerV2).getLoanSummary(_bidId);\\n\\n address collateralTokenAddress = allocatedReward\\n .requiredCollateralTokenAddress;\\n\\n //require that the loan was started in the correct timeframe\\n _verifyLoanStartTime(\\n acceptedTimestamp,\\n allocatedReward.bidStartTimeMin,\\n allocatedReward.bidStartTimeMax\\n );\\n\\n if (collateralTokenAddress != address(0)) {\\n uint256 collateralAmount = ICollateralManager(collateralManager)\\n .getCollateralAmount(_bidId, collateralTokenAddress);\\n\\n //require collateral amount\\n _verifyCollateralAmount(\\n collateralTokenAddress,\\n collateralAmount,\\n principalTokenAddress,\\n principalAmount,\\n allocatedReward.minimumCollateralPerPrincipalAmount\\n );\\n }\\n\\n _verifyExpectedTokenAddress(\\n principalTokenAddress,\\n allocatedReward.requiredPrincipalTokenAddress\\n );\\n\\n _verifyExpectedTokenAddress(\\n collateralTokenAddress,\\n allocatedReward.requiredCollateralTokenAddress\\n );\\n\\n require(\\n marketId == allocatedRewards[_allocationId].marketId,\\n \\\"MarketId mismatch for allocation\\\"\\n );\\n\\n uint256 principalTokenDecimals = IERC20MetadataUpgradeable(\\n principalTokenAddress\\n ).decimals();\\n\\n address rewardRecipient = _verifyAndReturnRewardRecipient(\\n allocatedReward.allocationStrategy,\\n bidState,\\n borrower,\\n lender\\n );\\n\\n uint256 amountToReward = _calculateRewardAmount(\\n principalAmount,\\n principalTokenDecimals,\\n allocatedReward.rewardPerLoanPrincipalAmount\\n );\\n\\n _decrementAllocatedAmount(_allocationId, amountToReward);\\n\\n //transfer tokens reward to the msgsender\\n IERC20Upgradeable(allocatedRewards[_allocationId].rewardTokenAddress)\\n .transfer(rewardRecipient, amountToReward);\\n\\n emit ClaimedRewards(\\n _allocationId,\\n _bidId,\\n rewardRecipient,\\n amountToReward\\n );\\n }\\n\\n /**\\n * @notice Verifies that the bid state is appropriate for claiming rewards based on the allocation strategy and then returns the address of the reward recipient(borrower or lender)\\n * @param _strategy - The strategy for the reward allocation.\\n * @param _bidState - The bid state of the loan.\\n * @param _borrower - The borrower of the loan.\\n * @param _lender - The lender of the loan.\\n * @return rewardRecipient_ The address that will receive the rewards. Either the borrower or lender.\\n */\\n function _verifyAndReturnRewardRecipient(\\n AllocationStrategy _strategy,\\n BidState _bidState,\\n address _borrower,\\n address _lender\\n ) internal virtual returns (address rewardRecipient_) {\\n if (_strategy == AllocationStrategy.BORROWER) {\\n require(_bidState == BidState.PAID, \\\"Invalid bid state for loan.\\\");\\n\\n rewardRecipient_ = _borrower;\\n } else if (_strategy == AllocationStrategy.LENDER) {\\n //Loan must have been accepted in the past\\n require(\\n _bidState >= BidState.ACCEPTED,\\n \\\"Invalid bid state for loan.\\\"\\n );\\n\\n rewardRecipient_ = _lender;\\n } else {\\n revert(\\\"Unknown allocation strategy\\\");\\n }\\n }\\n\\n /**\\n * @notice Decrements the amount allocated to keep track of tokens in escrow\\n * @param _allocationId - The id for the allocation to decrement\\n * @param _amount - The amount of ERC20 to decrement\\n */\\n function _decrementAllocatedAmount(uint256 _allocationId, uint256 _amount)\\n internal\\n {\\n allocatedRewards[_allocationId].rewardTokenAmount -= _amount;\\n }\\n\\n /**\\n * @notice Calculates the reward to claim for the allocation\\n * @param _loanPrincipal - The amount of principal for the loan for which to reward\\n * @param _principalTokenDecimals - The number of decimals of the principal token\\n * @param _rewardPerLoanPrincipalAmount - The amount of reward per loan principal amount, expanded by the principal token decimals\\n * @return The amount of ERC20 to reward\\n */\\n function _calculateRewardAmount(\\n uint256 _loanPrincipal,\\n uint256 _principalTokenDecimals,\\n uint256 _rewardPerLoanPrincipalAmount\\n ) internal view returns (uint256) {\\n return\\n MathUpgradeable.mulDiv(\\n _loanPrincipal,\\n _rewardPerLoanPrincipalAmount, //expanded by principal token decimals\\n 10**_principalTokenDecimals\\n );\\n }\\n\\n /**\\n * @notice Verifies that the collateral ratio for the loan was sufficient based on _minimumCollateralPerPrincipalAmount of the allocation\\n * @param _collateralTokenAddress - The contract address for the collateral token\\n * @param _collateralAmount - The number of decimals of the collateral token\\n * @param _principalTokenAddress - The contract address for the principal token\\n * @param _principalAmount - The number of decimals of the principal token\\n * @param _minimumCollateralPerPrincipalAmount - The amount of collateral required per principal amount. Expanded by the principal token decimals and collateral token decimals.\\n */\\n function _verifyCollateralAmount(\\n address _collateralTokenAddress,\\n uint256 _collateralAmount,\\n address _principalTokenAddress,\\n uint256 _principalAmount,\\n uint256 _minimumCollateralPerPrincipalAmount\\n ) internal virtual {\\n uint256 principalTokenDecimals = IERC20MetadataUpgradeable(\\n _principalTokenAddress\\n ).decimals();\\n\\n uint256 collateralTokenDecimals = IERC20MetadataUpgradeable(\\n _collateralTokenAddress\\n ).decimals();\\n\\n uint256 minCollateral = _requiredCollateralAmount(\\n _principalAmount,\\n principalTokenDecimals,\\n collateralTokenDecimals,\\n _minimumCollateralPerPrincipalAmount\\n );\\n\\n require(\\n _collateralAmount >= minCollateral,\\n \\\"Loan does not meet minimum collateralization ratio.\\\"\\n );\\n }\\n\\n /**\\n * @notice Calculates the minimum amount of collateral the loan requires based on principal amount\\n * @param _principalAmount - The number of decimals of the principal token\\n * @param _principalTokenDecimals - The number of decimals of the principal token\\n * @param _collateralTokenDecimals - The number of decimals of the collateral token\\n * @param _minimumCollateralPerPrincipalAmount - The amount of collateral required per principal amount. Expanded by the principal token decimals and collateral token decimals.\\n */\\n function _requiredCollateralAmount(\\n uint256 _principalAmount,\\n uint256 _principalTokenDecimals,\\n uint256 _collateralTokenDecimals,\\n uint256 _minimumCollateralPerPrincipalAmount\\n ) internal view virtual returns (uint256) {\\n return\\n MathUpgradeable.mulDiv(\\n _principalAmount,\\n _minimumCollateralPerPrincipalAmount, //expanded by principal token decimals and collateral token decimals\\n 10**(_principalTokenDecimals + _collateralTokenDecimals)\\n );\\n }\\n\\n /**\\n * @notice Verifies that the loan start time is within the bounds set by the allocation requirements\\n * @param _loanStartTime - The timestamp when the loan was accepted\\n * @param _minStartTime - The minimum time required, after which the loan must have been accepted\\n * @param _maxStartTime - The maximum time required, before which the loan must have been accepted\\n */\\n function _verifyLoanStartTime(\\n uint32 _loanStartTime,\\n uint32 _minStartTime,\\n uint32 _maxStartTime\\n ) internal virtual {\\n require(\\n _minStartTime == 0 || _loanStartTime > _minStartTime,\\n \\\"Loan was accepted before the min start time.\\\"\\n );\\n require(\\n _maxStartTime == 0 || _loanStartTime < _maxStartTime,\\n \\\"Loan was accepted after the max start time.\\\"\\n );\\n }\\n\\n /**\\n * @notice Verifies that the loan principal token address is per the requirements of the allocation\\n * @param _loanTokenAddress - The contract address of the token\\n * @param _expectedTokenAddress - The expected contract address per the allocation\\n */\\n function _verifyExpectedTokenAddress(\\n address _loanTokenAddress,\\n address _expectedTokenAddress\\n ) internal virtual {\\n require(\\n _expectedTokenAddress == address(0) ||\\n _loanTokenAddress == _expectedTokenAddress,\\n \\\"Invalid expected token address.\\\"\\n );\\n }\\n}\\n\",\"keccak256\":\"0xf5a0dd242fffa5facd0f7eebaf64ccf7f23f5acebd5f67308189eccc38d705e2\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\\n external\\n view\\n returns (uint256 _amount);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x27778a3446cdbfed6356d5047f9926231261b37def2712a3cc63e3779350e5e4\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketLiquidityRewards.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface IMarketLiquidityRewards {\\n struct RewardAllocation {\\n address allocator;\\n address rewardTokenAddress;\\n uint256 rewardTokenAmount;\\n uint256 marketId;\\n //requirements for loan\\n address requiredPrincipalTokenAddress; //0 for any\\n address requiredCollateralTokenAddress; //0 for any -- could be an enumerable set?\\n uint256 minimumCollateralPerPrincipalAmount;\\n uint256 rewardPerLoanPrincipalAmount;\\n uint32 bidStartTimeMin;\\n uint32 bidStartTimeMax;\\n AllocationStrategy allocationStrategy;\\n }\\n\\n enum AllocationStrategy {\\n BORROWER,\\n LENDER\\n }\\n\\n function allocateRewards(RewardAllocation calldata _allocation)\\n external\\n returns (uint256 allocationId_);\\n\\n function increaseAllocationAmount(\\n uint256 _allocationId,\\n uint256 _tokenAmount\\n ) external;\\n\\n function deallocateRewards(uint256 _allocationId, uint256 _amount) external;\\n\\n function claimRewards(uint256 _allocationId, uint256 _bidId) external;\\n\\n function rewardClaimedForBid(uint256 _bidId, uint256 _allocationId)\\n external\\n view\\n returns (bool);\\n\\n function initialize() external;\\n}\\n\",\"keccak256\":\"0x9eba1d670efd661e7c74f4e6e834af1e1a3a10070b773a54ffef85ddaba82b74\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanLiquidateable(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n\\n function getLoanSummary(uint256 _bidId)\\n external\\n view\\n returns (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n );\\n}\\n\",\"keccak256\":\"0x2750d9717451e34323ef523810ff2a3a6285f146009955220d3860a7c4326077\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x60e06040523480156200001157600080fd5b50604051620019313803806200193183398101604081905262000034916200006f565b6001600160a01b0392831660805290821660a0521660c052620000b9565b80516001600160a01b03811681146200006a57600080fd5b919050565b6000806000606084860312156200008557600080fd5b620000908462000052565b9250620000a06020850162000052565b9150620000b06040850162000052565b90509250925092565b60805160a05160c05161184b620000e660003960006104b401526000505060006103a5015261184b6000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80636f05bbdc1161005b5780636f05bbdc146101195780638129fc1c146101b8578063abcc45e0146101c0578063b291ac4c146101d357600080fd5b80633997ec2c1461008d5780634cfb5beb146100a2578063594dd432146100e55780635cb22c5a146100f8575b600080fd5b6100a061009b3660046112b1565b6101e6565b005b6100d06100b03660046112b1565b600360209081526000928352604080842090915290825290205460ff1681565b60405190151581526020015b60405180910390f35b6100a06100f33660046112b1565b6102e5565b61010b6101063660046112d3565b610782565b6040519081526020016100dc565b6101a16101273660046112ec565b60026020819052600091825260409091208054600182015492820154600383015460048401546005850154600686015460078701546008909701546001600160a01b0396871698871697959694959385169490921692909163ffffffff80821691640100000000810490911690600160401b900460ff168b565b6040516100dc9b9a9998979695949392919061131b565b6100a0610915565b6100a06101ce3660046113bd565b610a1e565b6100a06101e13660046112b1565b610b18565b600082815260026020526040908190206001015490516323b872dd60e01b8152336004820152306024820152604481018390526001600160a01b03909116906323b872dd90606401602060405180830381600087803b15801561024857600080fd5b505af115801561025c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102809190611413565b50600082815260026020819052604082200180548392906102a290849061144b565b909155505060408051838152602081018390527f6066faf685f9876a4e900441602eb0063cdc31b9241c2384019c1b72bf58f1e191015b60405180910390a15050565b6000828152600260209081526040808320848452600383528184208685529092529091205460ff16156103585760405162461bcd60e51b81526020600482015260166024820152751c995dd85c9908185b1c9958591e4818db185a5b595960521b60448201526064015b60405180910390fd5b6000828152600360209081526040808320868452909152808220805460ff191660011790555163e0d3d58d60e01b8152600481018490528190819081908190819081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e0d3d58d9060240160e06040518083038186803b1580156103e757600080fd5b505afa1580156103fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041f9190611478565b965096509650965096509650965060008860050160009054906101000a90046001600160a01b0316905061047c838a60080160009054906101000a900463ffffffff168b60080160049054906101000a900463ffffffff16610d50565b6001600160a01b038116156105455760405163cd98536b60e01b8152600481018b90526001600160a01b0382811660248301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063cd98536b9060440160206040518083038186803b1580156104f857600080fd5b505afa15801561050c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105309190611504565b9050610543828288888e60060154610e52565b505b600489015461055e9086906001600160a01b0316610fc8565b60058901546105779082906001600160a01b0316610fc8565b60008b81526002602052604090206003015486146105d75760405162461bcd60e51b815260206004820181905260248201527f4d61726b65744964206d69736d6174636820666f7220616c6c6f636174696f6e604482015260640161034f565b6000856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561061257600080fd5b505afa158015610626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064a919061151d565b60088b015460ff918216925060009161066d91600160401b900416858c8c61103b565b9050600061068087848e60070154611191565b905061068c8e826111b2565b60008e8152600260205260409081902060010154905163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b1580156106ea57600080fd5b505af11580156106fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107229190611413565b50604080518f8152602081018f90526001600160a01b038416818301526060810183905290517f9bcf4b7082743be9e48c040fa49881bdac9ba7ed4f12e71d8ff6c946da65c0649181900360800190a15050505050505050505050505050565b600180546000918261079383611540565b909155509050336107a7602084018461155b565b6001600160a01b0316146107fd5760405162461bcd60e51b815260206004820152601960248201527f496e76616c696420616c6c6f6361746f72206164647265737300000000000000604482015260640161034f565b61080d604083016020840161155b565b604080516323b872dd60e01b81523360048201523060248201529084013560448201526001600160a01b0391909116906323b872dd90606401602060405180830381600087803b15801561086057600080fd5b505af1158015610874573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108989190611413565b50600081815260026020526040902082906108b38282611603565b507f678866ebbf19eed1d9f95e0bfd63584f721eab8935f83844394f78873789a80d9050816108e5602085018561155b565b604080519283526001600160a01b03919091166020830152606085810135838301529051918290030190a1919050565b600054610100900460ff16158080156109355750600054600160ff909116105b8061094f5750303b15801561094f575060005460ff166001145b6109b25760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161034f565b6000805460ff1916600117905580156109d5576000805461ff0019166101001790555b8015610a1b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b600085815260026020526040902080546001600160a01b03163314610a9f5760405162461bcd60e51b815260206004820152603160248201527f4f6e6c792074686520616c6c6f6361746f722063616e2075706461746520616c6044820152703637b1b0ba34b7b7103932bbb0b932399760791b606482015260840161034f565b600681018590556007810184905560088101805463ffffffff8481166401000000000267ffffffffffffffff19909216908616171790556040517ffcd537d3fc9c6f64078c9c86412d6a64c37948df1bd043ecc7f9f581d7e8e24490610b089088815260200190565b60405180910390a1505050505050565b6000828152600260205260409020546001600160a01b03163314610b915760405162461bcd60e51b815260206004820152602a60248201527f4f6e6c792074686520616c6c6f6361746f722063616e206465616c6c6f63617460448201526932903932bbb0b932399760b11b606482015260840161034f565b60008281526002602081905260409091200154811115610bc05750600081815260026020819052604090912001545b610bca82826111b2565b6000828152600260205260409081902060010154905163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b158015610c2657600080fd5b505af1158015610c3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5e9190611413565b5060008281526002602081905260409091200154610d1657600082815260026020819052604080832080546001600160a01b03199081168255600182018054821690559281018490556003810184905560048101805484169055600581018054909316909255600682018390556007820192909255600801805468ffffffffffffffffff19169055517f698179301d5c74d995c4597afa699d93a464ea03a6a2a9bfc11f0d0fd4c9cfd9906102d99084815260200190565b60408051838152602081018390527fdb6f83be148266f54cb6b67859eedb520ac995d0d6b670dcee19a3d5c6f1e47e91016102d9565b5050565b63ffffffff82161580610d6e57508163ffffffff168363ffffffff16115b610dcf5760405162461bcd60e51b815260206004820152602c60248201527f4c6f616e20776173206163636570746564206265666f726520746865206d696e60448201526b1039ba30b93a103a34b6b29760a11b606482015260840161034f565b63ffffffff81161580610ded57508063ffffffff168363ffffffff16105b610e4d5760405162461bcd60e51b815260206004820152602b60248201527f4c6f616e2077617320616363657074656420616674657220746865206d61782060448201526a39ba30b93a103a34b6b29760a91b606482015260840161034f565b505050565b6000836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610e8d57600080fd5b505afa158015610ea1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec5919061151d565b60ff1690506000866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0557600080fd5b505afa158015610f19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3d919061151d565b60ff1690506000610f50858484876111dc565b905080871015610fbe5760405162461bcd60e51b815260206004820152603360248201527f4c6f616e20646f6573206e6f74206d656574206d696e696d756d20636f6c6c616044820152723a32b930b634bd30ba34b7b7103930ba34b79760691b606482015260840161034f565b5050505050505050565b6001600160a01b0381161580610fef5750806001600160a01b0316826001600160a01b0316145b610d4c5760405162461bcd60e51b815260206004820152601f60248201527f496e76616c696420657870656374656420746f6b656e20616464726573732e00604482015260640161034f565b60008085600181111561105057611050611305565b14156110be57600484600581111561106a5761106a611305565b146110b75760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642062696420737461746520666f72206c6f616e2e0000000000604482015260640161034f565b5081611189565b60018560018111156110d2576110d2611305565b14156111415760038460058111156110ec576110ec611305565b101561113a5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642062696420737461746520666f72206c6f616e2e0000000000604482015260640161034f565b5080611189565b60405162461bcd60e51b815260206004820152601b60248201527f556e6b6e6f776e20616c6c6f636174696f6e2073747261746567790000000000604482015260640161034f565b949350505050565b60006111a884836111a386600a6117dc565b611201565b90505b9392505050565b600082815260026020819052604082200180548392906111d39084906117e8565b90915550505050565b60006111f885836111ed868861144b565b6111a390600a6117dc565b95945050505050565b60008080600019858709858702925082811083820303915050806000141561123c57838281611232576112326117ff565b04925050506111ab565b80841161124857600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b600080604083850312156112c457600080fd5b50508035926020909101359150565b600061016082840312156112e657600080fd5b50919050565b6000602082840312156112fe57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b038c811682528b81166020830152604082018b9052606082018a90528881166080830152871660a082015260c0810186905260e0810185905263ffffffff848116610100830152831661012082015261016081016002831061139457634e487b7160e01b600052602160045260246000fd5b826101408301529c9b505050505050505050505050565b63ffffffff81168114610a1b57600080fd5b600080600080600060a086880312156113d557600080fd5b85359450602086013593506040860135925060608601356113f5816113ab565b91506080860135611405816113ab565b809150509295509295909350565b60006020828403121561142557600080fd5b815180151581146111ab57600080fd5b634e487b7160e01b600052601160045260246000fd5b6000821982111561145e5761145e611435565b500190565b6001600160a01b0381168114610a1b57600080fd5b600080600080600080600060e0888a03121561149357600080fd5b875161149e81611463565b60208901519097506114af81611463565b604089015160608a015191975095506114c781611463565b608089015160a08a015191955093506114df816113ab565b60c0890151909250600681106114f457600080fd5b8091505092959891949750929550565b60006020828403121561151657600080fd5b5051919050565b60006020828403121561152f57600080fd5b815160ff811681146111ab57600080fd5b600060001982141561155457611554611435565b5060010190565b60006020828403121561156d57600080fd5b81356111ab81611463565b6000813561158581611463565b92915050565b80546001600160a01b0319166001600160a01b0392909216919091179055565b60008135611585816113ab565b600081356002811061158557600080fd5b600282106115e757634e487b7160e01b600052602160045260246000fd5b805460ff60401b8360401b1660ff60401b198216178255505050565b61161561160f83611578565b8261158b565b61162d61162460208401611578565b6001830161158b565b604082013560028201556060820135600382015561165961165060808401611578565b6004830161158b565b61167161166860a08401611578565b6005830161158b565b60c0820135600682015560e08201356007820155600881016116b061169961010085016115ab565b825463ffffffff191663ffffffff91909116178255565b6116e26116c061012085016115ab565b825467ffffffff00000000191660209190911b67ffffffff0000000016178255565b610e4d6116f261014085016115b8565b826115c9565b600181815b8085111561173357816000190482111561171957611719611435565b8085161561172657918102915b93841c93908002906116fd565b509250929050565b60008261174a57506001611585565b8161175757506000611585565b816001811461176d576002811461177757611793565b6001915050611585565b60ff84111561178857611788611435565b50506001821b611585565b5060208310610133831016604e8410600b84101617156117b6575081810a611585565b6117c083836116f8565b80600019048211156117d4576117d4611435565b029392505050565b60006111ab838361173b565b6000828210156117fa576117fa611435565b500390565b634e487b7160e01b600052601260045260246000fdfea2646970667358221220e9ee9ce41db1cc79b75bc905ef429848369d3338d2dc4b86c00a6602f8690fb164736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c80636f05bbdc1161005b5780636f05bbdc146101195780638129fc1c146101b8578063abcc45e0146101c0578063b291ac4c146101d357600080fd5b80633997ec2c1461008d5780634cfb5beb146100a2578063594dd432146100e55780635cb22c5a146100f8575b600080fd5b6100a061009b3660046112b1565b6101e6565b005b6100d06100b03660046112b1565b600360209081526000928352604080842090915290825290205460ff1681565b60405190151581526020015b60405180910390f35b6100a06100f33660046112b1565b6102e5565b61010b6101063660046112d3565b610782565b6040519081526020016100dc565b6101a16101273660046112ec565b60026020819052600091825260409091208054600182015492820154600383015460048401546005850154600686015460078701546008909701546001600160a01b0396871698871697959694959385169490921692909163ffffffff80821691640100000000810490911690600160401b900460ff168b565b6040516100dc9b9a9998979695949392919061131b565b6100a0610915565b6100a06101ce3660046113bd565b610a1e565b6100a06101e13660046112b1565b610b18565b600082815260026020526040908190206001015490516323b872dd60e01b8152336004820152306024820152604481018390526001600160a01b03909116906323b872dd90606401602060405180830381600087803b15801561024857600080fd5b505af115801561025c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102809190611413565b50600082815260026020819052604082200180548392906102a290849061144b565b909155505060408051838152602081018390527f6066faf685f9876a4e900441602eb0063cdc31b9241c2384019c1b72bf58f1e191015b60405180910390a15050565b6000828152600260209081526040808320848452600383528184208685529092529091205460ff16156103585760405162461bcd60e51b81526020600482015260166024820152751c995dd85c9908185b1c9958591e4818db185a5b595960521b60448201526064015b60405180910390fd5b6000828152600360209081526040808320868452909152808220805460ff191660011790555163e0d3d58d60e01b8152600481018490528190819081908190819081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e0d3d58d9060240160e06040518083038186803b1580156103e757600080fd5b505afa1580156103fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041f9190611478565b965096509650965096509650965060008860050160009054906101000a90046001600160a01b0316905061047c838a60080160009054906101000a900463ffffffff168b60080160049054906101000a900463ffffffff16610d50565b6001600160a01b038116156105455760405163cd98536b60e01b8152600481018b90526001600160a01b0382811660248301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063cd98536b9060440160206040518083038186803b1580156104f857600080fd5b505afa15801561050c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105309190611504565b9050610543828288888e60060154610e52565b505b600489015461055e9086906001600160a01b0316610fc8565b60058901546105779082906001600160a01b0316610fc8565b60008b81526002602052604090206003015486146105d75760405162461bcd60e51b815260206004820181905260248201527f4d61726b65744964206d69736d6174636820666f7220616c6c6f636174696f6e604482015260640161034f565b6000856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561061257600080fd5b505afa158015610626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064a919061151d565b60088b015460ff918216925060009161066d91600160401b900416858c8c61103b565b9050600061068087848e60070154611191565b905061068c8e826111b2565b60008e8152600260205260409081902060010154905163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b1580156106ea57600080fd5b505af11580156106fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107229190611413565b50604080518f8152602081018f90526001600160a01b038416818301526060810183905290517f9bcf4b7082743be9e48c040fa49881bdac9ba7ed4f12e71d8ff6c946da65c0649181900360800190a15050505050505050505050505050565b600180546000918261079383611540565b909155509050336107a7602084018461155b565b6001600160a01b0316146107fd5760405162461bcd60e51b815260206004820152601960248201527f496e76616c696420616c6c6f6361746f72206164647265737300000000000000604482015260640161034f565b61080d604083016020840161155b565b604080516323b872dd60e01b81523360048201523060248201529084013560448201526001600160a01b0391909116906323b872dd90606401602060405180830381600087803b15801561086057600080fd5b505af1158015610874573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108989190611413565b50600081815260026020526040902082906108b38282611603565b507f678866ebbf19eed1d9f95e0bfd63584f721eab8935f83844394f78873789a80d9050816108e5602085018561155b565b604080519283526001600160a01b03919091166020830152606085810135838301529051918290030190a1919050565b600054610100900460ff16158080156109355750600054600160ff909116105b8061094f5750303b15801561094f575060005460ff166001145b6109b25760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161034f565b6000805460ff1916600117905580156109d5576000805461ff0019166101001790555b8015610a1b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b600085815260026020526040902080546001600160a01b03163314610a9f5760405162461bcd60e51b815260206004820152603160248201527f4f6e6c792074686520616c6c6f6361746f722063616e2075706461746520616c6044820152703637b1b0ba34b7b7103932bbb0b932399760791b606482015260840161034f565b600681018590556007810184905560088101805463ffffffff8481166401000000000267ffffffffffffffff19909216908616171790556040517ffcd537d3fc9c6f64078c9c86412d6a64c37948df1bd043ecc7f9f581d7e8e24490610b089088815260200190565b60405180910390a1505050505050565b6000828152600260205260409020546001600160a01b03163314610b915760405162461bcd60e51b815260206004820152602a60248201527f4f6e6c792074686520616c6c6f6361746f722063616e206465616c6c6f63617460448201526932903932bbb0b932399760b11b606482015260840161034f565b60008281526002602081905260409091200154811115610bc05750600081815260026020819052604090912001545b610bca82826111b2565b6000828152600260205260409081902060010154905163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b158015610c2657600080fd5b505af1158015610c3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5e9190611413565b5060008281526002602081905260409091200154610d1657600082815260026020819052604080832080546001600160a01b03199081168255600182018054821690559281018490556003810184905560048101805484169055600581018054909316909255600682018390556007820192909255600801805468ffffffffffffffffff19169055517f698179301d5c74d995c4597afa699d93a464ea03a6a2a9bfc11f0d0fd4c9cfd9906102d99084815260200190565b60408051838152602081018390527fdb6f83be148266f54cb6b67859eedb520ac995d0d6b670dcee19a3d5c6f1e47e91016102d9565b5050565b63ffffffff82161580610d6e57508163ffffffff168363ffffffff16115b610dcf5760405162461bcd60e51b815260206004820152602c60248201527f4c6f616e20776173206163636570746564206265666f726520746865206d696e60448201526b1039ba30b93a103a34b6b29760a11b606482015260840161034f565b63ffffffff81161580610ded57508063ffffffff168363ffffffff16105b610e4d5760405162461bcd60e51b815260206004820152602b60248201527f4c6f616e2077617320616363657074656420616674657220746865206d61782060448201526a39ba30b93a103a34b6b29760a91b606482015260840161034f565b505050565b6000836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610e8d57600080fd5b505afa158015610ea1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec5919061151d565b60ff1690506000866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0557600080fd5b505afa158015610f19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3d919061151d565b60ff1690506000610f50858484876111dc565b905080871015610fbe5760405162461bcd60e51b815260206004820152603360248201527f4c6f616e20646f6573206e6f74206d656574206d696e696d756d20636f6c6c616044820152723a32b930b634bd30ba34b7b7103930ba34b79760691b606482015260840161034f565b5050505050505050565b6001600160a01b0381161580610fef5750806001600160a01b0316826001600160a01b0316145b610d4c5760405162461bcd60e51b815260206004820152601f60248201527f496e76616c696420657870656374656420746f6b656e20616464726573732e00604482015260640161034f565b60008085600181111561105057611050611305565b14156110be57600484600581111561106a5761106a611305565b146110b75760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642062696420737461746520666f72206c6f616e2e0000000000604482015260640161034f565b5081611189565b60018560018111156110d2576110d2611305565b14156111415760038460058111156110ec576110ec611305565b101561113a5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642062696420737461746520666f72206c6f616e2e0000000000604482015260640161034f565b5080611189565b60405162461bcd60e51b815260206004820152601b60248201527f556e6b6e6f776e20616c6c6f636174696f6e2073747261746567790000000000604482015260640161034f565b949350505050565b60006111a884836111a386600a6117dc565b611201565b90505b9392505050565b600082815260026020819052604082200180548392906111d39084906117e8565b90915550505050565b60006111f885836111ed868861144b565b6111a390600a6117dc565b95945050505050565b60008080600019858709858702925082811083820303915050806000141561123c57838281611232576112326117ff565b04925050506111ab565b80841161124857600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b600080604083850312156112c457600080fd5b50508035926020909101359150565b600061016082840312156112e657600080fd5b50919050565b6000602082840312156112fe57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b038c811682528b81166020830152604082018b9052606082018a90528881166080830152871660a082015260c0810186905260e0810185905263ffffffff848116610100830152831661012082015261016081016002831061139457634e487b7160e01b600052602160045260246000fd5b826101408301529c9b505050505050505050505050565b63ffffffff81168114610a1b57600080fd5b600080600080600060a086880312156113d557600080fd5b85359450602086013593506040860135925060608601356113f5816113ab565b91506080860135611405816113ab565b809150509295509295909350565b60006020828403121561142557600080fd5b815180151581146111ab57600080fd5b634e487b7160e01b600052601160045260246000fd5b6000821982111561145e5761145e611435565b500190565b6001600160a01b0381168114610a1b57600080fd5b600080600080600080600060e0888a03121561149357600080fd5b875161149e81611463565b60208901519097506114af81611463565b604089015160608a015191975095506114c781611463565b608089015160a08a015191955093506114df816113ab565b60c0890151909250600681106114f457600080fd5b8091505092959891949750929550565b60006020828403121561151657600080fd5b5051919050565b60006020828403121561152f57600080fd5b815160ff811681146111ab57600080fd5b600060001982141561155457611554611435565b5060010190565b60006020828403121561156d57600080fd5b81356111ab81611463565b6000813561158581611463565b92915050565b80546001600160a01b0319166001600160a01b0392909216919091179055565b60008135611585816113ab565b600081356002811061158557600080fd5b600282106115e757634e487b7160e01b600052602160045260246000fd5b805460ff60401b8360401b1660ff60401b198216178255505050565b61161561160f83611578565b8261158b565b61162d61162460208401611578565b6001830161158b565b604082013560028201556060820135600382015561165961165060808401611578565b6004830161158b565b61167161166860a08401611578565b6005830161158b565b60c0820135600682015560e08201356007820155600881016116b061169961010085016115ab565b825463ffffffff191663ffffffff91909116178255565b6116e26116c061012085016115ab565b825467ffffffff00000000191660209190911b67ffffffff0000000016178255565b610e4d6116f261014085016115b8565b826115c9565b600181815b8085111561173357816000190482111561171957611719611435565b8085161561172657918102915b93841c93908002906116fd565b509250929050565b60008261174a57506001611585565b8161175757506000611585565b816001811461176d576002811461177757611793565b6001915050611585565b60ff84111561178857611788611435565b50506001821b611585565b5060208310610133831016604e8410600b84101617156117b6575081810a611585565b6117c083836116f8565b80600019048211156117d4576117d4611435565b029392505050565b60006111ab838361173b565b6000828210156117fa576117fa611435565b500390565b634e487b7160e01b600052601260045260246000fdfea2646970667358221220e9ee9ce41db1cc79b75bc905ef429848369d3338d2dc4b86c00a6602f8690fb164736f6c63430008090033", @@ -510,7 +510,7 @@ "storageLayout": { "storage": [ { - "astId": 138, + "astId": 326, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "_initialized", "offset": 0, @@ -518,7 +518,7 @@ "type": "t_uint8" }, { - "astId": 141, + "astId": 329, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "_initializing", "offset": 1, @@ -526,7 +526,7 @@ "type": "t_bool" }, { - "astId": 12374, + "astId": 16459, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "allocationCount", "offset": 0, @@ -534,15 +534,15 @@ "type": "t_uint256" }, { - "astId": 12379, + "astId": 16464, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "allocatedRewards", "offset": 0, "slot": "2", - "type": "t_mapping(t_uint256,t_struct(RewardAllocation)19290_storage)" + "type": "t_mapping(t_uint256,t_struct(RewardAllocation)24284_storage)" }, { - "astId": 12385, + "astId": 16470, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "rewardClaimedForBid", "offset": 0, @@ -561,7 +561,7 @@ "label": "bool", "numberOfBytes": "1" }, - "t_enum(AllocationStrategy)19293": { + "t_enum(AllocationStrategy)24287": { "encoding": "inplace", "label": "enum IMarketLiquidityRewards.AllocationStrategy", "numberOfBytes": "1" @@ -580,19 +580,19 @@ "numberOfBytes": "32", "value": "t_mapping(t_uint256,t_bool)" }, - "t_mapping(t_uint256,t_struct(RewardAllocation)19290_storage)": { + "t_mapping(t_uint256,t_struct(RewardAllocation)24284_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct IMarketLiquidityRewards.RewardAllocation)", "numberOfBytes": "32", - "value": "t_struct(RewardAllocation)19290_storage" + "value": "t_struct(RewardAllocation)24284_storage" }, - "t_struct(RewardAllocation)19290_storage": { + "t_struct(RewardAllocation)24284_storage": { "encoding": "inplace", "label": "struct IMarketLiquidityRewards.RewardAllocation", "members": [ { - "astId": 19268, + "astId": 24262, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "allocator", "offset": 0, @@ -600,7 +600,7 @@ "type": "t_address" }, { - "astId": 19270, + "astId": 24264, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "rewardTokenAddress", "offset": 0, @@ -608,7 +608,7 @@ "type": "t_address" }, { - "astId": 19272, + "astId": 24266, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "rewardTokenAmount", "offset": 0, @@ -616,7 +616,7 @@ "type": "t_uint256" }, { - "astId": 19274, + "astId": 24268, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "marketId", "offset": 0, @@ -624,7 +624,7 @@ "type": "t_uint256" }, { - "astId": 19276, + "astId": 24270, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "requiredPrincipalTokenAddress", "offset": 0, @@ -632,7 +632,7 @@ "type": "t_address" }, { - "astId": 19278, + "astId": 24272, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "requiredCollateralTokenAddress", "offset": 0, @@ -640,7 +640,7 @@ "type": "t_address" }, { - "astId": 19280, + "astId": 24274, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "minimumCollateralPerPrincipalAmount", "offset": 0, @@ -648,7 +648,7 @@ "type": "t_uint256" }, { - "astId": 19282, + "astId": 24276, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "rewardPerLoanPrincipalAmount", "offset": 0, @@ -656,7 +656,7 @@ "type": "t_uint256" }, { - "astId": 19284, + "astId": 24278, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "bidStartTimeMin", "offset": 0, @@ -664,7 +664,7 @@ "type": "t_uint32" }, { - "astId": 19286, + "astId": 24280, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "bidStartTimeMax", "offset": 4, @@ -672,12 +672,12 @@ "type": "t_uint32" }, { - "astId": 19289, + "astId": 24283, "contract": "contracts/MarketLiquidityRewards.sol:MarketLiquidityRewards", "label": "allocationStrategy", "offset": 8, "slot": "8", - "type": "t_enum(AllocationStrategy)19293" + "type": "t_enum(AllocationStrategy)24287" } ], "numberOfBytes": "288" diff --git a/packages/contracts/deployments/goerli/MarketLiquidityRewards_Proxy.json b/packages/contracts/deployments/goerli/MarketLiquidityRewards_Proxy.json index 3fb0ddc50..53736e00b 100644 --- a/packages/contracts/deployments/goerli/MarketLiquidityRewards_Proxy.json +++ b/packages/contracts/deployments/goerli/MarketLiquidityRewards_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", + "address": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", "abi": [ { "inputs": [ @@ -146,63 +146,63 @@ "type": "receive" } ], - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", - "transactionIndex": 0, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", + "transactionIndex": 20, "gasUsed": "745965", - "logsBloom": "0x00000000000000080000000020000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000100000020000000000000000000040000000000000400000000000000000000000000100000000000001000000000000000000001000000000000000000000000", - "blockHash": "0xd4a305d0afa01a819bcbd899b2c30c2da544daf08f98fe080fce144e6320258b", - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", + "logsBloom": "0x00000000000000000000000000000000400000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000140000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000080040000000000000400000000000000000000000000000000000001000000000000000000000000000000000000000000100000", + "blockHash": "0x933b881484a8721cace56ab8c162e378842bbd1dabb3bc7c19e8d362c014432e", + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", "logs": [ { - "transactionIndex": 0, - "blockNumber": 8667201, - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", - "address": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", + "transactionIndex": 20, + "blockNumber": 8689044, + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", + "address": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000001a8f9c4d62a1e36381058ae376b19ea07d7f4c3b" + "0x00000000000000000000000090418c2438c66e8f0d9712ea0447c23c80fe0441" ], "data": "0x", "logIndex": 0, - "blockHash": "0xd4a305d0afa01a819bcbd899b2c30c2da544daf08f98fe080fce144e6320258b" + "blockHash": "0x933b881484a8721cace56ab8c162e378842bbd1dabb3bc7c19e8d362c014432e" }, { - "transactionIndex": 0, - "blockNumber": 8667201, - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", - "address": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", + "transactionIndex": 20, + "blockNumber": 8689044, + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", + "address": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 1, - "blockHash": "0xd4a305d0afa01a819bcbd899b2c30c2da544daf08f98fe080fce144e6320258b" + "blockHash": "0x933b881484a8721cace56ab8c162e378842bbd1dabb3bc7c19e8d362c014432e" }, { - "transactionIndex": 0, - "blockNumber": 8667201, - "transactionHash": "0x182f008f65399b832d9819b4b994b7aa21efb96030ccf9c69ff973715412ec33", - "address": "0xfa0a79661ad21fbd416ddbD9a098564b3686adf5", + "transactionIndex": 20, + "blockNumber": 8689044, + "transactionHash": "0x55cec3adcef0acab952433ae8407b9051176f7f74ae6d921baf82f036d9cc8b9", + "address": "0x0E0ad52d1E1ddA7C81d7A5988e8fFD39F113a73A", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 2, - "blockHash": "0xd4a305d0afa01a819bcbd899b2c30c2da544daf08f98fe080fce144e6320258b" + "blockHash": "0x933b881484a8721cace56ab8c162e378842bbd1dabb3bc7c19e8d362c014432e" } ], - "blockNumber": 8667201, - "cumulativeGasUsed": "745965", + "blockNumber": 8689044, + "cumulativeGasUsed": "1165965", "status": 1, "byzantium": true }, "args": [ - "0x1a8f9C4D62A1E36381058ae376b19ea07d7F4C3B", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0x90418C2438c66e8f0d9712Ea0447c23c80fe0441", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x8129fc1c" ], "numDeployments": 1, diff --git a/packages/contracts/deployments/goerli/MarketRegistry.json b/packages/contracts/deployments/goerli/MarketRegistry.json index 1a7ccb2fa..c301515bd 100644 --- a/packages/contracts/deployments/goerli/MarketRegistry.json +++ b/packages/contracts/deployments/goerli/MarketRegistry.json @@ -1,5 +1,5 @@ { - "address": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", + "address": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", "abi": [ { "anonymous": false, @@ -1657,99 +1657,105 @@ "type": "constructor" } ], - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", - "transactionIndex": 1, - "gasUsed": "1119671", - "logsBloom": "0x04000000000000000000000000000002400000000000000000000000000000004100000000000000000000000000000080000000000000000000400000050000000000000020000000000000000002000000000000040000000000000000000000000000000000400000000000000000000000842000000000000000000008000000000000000000000000000000000000000040000080000000000000800000000000000000000000000100000400000000000000000000000000000000000000000020000000000000000000040000000000000404000000000000000040002000000000000000000000000000008000000000008008000000008000004000", - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c", - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", + "transactionIndex": 8, + "gasUsed": "1119967", + "logsBloom": "0x04000000000000000000000100000000400000010000000000000000000000000000000000000000000000000000000000000000000000000000000001040000000000000000000000000000000002000000000000040000000000000010000000000000000000000000000001000000000000800008000000000000000000000000000000000000000000000000000000000040000080000000000000800200000000004000000000000100000400000000000000000000000000040000000200000028000000000000000000040000000000008404000000000000004040010000000000000000000000000000000002000000008008000000000000000000", + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00", + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", "logs": [ { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000b43707f26d6356ae753e9c92d3c94d23c70c4057" + "0x000000000000000000000000f2b061a749ef7f983dd95aa00c698815dbfde414" ], "data": "0x", "logIndex": 0, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" }, { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x66ed2c7123FE6e95EE5Dfd27EaCD30cedb5F9cD2", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x16Ba53DDE085132b6cEb93334335f4236f6B58d4", "topics": [ "0x51a1a037ef8a642f8b5528429785b5a54e6ee54fb2d2db4b4a44480b5302d55b", - "0xa527b8a9866551c67a288f5890f65baf7ca9161bbefb8e0deb3d64d69b5a1ec6", + "0xe9fe23c0d1e41ff6510824323dafb6410722e8028be36ae209ba341c91fcad24", "0x0000000000000000000000000000000000000000000000000000000000000001" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000074ffc87282ab32c8e0969e26f93c820a213ae14600000000000000000000000074ffc87282ab32c8e0969e26f93c820a213ae14600000000000000000000000000000000000000000000000000000000000000292875696e74323536206d61726b657449642c2061646472657373206c656e64657241646472657373290000000000000000000000000000000000000000000000", + "data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000004f6908b97e4e985b849174f9904faf0a0e5041300000000000000000000000004f6908b97e4e985b849174f9904faf0a0e5041300000000000000000000000000000000000000000000000000000000000000292875696e74323536206d61726b657449642c2061646472657373206c656e64657241646472657373290000000000000000000000000000000000000000000000", "logIndex": 1, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" }, { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x66ed2c7123FE6e95EE5Dfd27EaCD30cedb5F9cD2", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x16Ba53DDE085132b6cEb93334335f4236f6B58d4", "topics": [ "0x51a1a037ef8a642f8b5528429785b5a54e6ee54fb2d2db4b4a44480b5302d55b", - "0xf76f4df82397149508696f392a80f2e2a6f717faf979b87d4636f37a00e91346", + "0x2b1743137d15722b02cc9049d12967bd29f1bfc8788995c02e3548d246e89024", "0x0000000000000000000000000000000000000000000000000000000000000002" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000074ffc87282ab32c8e0969e26f93c820a213ae14600000000000000000000000074ffc87282ab32c8e0969e26f93c820a213ae146000000000000000000000000000000000000000000000000000000000000002b2875696e74323536206d61726b657449642c206164647265737320626f72726f7765724164647265737329000000000000000000000000000000000000000000", + "data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000004f6908b97e4e985b849174f9904faf0a0e5041300000000000000000000000004f6908b97e4e985b849174f9904faf0a0e50413000000000000000000000000000000000000000000000000000000000000002b2875696e74323536206d61726b657449642c206164647265737320626f72726f7765724164647265737329000000000000000000000000000000000000000000", "logIndex": 2, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" }, { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 3, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" }, { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 4, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" } ], - "blockNumber": 8538442, - "cumulativeGasUsed": "1140671", + "blockNumber": 8688911, + "cumulativeGasUsed": "1287967", "status": 1, "byzantium": true }, "args": [ - "0xb43707f26D6356ae753E9C92d3C94D23c70c4057", - "0x5956c8158bde236d8e3638362ff7555C329A839B", - "0xc4d66de80000000000000000000000002858023076c86347cdd7dea4f38aa215cbbca91b" + "0xf2b061a749EF7f983DD95Aa00C698815dBfde414", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0xc4d66de80000000000000000000000002b6e11aeb39af806794ba2edc975632084a375b2" ], - "numDeployments": 2, + "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", - "implementation": "0xbC706F216B0E65329DaF7c43359E98eE197a3a58", + "execute": { + "methodName": "initialize", + "args": [ + "0x2B6e11Aeb39Af806794bA2Edc975632084A375b2" + ] + }, + "implementation": "0xf2b061a749EF7f983DD95Aa00C698815dBfde414", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/MarketRegistry_Implementation.json b/packages/contracts/deployments/goerli/MarketRegistry_Implementation.json index a59701319..f0539bf17 100644 --- a/packages/contracts/deployments/goerli/MarketRegistry_Implementation.json +++ b/packages/contracts/deployments/goerli/MarketRegistry_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0xbC706F216B0E65329DaF7c43359E98eE197a3a58", + "address": "0xf2b061a749EF7f983DD95Aa00C698815dBfde414", "abi": [ { "inputs": [], @@ -1517,28 +1517,28 @@ "type": "receive" } ], - "transactionHash": "0xb3da038a038a3a109dd0d227661e00127f20afca71a2450e721af05d884c5d35", + "transactionHash": "0x1e96ea7954d2c5f88fde3d8e8baa5e471a072c15ee5e8979f79308de169ad527", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xbC706F216B0E65329DaF7c43359E98eE197a3a58", - "transactionIndex": 1, - "gasUsed": "2861088", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xf2b061a749EF7f983DD95Aa00C698815dBfde414", + "transactionIndex": 13, + "gasUsed": "2861892", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x44eac928c8e2fa2f2536053d6c5a1cffde381ef313059d08531ff57ff6881350", - "transactionHash": "0xb3da038a038a3a109dd0d227661e00127f20afca71a2450e721af05d884c5d35", + "blockHash": "0xc1b88d15b29def1a8a25adf38e28889895cdc471cf00562ee197c81699c9e107", + "transactionHash": "0x1e96ea7954d2c5f88fde3d8e8baa5e471a072c15ee5e8979f79308de169ad527", "logs": [], - "blockNumber": 8579788, - "cumulativeGasUsed": "2882088", + "blockNumber": 8688910, + "cumulativeGasUsed": "3134892", "status": 1, "byzantium": true }, "args": [], - "numDeployments": 2, - "solcInputHash": "976bca259bf89d14d50591c72cf76420", - "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NotPayable\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"}],\"name\":\"BorrowerAttestation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"}],\"name\":\"BorrowerExitMarket\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"}],\"name\":\"BorrowerRevocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"}],\"name\":\"LenderAttestation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"}],\"name\":\"LenderExitMarket\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"}],\"name\":\"LenderRevocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"MarketClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"MarketCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"duration\",\"type\":\"uint32\"}],\"name\":\"SetBidExpirationTime\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"required\",\"type\":\"bool\"}],\"name\":\"SetMarketBorrowerAttestation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"feePct\",\"type\":\"uint16\"}],\"name\":\"SetMarketFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newRecipient\",\"type\":\"address\"}],\"name\":\"SetMarketFeeRecipient\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"required\",\"type\":\"bool\"}],\"name\":\"SetMarketLenderAttestation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"SetMarketOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum PaymentType\",\"name\":\"paymentType\",\"type\":\"uint8\"}],\"name\":\"SetMarketPaymentType\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"uri\",\"type\":\"string\"}],\"name\":\"SetMarketURI\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum PaymentCycleType\",\"name\":\"paymentCycleType\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"value\",\"type\":\"uint32\"}],\"name\":\"SetPaymentCycle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"duration\",\"type\":\"uint32\"}],\"name\":\"SetPaymentCycleDuration\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"duration\",\"type\":\"uint32\"}],\"name\":\"SetPaymentDefaultDuration\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CURRENT_CODE_VERSION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_expirationTime\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"attestBorrower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_expirationTime\",\"type\":\"uint256\"}],\"name\":\"attestBorrower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_expirationTime\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"attestLender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_expirationTime\",\"type\":\"uint256\"}],\"name\":\"attestLender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowerAttestationSchemaId\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"borrowerExitMarket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"closeMarket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_initialOwner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_paymentCycleDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_paymentDefaultDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_bidExpirationTime\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_feePercent\",\"type\":\"uint16\"},{\"internalType\":\"bool\",\"name\":\"_requireLenderAttestation\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_requireBorrowerAttestation\",\"type\":\"bool\"},{\"internalType\":\"enum PaymentType\",\"name\":\"_paymentType\",\"type\":\"uint8\"},{\"internalType\":\"enum PaymentCycleType\",\"name\":\"_paymentCycleType\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"_uri\",\"type\":\"string\"}],\"name\":\"createMarket\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"marketId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_initialOwner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_paymentCycleDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_paymentDefaultDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_bidExpirationTime\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_feePercent\",\"type\":\"uint16\"},{\"internalType\":\"bool\",\"name\":\"_requireLenderAttestation\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_requireBorrowerAttestation\",\"type\":\"bool\"},{\"internalType\":\"string\",\"name\":\"_uri\",\"type\":\"string\"}],\"name\":\"createMarket\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"marketId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_page\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_perPage\",\"type\":\"uint256\"}],\"name\":\"getAllVerifiedBorrowersForMarket\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_page\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_perPage\",\"type\":\"uint256\"}],\"name\":\"getAllVerifiedLendersForMarket\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"getBidExpirationTime\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketAttestationRequirements\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"lenderAttestationRequired\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"borrowerAttestationRequired\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketData\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"paymentCycleDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"paymentDefaultDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"loanExpirationTime\",\"type\":\"uint32\"},{\"internalType\":\"string\",\"name\":\"metadataURI\",\"type\":\"string\"},{\"internalType\":\"uint16\",\"name\":\"marketplaceFeePercent\",\"type\":\"uint16\"},{\"internalType\":\"bool\",\"name\":\"lenderAttestationRequired\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketFeeRecipient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketplaceFee\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"fee\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getPaymentCycle\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"},{\"internalType\":\"enum PaymentCycleType\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getPaymentDefaultDuration\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getPaymentType\",\"outputs\":[{\"internalType\":\"enum PaymentType\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TellerAS\",\"name\":\"_tellerAS\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"isMarketClosed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isPayable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"}],\"name\":\"isVerifiedBorrower\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isVerified_\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"uuid_\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"}],\"name\":\"isVerifiedLender\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isVerified_\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"uuid_\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lenderAttestationSchemaId\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"lenderExitMarket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"schema\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"attestor\",\"type\":\"address\"}],\"name\":\"resolve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"}],\"name\":\"revokeBorrower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"revokeBorrower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"revokeLender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"}],\"name\":\"revokeLender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_duration\",\"type\":\"uint32\"}],\"name\":\"setBidExpirationTime\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_required\",\"type\":\"bool\"}],\"name\":\"setBorrowerAttestationRequired\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_required\",\"type\":\"bool\"}],\"name\":\"setLenderAttestationRequired\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint16\",\"name\":\"_newPercent\",\"type\":\"uint16\"}],\"name\":\"setMarketFeePercent\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"setMarketFeeRecipient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"enum PaymentType\",\"name\":\"_newPaymentType\",\"type\":\"uint8\"}],\"name\":\"setMarketPaymentType\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"_uri\",\"type\":\"string\"}],\"name\":\"setMarketURI\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"enum PaymentCycleType\",\"name\":\"_paymentCycleType\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"_duration\",\"type\":\"uint32\"}],\"name\":\"setPaymentCycle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_duration\",\"type\":\"uint32\"}],\"name\":\"setPaymentDefaultDuration\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tellerAS\",\"outputs\":[{\"internalType\":\"contract TellerAS\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"transferMarketOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_paymentCycleDuration\",\"type\":\"uint32\"},{\"internalType\":\"enum PaymentType\",\"name\":\"_newPaymentType\",\"type\":\"uint8\"},{\"internalType\":\"enum PaymentCycleType\",\"name\":\"_paymentCycleType\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"_paymentDefaultDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_bidExpirationTime\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_feePercent\",\"type\":\"uint16\"},{\"internalType\":\"bool\",\"name\":\"_borrowerAttestationRequired\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_lenderAttestationRequired\",\"type\":\"bool\"},{\"internalType\":\"string\",\"name\":\"_metadataURI\",\"type\":\"string\"}],\"name\":\"updateMarketSettings\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"attestBorrower(uint256,address,uint256)\":{\"details\":\"See {_attestStakeholder}.\"},\"attestBorrower(uint256,address,uint256,uint8,bytes32,bytes32)\":{\"details\":\"See {_attestStakeholderViaDelegation}.\"},\"attestLender(uint256,address,uint256)\":{\"details\":\"See {_attestStakeholder}.\"},\"attestLender(uint256,address,uint256,uint8,bytes32,bytes32)\":{\"details\":\"See {_attestStakeholderViaDelegation}.\"},\"borrowerExitMarket(uint256)\":{\"params\":{\"_marketId\":\"The market ID to leave.\"}},\"closeMarket(uint256)\":{\"params\":{\"_marketId\":\"The market ID for the market to close.\"}},\"createMarket(address,uint32,uint32,uint32,uint16,bool,bool,string)\":{\"details\":\"Uses the default EMI payment type.\",\"params\":{\"_bidExpirationTime\":\"Length of time in seconds before pending bids expire.\",\"_initialOwner\":\"Address who will initially own the market.\",\"_paymentCycleDuration\":\"Length of time in seconds before a bid's next payment is required to be made.\",\"_paymentDefaultDuration\":\"Length of time in seconds before a loan is considered in default for non-payment.\",\"_requireBorrowerAttestation\":\"Boolean that indicates if borrowers require attestation to join market.\",\"_requireLenderAttestation\":\"Boolean that indicates if lenders require attestation to join market.\",\"_uri\":\"URI string to get metadata details about the market.\"},\"returns\":{\"marketId_\":\"The market ID of the newly created market.\"}},\"createMarket(address,uint32,uint32,uint32,uint16,bool,bool,uint8,uint8,string)\":{\"params\":{\"_bidExpirationTime\":\"Length of time in seconds before pending bids expire.\",\"_initialOwner\":\"Address who will initially own the market.\",\"_paymentCycleDuration\":\"Length of time in seconds before a bid's next payment is required to be made.\",\"_paymentCycleType\":\"The payment cycle type for loans in the market - Seconds or Monthly\",\"_paymentDefaultDuration\":\"Length of time in seconds before a loan is considered in default for non-payment.\",\"_paymentType\":\"The payment type for loans in the market.\",\"_requireBorrowerAttestation\":\"Boolean that indicates if borrowers require attestation to join market.\",\"_requireLenderAttestation\":\"Boolean that indicates if lenders require attestation to join market.\",\"_uri\":\"URI string to get metadata details about the market.\"},\"returns\":{\"marketId_\":\"The market ID of the newly created market.\"}},\"getAllVerifiedBorrowersForMarket(uint256,uint256,uint256)\":{\"params\":{\"_marketId\":\"The ID of the market.\",\"_page\":\"Page index to start from.\",\"_perPage\":\"Number of items in a page to return.\"},\"returns\":{\"_0\":\"Array of addresses that have been added to a market.\"}},\"getAllVerifiedLendersForMarket(uint256,uint256,uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_page\":\"Page index to start from.\",\"_perPage\":\"Number of items in a page to return.\"},\"returns\":{\"_0\":\"Array of addresses that have been added to a market.\"}},\"getMarketAttestationRequirements(uint256)\":{\"params\":{\"_marketId\":\"The ID of the market.\"}},\"getMarketData(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"}},\"getMarketFeeRecipient(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"The address of a market's fee recipient.\"}},\"getMarketOwner(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"The address of a market's owner.\"}},\"getMarketURI(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"URI of a market's metadata.\"}},\"getMarketplaceFee(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"fee\":\"in basis points\"}},\"getPaymentCycle(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"Duration of a loan until it is delinquent.\",\"_1\":\"The type of payment cycle for loans in the market.\"}},\"getPaymentDefaultDuration(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"Duration of a loan repayment interval until it is default.\"}},\"getPaymentType(uint256)\":{\"params\":{\"_marketId\":\"the ID of the market.\"},\"returns\":{\"_0\":\"The type of payment for loans in the market.\"}},\"isMarketClosed(uint256)\":{\"params\":{\"_marketId\":\"The market ID for the market to check.\"}},\"isPayable()\":{\"details\":\"Returns whether the resolver supports ETH transfers\"},\"isVerifiedBorrower(uint256,address)\":{\"params\":{\"_borrowerAddress\":\"Address of the borrower to check.\",\"_marketId\":\"The ID of a market.\"},\"returns\":{\"isVerified_\":\"Boolean indicating if a borrower has been added to a market.\",\"uuid_\":\"Bytes32 representing the UUID of the borrower.\"}},\"isVerifiedLender(uint256,address)\":{\"params\":{\"_lenderAddress\":\"Address to check.\",\"_marketId\":\"The ID of a market.\"},\"returns\":{\"isVerified_\":\"Boolean indicating if a lender has been added to a market.\",\"uuid_\":\"Bytes32 representing the UUID of the lender.\"}},\"lenderExitMarket(uint256)\":{\"params\":{\"_marketId\":\"The market ID to leave.\"}},\"resolve(address,bytes,bytes,uint256,address)\":{\"details\":\"This function must only be called by the `attestLender` function above.\",\"params\":{\"\":\"@param attestor Market owner's address who signed the attestation.\",\"data\":\"Data the must include the market ID and lender's address\",\"recipient\":\"Lender's address who is being attested.\",\"schema\":\"The schema used for the attestation.\"},\"returns\":{\"_0\":\"Boolean indicating the attestation was successful.\"}},\"revokeBorrower(uint256,address)\":{\"details\":\"See {_revokeStakeholder}.\"},\"revokeBorrower(uint256,address,uint8,bytes32,bytes32)\":{\"details\":\"See {_revokeStakeholderViaDelegation}.\"},\"revokeLender(uint256,address)\":{\"details\":\"See {_revokeStakeholder}.\"},\"revokeLender(uint256,address,uint8,bytes32,bytes32)\":{\"details\":\"See {_revokeStakeholderViaDelegation}.\"},\"setBorrowerAttestationRequired(uint256,bool)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_required\":\"Boolean indicating if the market requires whitelist. Requirements: - The caller must be the current owner.\"}},\"setLenderAttestationRequired(uint256,bool)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_required\":\"Boolean indicating if the market requires whitelist. Requirements: - The caller must be the current owner.\"}},\"setMarketFeePercent(uint256,uint16)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_newPercent\":\"The percentage fee in basis points. Requirements: - The caller must be the current owner.\"}},\"setMarketFeeRecipient(uint256,address)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_recipient\":\"Address of the new fee recipient. Requirements: - The caller must be the current owner.\"}},\"setMarketPaymentType(uint256,uint8)\":{\"params\":{\"_marketId\":\"The ID of the market.\",\"_newPaymentType\":\"The payment type for the market.\"}},\"setMarketURI(uint256,string)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_uri\":\"A URI that points to a market's metadata. Requirements: - The caller must be the current owner.\"}},\"setPaymentCycle(uint256,uint8,uint32)\":{\"params\":{\"_duration\":\"Delinquency duration for new loans\",\"_marketId\":\"The ID of a market.\",\"_paymentCycleType\":\"Cycle type (seconds or monthly)\"}},\"setPaymentDefaultDuration(uint256,uint32)\":{\"params\":{\"_duration\":\"Default duration for new loans\",\"_marketId\":\"The ID of a market.\"}},\"transferMarketOwnership(uint256,address)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_newOwner\":\"Address of the new market owner. Requirements: - The caller must be the current owner.\"}},\"updateMarketSettings(uint256,uint32,uint8,uint8,uint32,uint32,uint16,bool,bool,string)\":{\"params\":{\"_bidExpirationTime\":\"Duration of time before a bid is considered out of date\",\"_marketId\":\"The ID of a market.\",\"_metadataURI\":\"A URI that points to a market's metadata. Requirements: - The caller must be the current owner.\",\"_newPaymentType\":\"The payment type for the market.\",\"_paymentCycleDuration\":\"Delinquency duration for new loans\",\"_paymentCycleType\":\"The payment cycle type for loans in the market - Seconds or Monthly\",\"_paymentDefaultDuration\":\"Default duration for new loans\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"CURRENT_CODE_VERSION()\":{\"notice\":\"Constant Variables *\"},\"attestBorrower(uint256,address,uint256)\":{\"notice\":\"Adds a borrower to a market.\"},\"attestBorrower(uint256,address,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"Adds a borrower to a market via delegated attestation.\"},\"attestLender(uint256,address,uint256)\":{\"notice\":\"Adds a lender to a market.\"},\"attestLender(uint256,address,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"Adds a lender to a market via delegated attestation.\"},\"borrowerExitMarket(uint256)\":{\"notice\":\"Allows a borrower to voluntarily leave a market.\"},\"closeMarket(uint256)\":{\"notice\":\"Closes a market so new bids cannot be added.\"},\"createMarket(address,uint32,uint32,uint32,uint16,bool,bool,string)\":{\"notice\":\"Creates a new market.\"},\"createMarket(address,uint32,uint32,uint32,uint16,bool,bool,uint8,uint8,string)\":{\"notice\":\"Creates a new market.\"},\"getAllVerifiedBorrowersForMarket(uint256,uint256,uint256)\":{\"notice\":\"Gets addresses of all attested borrowers.\"},\"getAllVerifiedLendersForMarket(uint256,uint256,uint256)\":{\"notice\":\"Gets addresses of all attested lenders.\"},\"getMarketAttestationRequirements(uint256)\":{\"notice\":\"Gets the attestation requirements for a given market.\"},\"getMarketData(uint256)\":{\"notice\":\"Gets the data associated with a market.\"},\"getMarketFeeRecipient(uint256)\":{\"notice\":\"Gets the fee recipient of a market.\"},\"getMarketOwner(uint256)\":{\"notice\":\"Gets the address of a market's owner.\"},\"getMarketURI(uint256)\":{\"notice\":\"Gets the metadata URI of a market.\"},\"getMarketplaceFee(uint256)\":{\"notice\":\"Gets the marketplace fee in basis points\"},\"getPaymentCycle(uint256)\":{\"notice\":\"Gets the loan delinquent duration of a market.\"},\"getPaymentDefaultDuration(uint256)\":{\"notice\":\"Gets the loan default duration of a market.\"},\"getPaymentType(uint256)\":{\"notice\":\"Get the payment type of a market.\"},\"isMarketClosed(uint256)\":{\"notice\":\"Returns the status of a market being open or closed for new bids.\"},\"isVerifiedBorrower(uint256,address)\":{\"notice\":\"Checks if a borrower has been attested and added to a market.\"},\"isVerifiedLender(uint256,address)\":{\"notice\":\"Checks if a lender has been attested and added to a market.\"},\"lenderExitMarket(uint256)\":{\"notice\":\"Allows a lender to voluntarily leave a market.\"},\"resolve(address,bytes,bytes,uint256,address)\":{\"notice\":\"Verifies an attestation is valid.\"},\"revokeBorrower(uint256,address)\":{\"notice\":\"Removes a borrower from an market.\"},\"revokeBorrower(uint256,address,uint8,bytes32,bytes32)\":{\"notice\":\"Removes a borrower from a market via delegated revocation.\"},\"revokeLender(uint256,address)\":{\"notice\":\"Removes a lender from an market.\"},\"revokeLender(uint256,address,uint8,bytes32,bytes32)\":{\"notice\":\"Removes a borrower from a market via delegated revocation.\"},\"setBorrowerAttestationRequired(uint256,bool)\":{\"notice\":\"Enable/disables market whitelist for borrowers.\"},\"setLenderAttestationRequired(uint256,bool)\":{\"notice\":\"Enable/disables market whitelist for lenders.\"},\"setMarketFeePercent(uint256,uint16)\":{\"notice\":\"Sets the fee for the market.\"},\"setMarketFeeRecipient(uint256,address)\":{\"notice\":\"Sets the fee recipient address for a market.\"},\"setMarketPaymentType(uint256,uint8)\":{\"notice\":\"Set the payment type for the market.\"},\"setMarketURI(uint256,string)\":{\"notice\":\"Sets the metadata URI for a market.\"},\"setPaymentCycle(uint256,uint8,uint32)\":{\"notice\":\"Sets the duration of new loans for this market before they turn delinquent.Changing this value does not change the terms of existing loans for this market.\"},\"setPaymentDefaultDuration(uint256,uint32)\":{\"notice\":\"Sets the duration of new loans for this market before they turn defaulted.Changing this value does not change the terms of existing loans for this market.\"},\"transferMarketOwnership(uint256,address)\":{\"notice\":\"Transfers ownership of a marketplace.\"},\"updateMarketSettings(uint256,uint32,uint8,uint8,uint32,uint32,uint16,bool,bool,string)\":{\"notice\":\"Updates multiple market settings for a given market.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/MarketRegistry.sol\":\"MarketRegistry\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x3798da9e212cd00a7cda94ddb5a9721171a718e89c500d8901f810e0e37fa74e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/EAS/TellerASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../interfaces/IASResolver.sol\\\";\\n\\n/**\\n * @title A base resolver contract\\n */\\nabstract contract TellerASResolver is IASResolver {\\n error NotPayable();\\n\\n function isPayable() public pure virtual override returns (bool) {\\n return false;\\n }\\n\\n receive() external payable virtual {\\n if (!isPayable()) {\\n revert NotPayable();\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8002d1725fd711dacd001e06d98fe2afc4814d2939d06df70c5b3ffcf5ec7f15\",\"license\":\"MIT\"},\"contracts/MarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Contracts\\nimport \\\"./EAS/TellerAS.sol\\\";\\nimport \\\"./EAS/TellerASResolver.sol\\\";\\n\\n//must continue to use this so storage slots are not broken\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Context.sol\\\";\\n\\n// Interfaces\\nimport \\\"./interfaces/IMarketRegistry.sol\\\";\\n\\n// Libraries\\nimport { EnumerableSet } from \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport { PaymentType } from \\\"./libraries/V2Calculations.sol\\\";\\n\\ncontract MarketRegistry is\\n IMarketRegistry,\\n Initializable,\\n Context,\\n TellerASResolver\\n{\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /** Constant Variables **/\\n\\n uint256 public constant CURRENT_CODE_VERSION = 8;\\n\\n /* Storage Variables */\\n\\n struct Marketplace {\\n address owner;\\n string metadataURI;\\n uint16 marketplaceFeePercent; // 10000 is 100%\\n bool lenderAttestationRequired;\\n EnumerableSet.AddressSet verifiedLendersForMarket;\\n mapping(address => bytes32) lenderAttestationIds;\\n uint32 paymentCycleDuration; // unix time (seconds)\\n uint32 paymentDefaultDuration; //unix time\\n uint32 bidExpirationTime; //unix time\\n bool borrowerAttestationRequired;\\n EnumerableSet.AddressSet verifiedBorrowersForMarket;\\n mapping(address => bytes32) borrowerAttestationIds;\\n address feeRecipient;\\n PaymentType paymentType;\\n PaymentCycleType paymentCycleType;\\n }\\n\\n bytes32 public lenderAttestationSchemaId;\\n\\n mapping(uint256 => Marketplace) internal markets;\\n mapping(bytes32 => uint256) internal __uriToId; //DEPRECATED\\n uint256 public marketCount;\\n bytes32 private _attestingSchemaId;\\n bytes32 public borrowerAttestationSchemaId;\\n\\n uint256 public version;\\n\\n mapping(uint256 => bool) private marketIsClosed;\\n\\n TellerAS public tellerAS;\\n\\n /* Modifiers */\\n\\n modifier ownsMarket(uint256 _marketId) {\\n require(markets[_marketId].owner == _msgSender(), \\\"Not the owner\\\");\\n _;\\n }\\n\\n modifier withAttestingSchema(bytes32 schemaId) {\\n _attestingSchemaId = schemaId;\\n _;\\n _attestingSchemaId = bytes32(0);\\n }\\n\\n /* Events */\\n\\n event MarketCreated(address indexed owner, uint256 marketId);\\n event SetMarketURI(uint256 marketId, string uri);\\n event SetPaymentCycleDuration(uint256 marketId, uint32 duration); // DEPRECATED - used for subgraph reference\\n event SetPaymentCycle(\\n uint256 marketId,\\n PaymentCycleType paymentCycleType,\\n uint32 value\\n );\\n event SetPaymentDefaultDuration(uint256 marketId, uint32 duration);\\n event SetBidExpirationTime(uint256 marketId, uint32 duration);\\n event SetMarketFee(uint256 marketId, uint16 feePct);\\n event LenderAttestation(uint256 marketId, address lender);\\n event BorrowerAttestation(uint256 marketId, address borrower);\\n event LenderRevocation(uint256 marketId, address lender);\\n event BorrowerRevocation(uint256 marketId, address borrower);\\n event MarketClosed(uint256 marketId);\\n event LenderExitMarket(uint256 marketId, address lender);\\n event BorrowerExitMarket(uint256 marketId, address borrower);\\n event SetMarketOwner(uint256 marketId, address newOwner);\\n event SetMarketFeeRecipient(uint256 marketId, address newRecipient);\\n event SetMarketLenderAttestation(uint256 marketId, bool required);\\n event SetMarketBorrowerAttestation(uint256 marketId, bool required);\\n event SetMarketPaymentType(uint256 marketId, PaymentType paymentType);\\n\\n /* External Functions */\\n\\n function initialize(TellerAS _tellerAS) external initializer {\\n tellerAS = _tellerAS;\\n\\n lenderAttestationSchemaId = tellerAS.getASRegistry().register(\\n \\\"(uint256 marketId, address lenderAddress)\\\",\\n this\\n );\\n borrowerAttestationSchemaId = tellerAS.getASRegistry().register(\\n \\\"(uint256 marketId, address borrowerAddress)\\\",\\n this\\n );\\n }\\n\\n /**\\n * @notice Creates a new market.\\n * @param _initialOwner Address who will initially own the market.\\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\\n * @param _paymentType The payment type for loans in the market.\\n * @param _uri URI string to get metadata details about the market.\\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\\n * @return marketId_ The market ID of the newly created market.\\n */\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_) {\\n marketId_ = _createMarket(\\n _initialOwner,\\n _paymentCycleDuration,\\n _paymentDefaultDuration,\\n _bidExpirationTime,\\n _feePercent,\\n _requireLenderAttestation,\\n _requireBorrowerAttestation,\\n _paymentType,\\n _paymentCycleType,\\n _uri\\n );\\n }\\n\\n /**\\n * @notice Creates a new market.\\n * @dev Uses the default EMI payment type.\\n * @param _initialOwner Address who will initially own the market.\\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\\n * @param _uri URI string to get metadata details about the market.\\n * @return marketId_ The market ID of the newly created market.\\n */\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_) {\\n marketId_ = _createMarket(\\n _initialOwner,\\n _paymentCycleDuration,\\n _paymentDefaultDuration,\\n _bidExpirationTime,\\n _feePercent,\\n _requireLenderAttestation,\\n _requireBorrowerAttestation,\\n PaymentType.EMI,\\n PaymentCycleType.Seconds,\\n _uri\\n );\\n }\\n\\n /**\\n * @notice Creates a new market.\\n * @param _initialOwner Address who will initially own the market.\\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\\n * @param _paymentType The payment type for loans in the market.\\n * @param _uri URI string to get metadata details about the market.\\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\\n * @return marketId_ The market ID of the newly created market.\\n */\\n function _createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) internal returns (uint256 marketId_) {\\n require(_initialOwner != address(0), \\\"Invalid owner address\\\");\\n // Increment market ID counter\\n marketId_ = ++marketCount;\\n\\n // Set the market owner\\n markets[marketId_].owner = _initialOwner;\\n\\n // Initialize market settings\\n _setMarketSettings(\\n marketId_,\\n _paymentCycleDuration,\\n _paymentType,\\n _paymentCycleType,\\n _paymentDefaultDuration,\\n _bidExpirationTime,\\n _feePercent,\\n _requireBorrowerAttestation,\\n _requireLenderAttestation,\\n _uri\\n );\\n\\n emit MarketCreated(_initialOwner, marketId_);\\n }\\n\\n /**\\n * @notice Closes a market so new bids cannot be added.\\n * @param _marketId The market ID for the market to close.\\n */\\n\\n function closeMarket(uint256 _marketId) public ownsMarket(_marketId) {\\n if (!marketIsClosed[_marketId]) {\\n marketIsClosed[_marketId] = true;\\n\\n emit MarketClosed(_marketId);\\n }\\n }\\n\\n /**\\n * @notice Returns the status of a market being open or closed for new bids.\\n * @param _marketId The market ID for the market to check.\\n */\\n function isMarketClosed(uint256 _marketId)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return marketIsClosed[_marketId];\\n }\\n\\n /**\\n * @notice Adds a lender to a market.\\n * @dev See {_attestStakeholder}.\\n */\\n function attestLender(\\n uint256 _marketId,\\n address _lenderAddress,\\n uint256 _expirationTime\\n ) external {\\n _attestStakeholder(_marketId, _lenderAddress, _expirationTime, true);\\n }\\n\\n /**\\n * @notice Adds a lender to a market via delegated attestation.\\n * @dev See {_attestStakeholderViaDelegation}.\\n */\\n function attestLender(\\n uint256 _marketId,\\n address _lenderAddress,\\n uint256 _expirationTime,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) external {\\n _attestStakeholderViaDelegation(\\n _marketId,\\n _lenderAddress,\\n _expirationTime,\\n true,\\n _v,\\n _r,\\n _s\\n );\\n }\\n\\n /**\\n * @notice Removes a lender from an market.\\n * @dev See {_revokeStakeholder}.\\n */\\n function revokeLender(uint256 _marketId, address _lenderAddress) external {\\n _revokeStakeholder(_marketId, _lenderAddress, true);\\n }\\n\\n /**\\n * @notice Removes a borrower from a market via delegated revocation.\\n * @dev See {_revokeStakeholderViaDelegation}.\\n */\\n function revokeLender(\\n uint256 _marketId,\\n address _lenderAddress,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) external {\\n _revokeStakeholderViaDelegation(\\n _marketId,\\n _lenderAddress,\\n true,\\n _v,\\n _r,\\n _s\\n );\\n }\\n\\n /**\\n * @notice Allows a lender to voluntarily leave a market.\\n * @param _marketId The market ID to leave.\\n */\\n function lenderExitMarket(uint256 _marketId) external {\\n // Remove lender address from market set\\n bool response = markets[_marketId].verifiedLendersForMarket.remove(\\n _msgSender()\\n );\\n if (response) {\\n emit LenderExitMarket(_marketId, _msgSender());\\n }\\n }\\n\\n /**\\n * @notice Adds a borrower to a market.\\n * @dev See {_attestStakeholder}.\\n */\\n function attestBorrower(\\n uint256 _marketId,\\n address _borrowerAddress,\\n uint256 _expirationTime\\n ) external {\\n _attestStakeholder(_marketId, _borrowerAddress, _expirationTime, false);\\n }\\n\\n /**\\n * @notice Adds a borrower to a market via delegated attestation.\\n * @dev See {_attestStakeholderViaDelegation}.\\n */\\n function attestBorrower(\\n uint256 _marketId,\\n address _borrowerAddress,\\n uint256 _expirationTime,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) external {\\n _attestStakeholderViaDelegation(\\n _marketId,\\n _borrowerAddress,\\n _expirationTime,\\n false,\\n _v,\\n _r,\\n _s\\n );\\n }\\n\\n /**\\n * @notice Removes a borrower from an market.\\n * @dev See {_revokeStakeholder}.\\n */\\n function revokeBorrower(uint256 _marketId, address _borrowerAddress)\\n external\\n {\\n _revokeStakeholder(_marketId, _borrowerAddress, false);\\n }\\n\\n /**\\n * @notice Removes a borrower from a market via delegated revocation.\\n * @dev See {_revokeStakeholderViaDelegation}.\\n */\\n function revokeBorrower(\\n uint256 _marketId,\\n address _borrowerAddress,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) external {\\n _revokeStakeholderViaDelegation(\\n _marketId,\\n _borrowerAddress,\\n false,\\n _v,\\n _r,\\n _s\\n );\\n }\\n\\n /**\\n * @notice Allows a borrower to voluntarily leave a market.\\n * @param _marketId The market ID to leave.\\n */\\n function borrowerExitMarket(uint256 _marketId) external {\\n // Remove borrower address from market set\\n bool response = markets[_marketId].verifiedBorrowersForMarket.remove(\\n _msgSender()\\n );\\n if (response) {\\n emit BorrowerExitMarket(_marketId, _msgSender());\\n }\\n }\\n\\n /**\\n * @notice Verifies an attestation is valid.\\n * @dev This function must only be called by the `attestLender` function above.\\n * @param recipient Lender's address who is being attested.\\n * @param schema The schema used for the attestation.\\n * @param data Data the must include the market ID and lender's address\\n * @param\\n * @param attestor Market owner's address who signed the attestation.\\n * @return Boolean indicating the attestation was successful.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 /* expirationTime */,\\n address attestor\\n ) external payable override returns (bool) {\\n bytes32 attestationSchemaId = keccak256(\\n abi.encodePacked(schema, address(this))\\n );\\n (uint256 marketId, address lenderAddress) = abi.decode(\\n data,\\n (uint256, address)\\n );\\n return\\n (_attestingSchemaId == attestationSchemaId &&\\n recipient == lenderAddress &&\\n attestor == markets[marketId].owner) ||\\n attestor == address(this);\\n }\\n\\n /**\\n * @notice Transfers ownership of a marketplace.\\n * @param _marketId The ID of a market.\\n * @param _newOwner Address of the new market owner.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function transferMarketOwnership(uint256 _marketId, address _newOwner)\\n public\\n ownsMarket(_marketId)\\n {\\n markets[_marketId].owner = _newOwner;\\n emit SetMarketOwner(_marketId, _newOwner);\\n }\\n\\n /**\\n * @notice Updates multiple market settings for a given market.\\n * @param _marketId The ID of a market.\\n * @param _paymentCycleDuration Delinquency duration for new loans\\n * @param _newPaymentType The payment type for the market.\\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\\n * @param _paymentDefaultDuration Default duration for new loans\\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\\n * @param _metadataURI A URI that points to a market's metadata.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function updateMarketSettings(\\n uint256 _marketId,\\n uint32 _paymentCycleDuration,\\n PaymentType _newPaymentType,\\n PaymentCycleType _paymentCycleType,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _borrowerAttestationRequired,\\n bool _lenderAttestationRequired,\\n string calldata _metadataURI\\n ) public ownsMarket(_marketId) {\\n _setMarketSettings(\\n _marketId,\\n _paymentCycleDuration,\\n _newPaymentType,\\n _paymentCycleType,\\n _paymentDefaultDuration,\\n _bidExpirationTime,\\n _feePercent,\\n _borrowerAttestationRequired,\\n _lenderAttestationRequired,\\n _metadataURI\\n );\\n }\\n\\n /**\\n * @notice Sets the fee recipient address for a market.\\n * @param _marketId The ID of a market.\\n * @param _recipient Address of the new fee recipient.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setMarketFeeRecipient(uint256 _marketId, address _recipient)\\n public\\n ownsMarket(_marketId)\\n {\\n markets[_marketId].feeRecipient = _recipient;\\n emit SetMarketFeeRecipient(_marketId, _recipient);\\n }\\n\\n /**\\n * @notice Sets the metadata URI for a market.\\n * @param _marketId The ID of a market.\\n * @param _uri A URI that points to a market's metadata.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setMarketURI(uint256 _marketId, string calldata _uri)\\n public\\n ownsMarket(_marketId)\\n {\\n //We do string comparison by checking the hashes of the strings against one another\\n if (\\n keccak256(abi.encodePacked(_uri)) !=\\n keccak256(abi.encodePacked(markets[_marketId].metadataURI))\\n ) {\\n markets[_marketId].metadataURI = _uri;\\n\\n emit SetMarketURI(_marketId, _uri);\\n }\\n }\\n\\n /**\\n * @notice Sets the duration of new loans for this market before they turn delinquent.\\n * @notice Changing this value does not change the terms of existing loans for this market.\\n * @param _marketId The ID of a market.\\n * @param _paymentCycleType Cycle type (seconds or monthly)\\n * @param _duration Delinquency duration for new loans\\n */\\n function setPaymentCycle(\\n uint256 _marketId,\\n PaymentCycleType _paymentCycleType,\\n uint32 _duration\\n ) public ownsMarket(_marketId) {\\n require(\\n (_paymentCycleType == PaymentCycleType.Seconds) ||\\n (_paymentCycleType == PaymentCycleType.Monthly &&\\n _duration == 0),\\n \\\"monthly payment cycle duration cannot be set\\\"\\n );\\n Marketplace storage market = markets[_marketId];\\n uint32 duration = _paymentCycleType == PaymentCycleType.Seconds\\n ? _duration\\n : 30 days;\\n if (\\n _paymentCycleType != market.paymentCycleType ||\\n duration != market.paymentCycleDuration\\n ) {\\n markets[_marketId].paymentCycleType = _paymentCycleType;\\n markets[_marketId].paymentCycleDuration = duration;\\n\\n emit SetPaymentCycle(_marketId, _paymentCycleType, duration);\\n }\\n }\\n\\n /**\\n * @notice Sets the duration of new loans for this market before they turn defaulted.\\n * @notice Changing this value does not change the terms of existing loans for this market.\\n * @param _marketId The ID of a market.\\n * @param _duration Default duration for new loans\\n */\\n function setPaymentDefaultDuration(uint256 _marketId, uint32 _duration)\\n public\\n ownsMarket(_marketId)\\n {\\n if (_duration != markets[_marketId].paymentDefaultDuration) {\\n markets[_marketId].paymentDefaultDuration = _duration;\\n\\n emit SetPaymentDefaultDuration(_marketId, _duration);\\n }\\n }\\n\\n function setBidExpirationTime(uint256 _marketId, uint32 _duration)\\n public\\n ownsMarket(_marketId)\\n {\\n if (_duration != markets[_marketId].bidExpirationTime) {\\n markets[_marketId].bidExpirationTime = _duration;\\n\\n emit SetBidExpirationTime(_marketId, _duration);\\n }\\n }\\n\\n /**\\n * @notice Sets the fee for the market.\\n * @param _marketId The ID of a market.\\n * @param _newPercent The percentage fee in basis points.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setMarketFeePercent(uint256 _marketId, uint16 _newPercent)\\n public\\n ownsMarket(_marketId)\\n {\\n require(_newPercent >= 0 && _newPercent <= 10000, \\\"invalid percent\\\");\\n if (_newPercent != markets[_marketId].marketplaceFeePercent) {\\n markets[_marketId].marketplaceFeePercent = _newPercent;\\n emit SetMarketFee(_marketId, _newPercent);\\n }\\n }\\n\\n /**\\n * @notice Set the payment type for the market.\\n * @param _marketId The ID of the market.\\n * @param _newPaymentType The payment type for the market.\\n */\\n function setMarketPaymentType(\\n uint256 _marketId,\\n PaymentType _newPaymentType\\n ) public ownsMarket(_marketId) {\\n if (_newPaymentType != markets[_marketId].paymentType) {\\n markets[_marketId].paymentType = _newPaymentType;\\n emit SetMarketPaymentType(_marketId, _newPaymentType);\\n }\\n }\\n\\n /**\\n * @notice Enable/disables market whitelist for lenders.\\n * @param _marketId The ID of a market.\\n * @param _required Boolean indicating if the market requires whitelist.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setLenderAttestationRequired(uint256 _marketId, bool _required)\\n public\\n ownsMarket(_marketId)\\n {\\n if (_required != markets[_marketId].lenderAttestationRequired) {\\n markets[_marketId].lenderAttestationRequired = _required;\\n emit SetMarketLenderAttestation(_marketId, _required);\\n }\\n }\\n\\n /**\\n * @notice Enable/disables market whitelist for borrowers.\\n * @param _marketId The ID of a market.\\n * @param _required Boolean indicating if the market requires whitelist.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setBorrowerAttestationRequired(uint256 _marketId, bool _required)\\n public\\n ownsMarket(_marketId)\\n {\\n if (_required != markets[_marketId].borrowerAttestationRequired) {\\n markets[_marketId].borrowerAttestationRequired = _required;\\n emit SetMarketBorrowerAttestation(_marketId, _required);\\n }\\n }\\n\\n /**\\n * @notice Gets the data associated with a market.\\n * @param _marketId The ID of a market.\\n */\\n function getMarketData(uint256 _marketId)\\n public\\n view\\n returns (\\n address owner,\\n uint32 paymentCycleDuration,\\n uint32 paymentDefaultDuration,\\n uint32 loanExpirationTime,\\n string memory metadataURI,\\n uint16 marketplaceFeePercent,\\n bool lenderAttestationRequired\\n )\\n {\\n return (\\n markets[_marketId].owner,\\n markets[_marketId].paymentCycleDuration,\\n markets[_marketId].paymentDefaultDuration,\\n markets[_marketId].bidExpirationTime,\\n markets[_marketId].metadataURI,\\n markets[_marketId].marketplaceFeePercent,\\n markets[_marketId].lenderAttestationRequired\\n );\\n }\\n\\n /**\\n * @notice Gets the attestation requirements for a given market.\\n * @param _marketId The ID of the market.\\n */\\n function getMarketAttestationRequirements(uint256 _marketId)\\n public\\n view\\n returns (\\n bool lenderAttestationRequired,\\n bool borrowerAttestationRequired\\n )\\n {\\n return (\\n markets[_marketId].lenderAttestationRequired,\\n markets[_marketId].borrowerAttestationRequired\\n );\\n }\\n\\n /**\\n * @notice Gets the address of a market's owner.\\n * @param _marketId The ID of a market.\\n * @return The address of a market's owner.\\n */\\n function getMarketOwner(uint256 _marketId)\\n public\\n view\\n override\\n returns (address)\\n {\\n return markets[_marketId].owner;\\n }\\n\\n /**\\n * @notice Gets the fee recipient of a market.\\n * @param _marketId The ID of a market.\\n * @return The address of a market's fee recipient.\\n */\\n function getMarketFeeRecipient(uint256 _marketId)\\n public\\n view\\n override\\n returns (address)\\n {\\n address recipient = markets[_marketId].feeRecipient;\\n\\n if (recipient == address(0)) {\\n return markets[_marketId].owner;\\n }\\n\\n return recipient;\\n }\\n\\n /**\\n * @notice Gets the metadata URI of a market.\\n * @param _marketId The ID of a market.\\n * @return URI of a market's metadata.\\n */\\n function getMarketURI(uint256 _marketId)\\n public\\n view\\n override\\n returns (string memory)\\n {\\n return markets[_marketId].metadataURI;\\n }\\n\\n /**\\n * @notice Gets the loan delinquent duration of a market.\\n * @param _marketId The ID of a market.\\n * @return Duration of a loan until it is delinquent.\\n * @return The type of payment cycle for loans in the market.\\n */\\n function getPaymentCycle(uint256 _marketId)\\n public\\n view\\n override\\n returns (uint32, PaymentCycleType)\\n {\\n return (\\n markets[_marketId].paymentCycleDuration,\\n markets[_marketId].paymentCycleType\\n );\\n }\\n\\n /**\\n * @notice Gets the loan default duration of a market.\\n * @param _marketId The ID of a market.\\n * @return Duration of a loan repayment interval until it is default.\\n */\\n function getPaymentDefaultDuration(uint256 _marketId)\\n public\\n view\\n override\\n returns (uint32)\\n {\\n return markets[_marketId].paymentDefaultDuration;\\n }\\n\\n /**\\n * @notice Get the payment type of a market.\\n * @param _marketId the ID of the market.\\n * @return The type of payment for loans in the market.\\n */\\n function getPaymentType(uint256 _marketId)\\n public\\n view\\n override\\n returns (PaymentType)\\n {\\n return markets[_marketId].paymentType;\\n }\\n\\n function getBidExpirationTime(uint256 marketId)\\n public\\n view\\n override\\n returns (uint32)\\n {\\n return markets[marketId].bidExpirationTime;\\n }\\n\\n /**\\n * @notice Gets the marketplace fee in basis points\\n * @param _marketId The ID of a market.\\n * @return fee in basis points\\n */\\n function getMarketplaceFee(uint256 _marketId)\\n public\\n view\\n override\\n returns (uint16 fee)\\n {\\n return markets[_marketId].marketplaceFeePercent;\\n }\\n\\n /**\\n * @notice Checks if a lender has been attested and added to a market.\\n * @param _marketId The ID of a market.\\n * @param _lenderAddress Address to check.\\n * @return isVerified_ Boolean indicating if a lender has been added to a market.\\n * @return uuid_ Bytes32 representing the UUID of the lender.\\n */\\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\\n public\\n view\\n override\\n returns (bool isVerified_, bytes32 uuid_)\\n {\\n return\\n _isVerified(\\n _lenderAddress,\\n markets[_marketId].lenderAttestationRequired,\\n markets[_marketId].lenderAttestationIds,\\n markets[_marketId].verifiedLendersForMarket\\n );\\n }\\n\\n /**\\n * @notice Checks if a borrower has been attested and added to a market.\\n * @param _marketId The ID of a market.\\n * @param _borrowerAddress Address of the borrower to check.\\n * @return isVerified_ Boolean indicating if a borrower has been added to a market.\\n * @return uuid_ Bytes32 representing the UUID of the borrower.\\n */\\n function isVerifiedBorrower(uint256 _marketId, address _borrowerAddress)\\n public\\n view\\n override\\n returns (bool isVerified_, bytes32 uuid_)\\n {\\n return\\n _isVerified(\\n _borrowerAddress,\\n markets[_marketId].borrowerAttestationRequired,\\n markets[_marketId].borrowerAttestationIds,\\n markets[_marketId].verifiedBorrowersForMarket\\n );\\n }\\n\\n /**\\n * @notice Gets addresses of all attested lenders.\\n * @param _marketId The ID of a market.\\n * @param _page Page index to start from.\\n * @param _perPage Number of items in a page to return.\\n * @return Array of addresses that have been added to a market.\\n */\\n function getAllVerifiedLendersForMarket(\\n uint256 _marketId,\\n uint256 _page,\\n uint256 _perPage\\n ) public view returns (address[] memory) {\\n EnumerableSet.AddressSet storage set = markets[_marketId]\\n .verifiedLendersForMarket;\\n\\n return _getStakeholdersForMarket(set, _page, _perPage);\\n }\\n\\n /**\\n * @notice Gets addresses of all attested borrowers.\\n * @param _marketId The ID of the market.\\n * @param _page Page index to start from.\\n * @param _perPage Number of items in a page to return.\\n * @return Array of addresses that have been added to a market.\\n */\\n function getAllVerifiedBorrowersForMarket(\\n uint256 _marketId,\\n uint256 _page,\\n uint256 _perPage\\n ) public view returns (address[] memory) {\\n EnumerableSet.AddressSet storage set = markets[_marketId]\\n .verifiedBorrowersForMarket;\\n return _getStakeholdersForMarket(set, _page, _perPage);\\n }\\n\\n /**\\n * @notice Sets multiple market settings for a given market.\\n * @param _marketId The ID of a market.\\n * @param _paymentCycleDuration Delinquency duration for new loans\\n * @param _newPaymentType The payment type for the market.\\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\\n * @param _paymentDefaultDuration Default duration for new loans\\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\\n * @param _metadataURI A URI that points to a market's metadata.\\n */\\n function _setMarketSettings(\\n uint256 _marketId,\\n uint32 _paymentCycleDuration,\\n PaymentType _newPaymentType,\\n PaymentCycleType _paymentCycleType,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _borrowerAttestationRequired,\\n bool _lenderAttestationRequired,\\n string calldata _metadataURI\\n ) internal {\\n setMarketURI(_marketId, _metadataURI);\\n setPaymentDefaultDuration(_marketId, _paymentDefaultDuration);\\n setBidExpirationTime(_marketId, _bidExpirationTime);\\n setMarketFeePercent(_marketId, _feePercent);\\n setLenderAttestationRequired(_marketId, _lenderAttestationRequired);\\n setBorrowerAttestationRequired(_marketId, _borrowerAttestationRequired);\\n setMarketPaymentType(_marketId, _newPaymentType);\\n setPaymentCycle(_marketId, _paymentCycleType, _paymentCycleDuration);\\n }\\n\\n /**\\n * @notice Gets addresses of all attested relevant stakeholders.\\n * @param _set The stored set of stakeholders to index from.\\n * @param _page Page index to start from.\\n * @param _perPage Number of items in a page to return.\\n * @return stakeholders_ Array of addresses that have been added to a market.\\n */\\n function _getStakeholdersForMarket(\\n EnumerableSet.AddressSet storage _set,\\n uint256 _page,\\n uint256 _perPage\\n ) internal view returns (address[] memory stakeholders_) {\\n uint256 len = _set.length();\\n\\n uint256 start = _page * _perPage;\\n if (start <= len) {\\n uint256 end = start + _perPage;\\n // Ensure we do not go out of bounds\\n if (end > len) {\\n end = len;\\n }\\n\\n stakeholders_ = new address[](end - start);\\n for (uint256 i = start; i < end; i++) {\\n stakeholders_[i] = _set.at(i);\\n }\\n }\\n }\\n\\n /* Internal Functions */\\n\\n /**\\n * @notice Adds a stakeholder (lender or borrower) to a market.\\n * @param _marketId The market ID to add a borrower to.\\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\\n * @param _expirationTime The expiration time of the attestation.\\n * @param _expirationTime The expiration time of the attestation.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n */\\n function _attestStakeholder(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n uint256 _expirationTime,\\n bool _isLender\\n )\\n internal\\n withAttestingSchema(\\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\\n )\\n {\\n require(\\n _msgSender() == markets[_marketId].owner,\\n \\\"Not the market owner\\\"\\n );\\n\\n // Submit attestation for borrower to join a market\\n bytes32 uuid = tellerAS.attest(\\n _stakeholderAddress,\\n _attestingSchemaId, // set by the modifier\\n _expirationTime,\\n 0,\\n abi.encode(_marketId, _stakeholderAddress)\\n );\\n _attestStakeholderVerification(\\n _marketId,\\n _stakeholderAddress,\\n uuid,\\n _isLender\\n );\\n }\\n\\n /**\\n * @notice Adds a stakeholder (lender or borrower) to a market via delegated attestation.\\n * @dev The signature must match that of the market owner.\\n * @param _marketId The market ID to add a lender to.\\n * @param _stakeholderAddress The address of the lender to add to the market.\\n * @param _expirationTime The expiration time of the attestation.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n * @param _v Signature value\\n * @param _r Signature value\\n * @param _s Signature value\\n */\\n function _attestStakeholderViaDelegation(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n uint256 _expirationTime,\\n bool _isLender,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n )\\n internal\\n withAttestingSchema(\\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\\n )\\n {\\n // NOTE: block scope to prevent stack too deep!\\n bytes32 uuid;\\n {\\n bytes memory data = abi.encode(_marketId, _stakeholderAddress);\\n address attestor = markets[_marketId].owner;\\n // Submit attestation for stakeholder to join a market (attestation must be signed by market owner)\\n uuid = tellerAS.attestByDelegation(\\n _stakeholderAddress,\\n _attestingSchemaId, // set by the modifier\\n _expirationTime,\\n 0,\\n data,\\n attestor,\\n _v,\\n _r,\\n _s\\n );\\n }\\n _attestStakeholderVerification(\\n _marketId,\\n _stakeholderAddress,\\n uuid,\\n _isLender\\n );\\n }\\n\\n /**\\n * @notice Adds a stakeholder (borrower/lender) to a market.\\n * @param _marketId The market ID to add a stakeholder to.\\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\\n * @param _uuid The UUID of the attestation created.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n */\\n function _attestStakeholderVerification(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n bytes32 _uuid,\\n bool _isLender\\n ) internal {\\n if (_isLender) {\\n // Store the lender attestation ID for the market ID\\n markets[_marketId].lenderAttestationIds[\\n _stakeholderAddress\\n ] = _uuid;\\n // Add lender address to market set\\n markets[_marketId].verifiedLendersForMarket.add(\\n _stakeholderAddress\\n );\\n\\n emit LenderAttestation(_marketId, _stakeholderAddress);\\n } else {\\n // Store the lender attestation ID for the market ID\\n markets[_marketId].borrowerAttestationIds[\\n _stakeholderAddress\\n ] = _uuid;\\n // Add lender address to market set\\n markets[_marketId].verifiedBorrowersForMarket.add(\\n _stakeholderAddress\\n );\\n\\n emit BorrowerAttestation(_marketId, _stakeholderAddress);\\n }\\n }\\n\\n /**\\n * @notice Removes a stakeholder from an market.\\n * @dev The caller must be the market owner.\\n * @param _marketId The market ID to remove the borrower from.\\n * @param _stakeholderAddress The address of the borrower to remove from the market.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n */\\n function _revokeStakeholder(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n bool _isLender\\n ) internal {\\n require(\\n _msgSender() == markets[_marketId].owner,\\n \\\"Not the market owner\\\"\\n );\\n\\n bytes32 uuid = _revokeStakeholderVerification(\\n _marketId,\\n _stakeholderAddress,\\n _isLender\\n );\\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\\n // tellerAS.revoke(uuid);\\n }\\n\\n /**\\n * @notice Removes a stakeholder from an market via delegated revocation.\\n * @param _marketId The market ID to remove the borrower from.\\n * @param _stakeholderAddress The address of the borrower to remove from the market.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n * @param _v Signature value\\n * @param _r Signature value\\n * @param _s Signature value\\n */\\n function _revokeStakeholderViaDelegation(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n bool _isLender,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) internal {\\n bytes32 uuid = _revokeStakeholderVerification(\\n _marketId,\\n _stakeholderAddress,\\n _isLender\\n );\\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\\n // address attestor = markets[_marketId].owner;\\n // tellerAS.revokeByDelegation(uuid, attestor, _v, _r, _s);\\n }\\n\\n /**\\n * @notice Removes a stakeholder (borrower/lender) from a market.\\n * @param _marketId The market ID to remove the lender from.\\n * @param _stakeholderAddress The address of the stakeholder to remove from the market.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n * @return uuid_ The ID of the previously verified attestation.\\n */\\n function _revokeStakeholderVerification(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n bool _isLender\\n ) internal returns (bytes32 uuid_) {\\n if (_isLender) {\\n uuid_ = markets[_marketId].lenderAttestationIds[\\n _stakeholderAddress\\n ];\\n // Remove lender address from market set\\n markets[_marketId].verifiedLendersForMarket.remove(\\n _stakeholderAddress\\n );\\n\\n emit LenderRevocation(_marketId, _stakeholderAddress);\\n } else {\\n uuid_ = markets[_marketId].borrowerAttestationIds[\\n _stakeholderAddress\\n ];\\n // Remove borrower address from market set\\n markets[_marketId].verifiedBorrowersForMarket.remove(\\n _stakeholderAddress\\n );\\n\\n emit BorrowerRevocation(_marketId, _stakeholderAddress);\\n }\\n }\\n\\n /**\\n * @notice Checks if a stakeholder has been attested and added to a market.\\n * @param _stakeholderAddress Address of the stakeholder to check.\\n * @param _attestationRequired Stored boolean indicating if attestation is required for the stakeholder class.\\n * @param _stakeholderAttestationIds Mapping of attested Ids for the stakeholder class.\\n */\\n function _isVerified(\\n address _stakeholderAddress,\\n bool _attestationRequired,\\n mapping(address => bytes32) storage _stakeholderAttestationIds,\\n EnumerableSet.AddressSet storage _verifiedStakeholderForMarket\\n ) internal view returns (bool isVerified_, bytes32 uuid_) {\\n if (_attestationRequired) {\\n isVerified_ =\\n _verifiedStakeholderForMarket.contains(_stakeholderAddress) &&\\n tellerAS.isAttestationActive(\\n _stakeholderAttestationIds[_stakeholderAddress]\\n );\\n uuid_ = _stakeholderAttestationIds[_stakeholderAddress];\\n } else {\\n isVerified_ = true;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x81b5568ae3770dadab527bed63a37b5c1029047daf3bbeae01d07e44176edf68\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x549d37cb1390adad543f2e7b1ad46104c4326c4af7dbccda35116833103a6465\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b506132cf806100206000396000f3fe6080604052600436106102975760003560e01c80637f027a1a1161015a578063bd536e6e116100c1578063d6e794dd1161007a578063d6e794dd14610956578063ddfafef61461099d578063e4050e29146109bd578063e690e84e146109dd578063ec979082146109fd578063f9fa934514610a1357600080fd5b8063bd536e6e1461088f578063be99279b146108af578063bfacba3d146108cf578063c4d66de814610902578063c995cddc14610922578063ce46e0461461094257600080fd5b806397eb575b1161011357806397eb575b14610796578063a5630f19146107b6578063aa542fa51461080f578063ae4180951461082f578063b6b6d77f1461084f578063bc4c34951461086f57600080fd5b80637f027a1a1461069d5780638b636632146106bd5780638b975cda146106dd5780638eff9ea4146106fd578063947a75b41461076357806394e8e97e1461077657600080fd5b80633ef19a9b116101fe578063583b16ae116101b7578063583b16ae146105e75780636054b175146106075780636441379614610627578063679700d9146106475780637694d2ec1461065d5780637cfc18181461067d57600080fd5b80633ef19a9b1461053c5780633fa7f6881461055c5780634148f94c1461057c578063455154e514610591578063532f5694146105b157806354fd4d50146105d157600080fd5b80631db2b0d9116102505780631db2b0d91461043d5780631ebc7da81461046a5780632f1be8f91461048a578063344e553d146104aa5780633c0db788146104d85780633d369029146104ee57600080fd5b8063066e7513146102bc578063082fc54d146102f85780630a2e98e41461034a57806311bed5bb146103925780631a4808d2146103d05780631cc672df146103fd57600080fd5b366102b757604051631574f9f360e01b815260040160405180910390fd5b005b600080fd5b3480156102c857600080fd5b506102dc6102d73660046127b5565b610a33565b6040805192151583526020830191909152015b60405180910390f35b34801561030457600080fd5b506103356103133660046127e5565b600090815260026020526040902060060154600160401b900463ffffffff1690565b60405163ffffffff90911681526020016102ef565b34801561035657600080fd5b5061037f6103653660046127e5565b6000908152600260208190526040909120015461ffff1690565b60405161ffff90911681526020016102ef565b34801561039e57600080fd5b506103356103ad3660046127e5565b600090815260026020526040902060060154640100000000900463ffffffff1690565b3480156103dc57600080fd5b506103f06103eb3660046127e5565b610a73565b6040516102ef919061284b565b34801561040957600080fd5b5061042d6104183660046127e5565b60009081526008602052604090205460ff1690565b60405190151581526020016102ef565b34801561044957600080fd5b5061045d61045836600461285e565b610b18565b6040516102ef919061288a565b34801561047657600080fd5b506102b56104853660046127b5565b610b42565b34801561049657600080fd5b506102b56104a53660046128f0565b610bee565b3480156104b657600080fd5b506104ca6104c536600461298b565b610cbe565b6040519081526020016102ef565b3480156104e457600080fd5b506104ca60015481565b3480156104fa57600080fd5b506105246105093660046127e5565b6000908152600260205260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016102ef565b34801561054857600080fd5b506102dc6105573660046127b5565b610ce3565b34801561056857600080fd5b506102b5610577366004612a85565b610d17565b34801561058857600080fd5b506104ca600881565b34801561059d57600080fd5b506102b56105ac3660046127b5565b610d2f565b3480156105bd57600080fd5b506102b56105cc366004612adf565b610d3f565b3480156105dd57600080fd5b506104ca60075481565b3480156105f357600080fd5b506102b5610602366004612a85565b610e3c565b34801561061357600080fd5b506102b5610622366004612b2b565b610e4c565b34801561063357600080fd5b506105246106423660046127e5565b610e62565b34801561065357600080fd5b506104ca60065481565b34801561066957600080fd5b5061045d61067836600461285e565b610ea5565b34801561068957600080fd5b506102b56106983660046127b5565b610ec4565b3480156106a957600080fd5b506102b56106b83660046127e5565b610f5b565b3480156106c957600080fd5b506102b56106d83660046127b5565b610fc7565b3480156106e957600080fd5b506102b56106f8366004612b7b565b610fd3565b34801561070957600080fd5b5061074c6107183660046127e5565b6000908152600260208190526040909120908101546006909101546201000090910460ff90811692600160601b9092041690565b6040805192151583529015156020830152016102ef565b61042d610771366004612c18565b61102c565b34801561078257600080fd5b506102b5610791366004612cb8565b6110da565b3480156107a257600080fd5b506102b56107b1366004612cdd565b611197565b3480156107c257600080fd5b506108016107d13660046127e5565b60009081526002602052604090206006810154600a9091015463ffffffff90911691600160a81b90910460ff1690565b6040516102ef929190612d49565b34801561081b57600080fd5b506102b561082a366004612d6c565b6111a4565b34801561083b57600080fd5b506102b561084a3660046127e5565b61128a565b34801561085b57600080fd5b506102b561086a366004612d91565b611323565b34801561087b57600080fd5b506102b561088a366004612b2b565b61141b565b34801561089b57600080fd5b506102b56108aa3660046128f0565b61142a565b3480156108bb57600080fd5b506102b56108ca366004612cb8565b6114f7565b3480156108db57600080fd5b506108ef6108ea3660046127e5565b6115b6565b6040516102ef9796959493929190612db4565b34801561090e57600080fd5b506102b561091d366004612e13565b6116c8565b34801561092e57600080fd5b506102b561093d3660046127e5565b611a61565b34801561094e57600080fd5b50600061042d565b34801561096257600080fd5b506109906109713660046127e5565b6000908152600260205260409020600a0154600160a01b900460ff1690565b6040516102ef9190612e30565b3480156109a957600080fd5b50600954610524906001600160a01b031681565b3480156109c957600080fd5b506102b56109d8366004612cdd565b611aac565b3480156109e957600080fd5b506102b56109f8366004612e43565b611ab9565b348015610a0957600080fd5b506104ca60045481565b348015610a1f57600080fd5b506104ca610a2e366004612e81565b611cb9565b600082815260026020526040812060068101548291610a67918591600160601b90910460ff16906009810190600701611cdd565b915091505b9250929050565b6000818152600260205260409020600101805460609190610a9390612f42565b80601f0160208091040260200160405190810160405280929190818152602001828054610abf90612f42565b8015610b0c5780601f10610ae157610100808354040283529160200191610b0c565b820191906000526020600020905b815481529060010190602001808311610aef57829003601f168201915b50505050509050919050565b6000838152600260205260409020606090600301610b37818585611db7565b9150505b9392505050565b60008281526002602052604090205482906001600160a01b03163314610b835760405162461bcd60e51b8152600401610b7a90612f7d565b60405180910390fd5b600083815260026020908152604091829020600a0180546001600160a01b0319166001600160a01b0386169081179091558251868152918201527ffc7e26c4fffcd77fc52c81b32a6a6b7838b5592ced8c14c1a46e2b4a322c568a91015b60405180910390a1505050565b60008281526002602052604090205482906001600160a01b03163314610c265760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602052604090206006015463ffffffff8381166401000000009092041614610cb957600083815260026020908152604091829020600601805467ffffffff00000000191664010000000063ffffffff8716908102919091179091558251868152918201527f3e49e2efeacab7e8344acd4e7940449bf62039aa3734c34fa6d3525654be81019101610be1565b505050565b6000610cd38c8c8c8c8c8c8c8c8c8c8c611e9e565b9c9b505050505050505050505050565b60008281526002602081905260408220908101548291610a679185916201000090910460ff16906005810190600301611cdd565b610d278686866001878787611f90565b505050505050565b610d3b828260006120d5565b5050565b60008381526002602052604090205483906001600160a01b03163314610d775760405162461bcd60e51b8152600401610b7a90612f7d565b6000848152600260209081526040918290209151610d99926001019101612fa4565b604051602081830303815290604052805190602001208383604051602001610dc2929190613040565b6040516020818303038152906040528051906020012014610e36576000848152600260205260409020610df9906001018484612704565b507f6218b53065a32d32b3f52d9ad728c1b826a2aae15fc1ee92f83836debbcc1029848484604051610e2d93929190613050565b60405180910390a15b50505050565b610d278686866000878787611f90565b610e5b85856001868686612148565b5050505050565b6000818152600260205260408120600a01546001600160a01b031680610e9f5750506000908152600260205260409020546001600160a01b031690565b92915050565b6000838152600260205260409020606090600701610b37818585611db7565b60008281526002602052604090205482906001600160a01b03163314610efc5760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251868152918201527ff68f2d4b68e0d54a81a3b8e53403ddec34a1e288cf6a6f6b3621c0a47b6e36f99101610be1565b6000818152600260205260408120610f76906003013361215f565b90508015610d3b577f55e867ccc9ac324e2c193ce4ed25397fb890213c704685f2c9fbe5bd7507298682335b604080519283526001600160a01b039091166020830152015b60405180910390a15050565b610d3b828260016120d5565b60008b8152600260205260409020548b906001600160a01b0316331461100b5760405162461bcd60e51b8152600401610b7a90612f7d565b61101e8c8c8c8c8c8c8c8c8c8c8c612174565b505050505050505050505050565b60008087873060405160200161104493929190613086565b60408051601f198184030181529190528051602090910120905060008061106d878901896127b5565b91509150826005541480156110935750806001600160a01b03168b6001600160a01b0316145b80156110b857506000828152600260205260409020546001600160a01b038681169116145b806110cb57506001600160a01b03851630145b9b9a5050505050505050505050565b60008281526002602052604090205482906001600160a01b031633146111125760405162461bcd60e51b8152600401610b7a90612f7d565b6000838152600260208190526040909120015462010000900460ff16151582151514610cb957600083815260026020818152604092839020909101805462ff0000191662010000861515908102919091179091558251868152918201527f4666a8529dea37114f2ecc11706d613f7a59a7967f8467da6877820b83d405a19101610be1565b610cb983838360016121d3565b60008281526002602052604090205482906001600160a01b031633146111dc5760405162461bcd60e51b8152600401610b7a90612f7d565b6000838152600260205260409020600a0154600160a01b900460ff16600181111561120957611209612d15565b82600181111561121b5761121b612d15565b14610cb9576000838152600260205260409020600a01805483919060ff60a01b1916600160a01b83600181111561125457611254612d15565b02179055507ff81d9cc918f72edfc74e6b61d4e19ef9a739e94a0e9715b108e6af62275142ef8383604051610be19291906130ac565b60008181526002602052604090205481906001600160a01b031633146112c25760405162461bcd60e51b8152600401610b7a90612f7d565b60008281526008602052604090205460ff16610d3b5760008281526008602052604090819020805460ff19166001179055517f9dc30b8eda31a6a144e092e5de600955523a6a925cc15cc1d1b9b4872cfa615590610fbb9084815260200190565b60008281526002602052604090205482906001600160a01b0316331461135b5760405162461bcd60e51b8152600401610b7a90612f7d565b6127108261ffff1611156113a35760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b6044820152606401610b7a565b6000838152600260208190526040909120015461ffff838116911614610cb957600083815260026020818152604092839020909101805461ffff191661ffff86169081179091558251868152918201527f9c6f3e426c05d512408d4ecf517e5155756288155088ad45a81c0e111e3d18549101610be1565b610e5b85856000868686612148565b60008281526002602052604090205482906001600160a01b031633146114625760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602052604090206006015463ffffffff838116600160401b9092041614610cb95760008381526002602090815260409182902060060180546bffffffff00000000000000001916600160401b63ffffffff8716908102919091179091558251868152918201527ff0275a50e761f3b1635fa59ce199b1f2268b3fcb7fbdfb18c21aa3d2d78aa7b79101610be1565b60008281526002602052604090205482906001600160a01b0316331461152f5760405162461bcd60e51b8152600401610b7a90612f7d565b600083815260026020526040902060060154600160601b900460ff16151582151514610cb957600083815260026020908152604091829020600601805460ff60601b1916600160601b861515908102919091179091558251868152918201527fc906280af595fe94779bb9a972f24fe4e0ed7f76bebb4ee0eb9a5f30d6dd4c879101610be1565b60008181526002602081905260408220805460068201549282015460019092018054859485948594606094869485946001600160a01b039093169363ffffffff808516946401000000008104821694600160401b90910490911692909161ffff8116916201000090910460ff1690839061162f90612f42565b80601f016020809104026020016040519081016040528092919081815260200182805461165b90612f42565b80156116a85780601f1061167d576101008083540402835291602001916116a8565b820191906000526020600020905b81548152906001019060200180831161168b57829003601f168201915b505050505092509650965096509650965096509650919395979092949650565b600054610100900460ff16158080156116e85750600054600160ff909116105b806117025750303b158015611702575060005460ff166001145b6117655760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b7a565b6000805460ff191660011790558015611788576000805461ff0019166101001790555b600980546001600160a01b0319166001600160a01b038416908117909155604080516381fa6cd360e01b815290516381fa6cd391600480820192602092909190829003018186803b1580156117dc57600080fd5b505afa1580156117f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181491906130bc565b6040805163a99e7e2960e01b81526004810191909152602960448201527f2875696e74323536206d61726b657449642c2061646472657373206c656e646560648201526872416464726573732960b81b60848201523060248201526001600160a01b03919091169063a99e7e299060a401602060405180830381600087803b15801561189f57600080fd5b505af11580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d791906130d9565b600155600954604080516381fa6cd360e01b815290516001600160a01b03909216916381fa6cd391600480820192602092909190829003018186803b15801561191f57600080fd5b505afa158015611933573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195791906130bc565b6040805163a99e7e2960e01b81526004810191909152602b60448201527f2875696e74323536206d61726b657449642c206164647265737320626f72726f60648201526a776572416464726573732960a81b60848201523060248201526001600160a01b03919091169063a99e7e299060a401602060405180830381600087803b1580156119e457600080fd5b505af11580156119f8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1c91906130d9565b6006558015610d3b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610fbb565b6000818152600260205260408120611a7c906007013361215f565b90508015610d3b577f914ccbaf2f5c9c2f4b7c6be3497b6b2ceb6ce2d050aec6eb2e0e31b8f9f67f0c8233610fa2565b610cb983838360006121d3565b60008381526002602052604090205483906001600160a01b03163314611af15760405162461bcd60e51b8152600401610b7a90612f7d565b6000836001811115611b0557611b05612d15565b1480611b3157506001836001811115611b2057611b20612d15565b148015611b31575063ffffffff8216155b611b925760405162461bcd60e51b815260206004820152602c60248201527f6d6f6e74686c79207061796d656e74206379636c65206475726174696f6e206360448201526b185b9b9bdd081899481cd95d60a21b6064820152608401610b7a565b60008481526002602052604081209080856001811115611bb457611bb4612d15565b14611bc25762278d00611bc4565b835b600a830154909150600160a81b900460ff166001811115611be757611be7612d15565b856001811115611bf957611bf9612d15565b141580611c135750600682015463ffffffff828116911614155b15610d27576000868152600260205260409020600a01805486919060ff60a81b1916600160a81b836001811115611c4c57611c4c612d15565b021790555060008681526002602052604090819020600601805463ffffffff191663ffffffff8416179055517fbb20033c58b125e31641bfd5e2f4bd906d684e27472fab0648527cc39cb2918c90611ca9908890889085906130f2565b60405180910390a1505050505050565b6000611ccf8a8a8a8a8a8a8a6000808c8c611e9e565b9a9950505050505050505050565b6000808415611da957611cf08387612330565b8015611d8657506009546001600160a01b03878116600090815260208790526040908190205490516330cd251f60e21b8152600481019190915291169063c334947c9060240160206040518083038186803b158015611d4e57600080fd5b505afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d86919061311c565b6001600160a01b0387166000908152602086905260409020549092509050611dae565b600191505b94509492505050565b60606000611dc485612352565b90506000611dd2848661314f565b9050818111611e95576000611de7858361316e565b905082811115611df45750815b611dfe8282613186565b67ffffffffffffffff811115611e1657611e1661319d565b604051908082528060200260200182016040528015611e3f578160200160208202803683370190505b509350815b81811015611e9257611e56888261235c565b858281518110611e6857611e686131b3565b6001600160a01b039092166020928302919091019091015280611e8a816131c9565b915050611e44565b50505b50509392505050565b60006001600160a01b038c16611eee5760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206f776e6572206164647265737360581b6044820152606401610b7a565b600460008154611efd906131c9565b9182905550600081815260026020526040902080546001600160a01b0319166001600160a01b038f161790559050611f3e818c87878e8e8e8d8f8c8c612174565b8b6001600160a01b03167fa69fa77c6a90b171cf4e3d9a9dd6c4e56fbd1fbbdcf3925eaf600ccaa917feab82604051611f7991815260200190565b60405180910390a29b9a5050505050505050505050565b83611f9d57600654611fa1565b6001545b806005819055506000808989604051602001611fd09291909182526001600160a01b0316602082015260400190565b60405160208183030381529060405290506000600260008c815260200190815260200160002060000160009054906101000a90046001600160a01b03169050600960009054906101000a90046001600160a01b03166001600160a01b031663930ed0138b6005548c600087878e8e8e6040518a63ffffffff1660e01b8152600401612063999897969594939291906131e4565b602060405180830381600087803b15801561207d57600080fd5b505af1158015612091573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b591906130d9565b925050506120c589898389612368565b5050600060055550505050505050565b6000838152600260205260409020546001600160a01b0316336001600160a01b03161461213b5760405162461bcd60e51b81526020600482015260146024820152732737ba103a34329036b0b935b2ba1037bbb732b960611b6044820152606401610b7a565b6000610e5b84848461246a565b600061215587878761246a565b5050505050505050565b6000610b3b836001600160a01b03841661257a565b61217f8b8383610d3f565b6121898b88610bee565b6121938b8761142a565b61219d8b86611323565b6121a78b846110da565b6121b18b856114f7565b6121bb8b8a6111a4565b6121c68b898c611ab9565b5050505050505050505050565b806121e0576006546121e4565b6001545b60058190556000858152600260205260409020546001600160a01b0316336001600160a01b03161461224f5760405162461bcd60e51b81526020600482015260146024820152732737ba103a34329036b0b935b2ba1037bbb732b960611b6044820152606401610b7a565b6009546005546040516000926001600160a01b0316916309a954cd9188919088908690612294908d9086906020019182526001600160a01b0316602082015260400190565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016122c3959493929190613245565b602060405180830381600087803b1580156122dd57600080fd5b505af11580156122f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231591906130d9565b905061232386868386612368565b5050600060055550505050565b6001600160a01b03811660009081526001830160205260408120541515610b3b565b6000610e9f825490565b6000610b3b838361266d565b80156123f05760008481526002602081815260408084206001600160a01b038816855260058101835290842086905592879052526123a99060030184612697565b50604080518581526001600160a01b03851660208201527f75675690de0899b0b869d83b44b2d926ac594426b2a0286c478ecdf815cbd33e910160405180910390a1610e36565b60008481526002602081815260408084206001600160a01b0388168552600981018352908420869055928790525261242b9060070184612697565b50604080518581526001600160a01b03851660208201527f0c2cfc7e7a16ebee66e77fb314f4bfdb5505e33e77d41c0c60604efc70fd926b9101610e2d565b600081156124f5575060008381526002602081815260408084206001600160a01b038716855260058101835290842054938790529190526124ae906003018461215f565b50604080518581526001600160a01b03851660208201527f6e7c30dc58d3daa1458c79b66ca464f5f3d8a23d9e50eb14daf1cb0923bf2900910160405180910390a1610b3b565b5060008381526002602081815260408084206001600160a01b03871685526009810183529084205493879052919052612531906007018461215f565b50604080518581526001600160a01b03851660208201527fe76a3e8b220b622b9fc2a655ab867687a93f195809eb3639f422e60936ff7eb4910160405180910390a19392505050565b6000818152600183016020526040812054801561266357600061259e600183613186565b85549091506000906125b290600190613186565b90508181146126175760008660000182815481106125d2576125d26131b3565b90600052602060002001549050808760000184815481106125f5576125f56131b3565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061262857612628613283565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610e9f565b6000915050610e9f565b6000826000018281548110612684576126846131b3565b9060005260206000200154905092915050565b6000610b3b836001600160a01b03841660006126c6838360009081526001919091016020526040902054151590565b6126fc57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610e9f565b506000610e9f565b82805461271090612f42565b90600052602060002090601f0160209004810192826127325760008555612778565b82601f1061274b5782800160ff19823516178555612778565b82800160010185558215612778579182015b8281111561277857823582559160200191906001019061275d565b50612784929150612788565b5090565b5b808211156127845760008155600101612789565b6001600160a01b03811681146127b257600080fd5b50565b600080604083850312156127c857600080fd5b8235915060208301356127da8161279d565b809150509250929050565b6000602082840312156127f757600080fd5b5035919050565b6000815180845260005b8181101561282457602081850181015186830182015201612808565b81811115612836576000602083870101525b50601f01601f19169290920160200192915050565b602081526000610b3b60208301846127fe565b60008060006060848603121561287357600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b818110156128cb5783516001600160a01b0316835292840192918401916001016128a6565b50909695505050505050565b803563ffffffff811681146128eb57600080fd5b919050565b6000806040838503121561290357600080fd5b82359150612913602084016128d7565b90509250929050565b803561ffff811681146128eb57600080fd5b80151581146127b257600080fd5b600281106127b257600080fd5b60008083601f84011261295b57600080fd5b50813567ffffffffffffffff81111561297357600080fd5b602083019150836020828501011115610a6c57600080fd5b60008060008060008060008060008060006101408c8e0312156129ad57600080fd5b8b356129b88161279d565b9a506129c660208d016128d7565b99506129d460408d016128d7565b98506129e260608d016128d7565b97506129f060808d0161291c565b965060a08c0135612a008161292e565b955060c08c0135612a108161292e565b945060e08c0135612a208161293c565b93506101008c0135612a318161293c565b92506101208c013567ffffffffffffffff811115612a4e57600080fd5b612a5a8e828f01612949565b915080935050809150509295989b509295989b9093969950565b803560ff811681146128eb57600080fd5b60008060008060008060c08789031215612a9e57600080fd5b863595506020870135612ab08161279d565b945060408701359350612ac560608801612a74565b92506080870135915060a087013590509295509295509295565b600080600060408486031215612af457600080fd5b83359250602084013567ffffffffffffffff811115612b1257600080fd5b612b1e86828701612949565b9497909650939450505050565b600080600080600060a08688031215612b4357600080fd5b853594506020860135612b558161279d565b9350612b6360408701612a74565b94979396509394606081013594506080013592915050565b60008060008060008060008060008060006101408c8e031215612b9d57600080fd5b8b359a50612bad60208d016128d7565b995060408c0135612bbd8161293c565b985060608c0135612bcd8161293c565b9750612bdb60808d016128d7565b9650612be960a08d016128d7565b9550612bf760c08d0161291c565b945060e08c0135612c078161292e565b93506101008c0135612a318161292e565b600080600080600080600060a0888a031215612c3357600080fd5b8735612c3e8161279d565b9650602088013567ffffffffffffffff80821115612c5b57600080fd5b612c678b838c01612949565b909850965060408a0135915080821115612c8057600080fd5b50612c8d8a828b01612949565b909550935050606088013591506080880135612ca88161279d565b8091505092959891949750929550565b60008060408385031215612ccb57600080fd5b8235915060208301356127da8161292e565b600080600060608486031215612cf257600080fd5b833592506020840135612d048161279d565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b600281106127b257634e487b7160e01b600052602160045260246000fd5b63ffffffff8316815260408101612d5f83612d2b565b8260208301529392505050565b60008060408385031215612d7f57600080fd5b8235915060208301356127da8161293c565b60008060408385031215612da457600080fd5b823591506129136020840161291c565b6001600160a01b038816815263ffffffff878116602083015286811660408301528516606082015260e060808201819052600090612df4908301866127fe565b61ffff9490941660a08301525090151560c09091015295945050505050565b600060208284031215612e2557600080fd5b8135610b3b8161279d565b60208101612e3d83612d2b565b91905290565b600080600060608486031215612e5857600080fd5b833592506020840135612e6a8161293c565b9150612e78604085016128d7565b90509250925092565b60008060008060008060008060006101008a8c031215612ea057600080fd5b8935612eab8161279d565b9850612eb960208b016128d7565b9750612ec760408b016128d7565b9650612ed560608b016128d7565b9550612ee360808b0161291c565b945060a08a0135612ef38161292e565b935060c08a0135612f038161292e565b925060e08a013567ffffffffffffffff811115612f1f57600080fd5b612f2b8c828d01612949565b915080935050809150509295985092959850929598565b600181811c90821680612f5657607f821691505b60208210811415612f7757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600d908201526c2737ba103a34329037bbb732b960991b604082015260600190565b600080835481600182811c915080831680612fc057607f831692505b6020808410821415612fe057634e487b7160e01b86526022600452602486fd5b818015612ff4576001811461300557613032565b60ff19861689528489019650613032565b60008a81526020902060005b8681101561302a5781548b820152908501908301613011565b505084890196505b509498975050505050505050565b8183823760009101908152919050565b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b82815260408101612d5f83612d2b565b6000602082840312156130ce57600080fd5b8151610b3b8161279d565b6000602082840312156130eb57600080fd5b5051919050565b8381526060810161310284612d2b565b83602083015263ffffffff83166040830152949350505050565b60006020828403121561312e57600080fd5b8151610b3b8161292e565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561316957613169613139565b500290565b6000821982111561318157613181613139565b500190565b60008282101561319857613198613139565b500390565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006000198214156131dd576131dd613139565b5060010190565b600061012060018060a01b03808d1684528b60208501528a60408501528960608501528160808501526132198285018a6127fe565b971660a0840152505060ff9390931660c084015260e08301919091526101009091015295945050505050565b60018060a01b038616815284602082015283604082015282606082015260a06080820152600061327860a08301846127fe565b979650505050505050565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220411d7354c9de04260f65046876835a5dcd340ba2f2d99e737e5e544f5f25acff64736f6c63430008090033", - "deployedBytecode": "0x6080604052600436106102975760003560e01c80637f027a1a1161015a578063bd536e6e116100c1578063d6e794dd1161007a578063d6e794dd14610956578063ddfafef61461099d578063e4050e29146109bd578063e690e84e146109dd578063ec979082146109fd578063f9fa934514610a1357600080fd5b8063bd536e6e1461088f578063be99279b146108af578063bfacba3d146108cf578063c4d66de814610902578063c995cddc14610922578063ce46e0461461094257600080fd5b806397eb575b1161011357806397eb575b14610796578063a5630f19146107b6578063aa542fa51461080f578063ae4180951461082f578063b6b6d77f1461084f578063bc4c34951461086f57600080fd5b80637f027a1a1461069d5780638b636632146106bd5780638b975cda146106dd5780638eff9ea4146106fd578063947a75b41461076357806394e8e97e1461077657600080fd5b80633ef19a9b116101fe578063583b16ae116101b7578063583b16ae146105e75780636054b175146106075780636441379614610627578063679700d9146106475780637694d2ec1461065d5780637cfc18181461067d57600080fd5b80633ef19a9b1461053c5780633fa7f6881461055c5780634148f94c1461057c578063455154e514610591578063532f5694146105b157806354fd4d50146105d157600080fd5b80631db2b0d9116102505780631db2b0d91461043d5780631ebc7da81461046a5780632f1be8f91461048a578063344e553d146104aa5780633c0db788146104d85780633d369029146104ee57600080fd5b8063066e7513146102bc578063082fc54d146102f85780630a2e98e41461034a57806311bed5bb146103925780631a4808d2146103d05780631cc672df146103fd57600080fd5b366102b757604051631574f9f360e01b815260040160405180910390fd5b005b600080fd5b3480156102c857600080fd5b506102dc6102d73660046127b5565b610a33565b6040805192151583526020830191909152015b60405180910390f35b34801561030457600080fd5b506103356103133660046127e5565b600090815260026020526040902060060154600160401b900463ffffffff1690565b60405163ffffffff90911681526020016102ef565b34801561035657600080fd5b5061037f6103653660046127e5565b6000908152600260208190526040909120015461ffff1690565b60405161ffff90911681526020016102ef565b34801561039e57600080fd5b506103356103ad3660046127e5565b600090815260026020526040902060060154640100000000900463ffffffff1690565b3480156103dc57600080fd5b506103f06103eb3660046127e5565b610a73565b6040516102ef919061284b565b34801561040957600080fd5b5061042d6104183660046127e5565b60009081526008602052604090205460ff1690565b60405190151581526020016102ef565b34801561044957600080fd5b5061045d61045836600461285e565b610b18565b6040516102ef919061288a565b34801561047657600080fd5b506102b56104853660046127b5565b610b42565b34801561049657600080fd5b506102b56104a53660046128f0565b610bee565b3480156104b657600080fd5b506104ca6104c536600461298b565b610cbe565b6040519081526020016102ef565b3480156104e457600080fd5b506104ca60015481565b3480156104fa57600080fd5b506105246105093660046127e5565b6000908152600260205260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016102ef565b34801561054857600080fd5b506102dc6105573660046127b5565b610ce3565b34801561056857600080fd5b506102b5610577366004612a85565b610d17565b34801561058857600080fd5b506104ca600881565b34801561059d57600080fd5b506102b56105ac3660046127b5565b610d2f565b3480156105bd57600080fd5b506102b56105cc366004612adf565b610d3f565b3480156105dd57600080fd5b506104ca60075481565b3480156105f357600080fd5b506102b5610602366004612a85565b610e3c565b34801561061357600080fd5b506102b5610622366004612b2b565b610e4c565b34801561063357600080fd5b506105246106423660046127e5565b610e62565b34801561065357600080fd5b506104ca60065481565b34801561066957600080fd5b5061045d61067836600461285e565b610ea5565b34801561068957600080fd5b506102b56106983660046127b5565b610ec4565b3480156106a957600080fd5b506102b56106b83660046127e5565b610f5b565b3480156106c957600080fd5b506102b56106d83660046127b5565b610fc7565b3480156106e957600080fd5b506102b56106f8366004612b7b565b610fd3565b34801561070957600080fd5b5061074c6107183660046127e5565b6000908152600260208190526040909120908101546006909101546201000090910460ff90811692600160601b9092041690565b6040805192151583529015156020830152016102ef565b61042d610771366004612c18565b61102c565b34801561078257600080fd5b506102b5610791366004612cb8565b6110da565b3480156107a257600080fd5b506102b56107b1366004612cdd565b611197565b3480156107c257600080fd5b506108016107d13660046127e5565b60009081526002602052604090206006810154600a9091015463ffffffff90911691600160a81b90910460ff1690565b6040516102ef929190612d49565b34801561081b57600080fd5b506102b561082a366004612d6c565b6111a4565b34801561083b57600080fd5b506102b561084a3660046127e5565b61128a565b34801561085b57600080fd5b506102b561086a366004612d91565b611323565b34801561087b57600080fd5b506102b561088a366004612b2b565b61141b565b34801561089b57600080fd5b506102b56108aa3660046128f0565b61142a565b3480156108bb57600080fd5b506102b56108ca366004612cb8565b6114f7565b3480156108db57600080fd5b506108ef6108ea3660046127e5565b6115b6565b6040516102ef9796959493929190612db4565b34801561090e57600080fd5b506102b561091d366004612e13565b6116c8565b34801561092e57600080fd5b506102b561093d3660046127e5565b611a61565b34801561094e57600080fd5b50600061042d565b34801561096257600080fd5b506109906109713660046127e5565b6000908152600260205260409020600a0154600160a01b900460ff1690565b6040516102ef9190612e30565b3480156109a957600080fd5b50600954610524906001600160a01b031681565b3480156109c957600080fd5b506102b56109d8366004612cdd565b611aac565b3480156109e957600080fd5b506102b56109f8366004612e43565b611ab9565b348015610a0957600080fd5b506104ca60045481565b348015610a1f57600080fd5b506104ca610a2e366004612e81565b611cb9565b600082815260026020526040812060068101548291610a67918591600160601b90910460ff16906009810190600701611cdd565b915091505b9250929050565b6000818152600260205260409020600101805460609190610a9390612f42565b80601f0160208091040260200160405190810160405280929190818152602001828054610abf90612f42565b8015610b0c5780601f10610ae157610100808354040283529160200191610b0c565b820191906000526020600020905b815481529060010190602001808311610aef57829003601f168201915b50505050509050919050565b6000838152600260205260409020606090600301610b37818585611db7565b9150505b9392505050565b60008281526002602052604090205482906001600160a01b03163314610b835760405162461bcd60e51b8152600401610b7a90612f7d565b60405180910390fd5b600083815260026020908152604091829020600a0180546001600160a01b0319166001600160a01b0386169081179091558251868152918201527ffc7e26c4fffcd77fc52c81b32a6a6b7838b5592ced8c14c1a46e2b4a322c568a91015b60405180910390a1505050565b60008281526002602052604090205482906001600160a01b03163314610c265760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602052604090206006015463ffffffff8381166401000000009092041614610cb957600083815260026020908152604091829020600601805467ffffffff00000000191664010000000063ffffffff8716908102919091179091558251868152918201527f3e49e2efeacab7e8344acd4e7940449bf62039aa3734c34fa6d3525654be81019101610be1565b505050565b6000610cd38c8c8c8c8c8c8c8c8c8c8c611e9e565b9c9b505050505050505050505050565b60008281526002602081905260408220908101548291610a679185916201000090910460ff16906005810190600301611cdd565b610d278686866001878787611f90565b505050505050565b610d3b828260006120d5565b5050565b60008381526002602052604090205483906001600160a01b03163314610d775760405162461bcd60e51b8152600401610b7a90612f7d565b6000848152600260209081526040918290209151610d99926001019101612fa4565b604051602081830303815290604052805190602001208383604051602001610dc2929190613040565b6040516020818303038152906040528051906020012014610e36576000848152600260205260409020610df9906001018484612704565b507f6218b53065a32d32b3f52d9ad728c1b826a2aae15fc1ee92f83836debbcc1029848484604051610e2d93929190613050565b60405180910390a15b50505050565b610d278686866000878787611f90565b610e5b85856001868686612148565b5050505050565b6000818152600260205260408120600a01546001600160a01b031680610e9f5750506000908152600260205260409020546001600160a01b031690565b92915050565b6000838152600260205260409020606090600701610b37818585611db7565b60008281526002602052604090205482906001600160a01b03163314610efc5760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251868152918201527ff68f2d4b68e0d54a81a3b8e53403ddec34a1e288cf6a6f6b3621c0a47b6e36f99101610be1565b6000818152600260205260408120610f76906003013361215f565b90508015610d3b577f55e867ccc9ac324e2c193ce4ed25397fb890213c704685f2c9fbe5bd7507298682335b604080519283526001600160a01b039091166020830152015b60405180910390a15050565b610d3b828260016120d5565b60008b8152600260205260409020548b906001600160a01b0316331461100b5760405162461bcd60e51b8152600401610b7a90612f7d565b61101e8c8c8c8c8c8c8c8c8c8c8c612174565b505050505050505050505050565b60008087873060405160200161104493929190613086565b60408051601f198184030181529190528051602090910120905060008061106d878901896127b5565b91509150826005541480156110935750806001600160a01b03168b6001600160a01b0316145b80156110b857506000828152600260205260409020546001600160a01b038681169116145b806110cb57506001600160a01b03851630145b9b9a5050505050505050505050565b60008281526002602052604090205482906001600160a01b031633146111125760405162461bcd60e51b8152600401610b7a90612f7d565b6000838152600260208190526040909120015462010000900460ff16151582151514610cb957600083815260026020818152604092839020909101805462ff0000191662010000861515908102919091179091558251868152918201527f4666a8529dea37114f2ecc11706d613f7a59a7967f8467da6877820b83d405a19101610be1565b610cb983838360016121d3565b60008281526002602052604090205482906001600160a01b031633146111dc5760405162461bcd60e51b8152600401610b7a90612f7d565b6000838152600260205260409020600a0154600160a01b900460ff16600181111561120957611209612d15565b82600181111561121b5761121b612d15565b14610cb9576000838152600260205260409020600a01805483919060ff60a01b1916600160a01b83600181111561125457611254612d15565b02179055507ff81d9cc918f72edfc74e6b61d4e19ef9a739e94a0e9715b108e6af62275142ef8383604051610be19291906130ac565b60008181526002602052604090205481906001600160a01b031633146112c25760405162461bcd60e51b8152600401610b7a90612f7d565b60008281526008602052604090205460ff16610d3b5760008281526008602052604090819020805460ff19166001179055517f9dc30b8eda31a6a144e092e5de600955523a6a925cc15cc1d1b9b4872cfa615590610fbb9084815260200190565b60008281526002602052604090205482906001600160a01b0316331461135b5760405162461bcd60e51b8152600401610b7a90612f7d565b6127108261ffff1611156113a35760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b6044820152606401610b7a565b6000838152600260208190526040909120015461ffff838116911614610cb957600083815260026020818152604092839020909101805461ffff191661ffff86169081179091558251868152918201527f9c6f3e426c05d512408d4ecf517e5155756288155088ad45a81c0e111e3d18549101610be1565b610e5b85856000868686612148565b60008281526002602052604090205482906001600160a01b031633146114625760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602052604090206006015463ffffffff838116600160401b9092041614610cb95760008381526002602090815260409182902060060180546bffffffff00000000000000001916600160401b63ffffffff8716908102919091179091558251868152918201527ff0275a50e761f3b1635fa59ce199b1f2268b3fcb7fbdfb18c21aa3d2d78aa7b79101610be1565b60008281526002602052604090205482906001600160a01b0316331461152f5760405162461bcd60e51b8152600401610b7a90612f7d565b600083815260026020526040902060060154600160601b900460ff16151582151514610cb957600083815260026020908152604091829020600601805460ff60601b1916600160601b861515908102919091179091558251868152918201527fc906280af595fe94779bb9a972f24fe4e0ed7f76bebb4ee0eb9a5f30d6dd4c879101610be1565b60008181526002602081905260408220805460068201549282015460019092018054859485948594606094869485946001600160a01b039093169363ffffffff808516946401000000008104821694600160401b90910490911692909161ffff8116916201000090910460ff1690839061162f90612f42565b80601f016020809104026020016040519081016040528092919081815260200182805461165b90612f42565b80156116a85780601f1061167d576101008083540402835291602001916116a8565b820191906000526020600020905b81548152906001019060200180831161168b57829003601f168201915b505050505092509650965096509650965096509650919395979092949650565b600054610100900460ff16158080156116e85750600054600160ff909116105b806117025750303b158015611702575060005460ff166001145b6117655760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b7a565b6000805460ff191660011790558015611788576000805461ff0019166101001790555b600980546001600160a01b0319166001600160a01b038416908117909155604080516381fa6cd360e01b815290516381fa6cd391600480820192602092909190829003018186803b1580156117dc57600080fd5b505afa1580156117f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181491906130bc565b6040805163a99e7e2960e01b81526004810191909152602960448201527f2875696e74323536206d61726b657449642c2061646472657373206c656e646560648201526872416464726573732960b81b60848201523060248201526001600160a01b03919091169063a99e7e299060a401602060405180830381600087803b15801561189f57600080fd5b505af11580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d791906130d9565b600155600954604080516381fa6cd360e01b815290516001600160a01b03909216916381fa6cd391600480820192602092909190829003018186803b15801561191f57600080fd5b505afa158015611933573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195791906130bc565b6040805163a99e7e2960e01b81526004810191909152602b60448201527f2875696e74323536206d61726b657449642c206164647265737320626f72726f60648201526a776572416464726573732960a81b60848201523060248201526001600160a01b03919091169063a99e7e299060a401602060405180830381600087803b1580156119e457600080fd5b505af11580156119f8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1c91906130d9565b6006558015610d3b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610fbb565b6000818152600260205260408120611a7c906007013361215f565b90508015610d3b577f914ccbaf2f5c9c2f4b7c6be3497b6b2ceb6ce2d050aec6eb2e0e31b8f9f67f0c8233610fa2565b610cb983838360006121d3565b60008381526002602052604090205483906001600160a01b03163314611af15760405162461bcd60e51b8152600401610b7a90612f7d565b6000836001811115611b0557611b05612d15565b1480611b3157506001836001811115611b2057611b20612d15565b148015611b31575063ffffffff8216155b611b925760405162461bcd60e51b815260206004820152602c60248201527f6d6f6e74686c79207061796d656e74206379636c65206475726174696f6e206360448201526b185b9b9bdd081899481cd95d60a21b6064820152608401610b7a565b60008481526002602052604081209080856001811115611bb457611bb4612d15565b14611bc25762278d00611bc4565b835b600a830154909150600160a81b900460ff166001811115611be757611be7612d15565b856001811115611bf957611bf9612d15565b141580611c135750600682015463ffffffff828116911614155b15610d27576000868152600260205260409020600a01805486919060ff60a81b1916600160a81b836001811115611c4c57611c4c612d15565b021790555060008681526002602052604090819020600601805463ffffffff191663ffffffff8416179055517fbb20033c58b125e31641bfd5e2f4bd906d684e27472fab0648527cc39cb2918c90611ca9908890889085906130f2565b60405180910390a1505050505050565b6000611ccf8a8a8a8a8a8a8a6000808c8c611e9e565b9a9950505050505050505050565b6000808415611da957611cf08387612330565b8015611d8657506009546001600160a01b03878116600090815260208790526040908190205490516330cd251f60e21b8152600481019190915291169063c334947c9060240160206040518083038186803b158015611d4e57600080fd5b505afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d86919061311c565b6001600160a01b0387166000908152602086905260409020549092509050611dae565b600191505b94509492505050565b60606000611dc485612352565b90506000611dd2848661314f565b9050818111611e95576000611de7858361316e565b905082811115611df45750815b611dfe8282613186565b67ffffffffffffffff811115611e1657611e1661319d565b604051908082528060200260200182016040528015611e3f578160200160208202803683370190505b509350815b81811015611e9257611e56888261235c565b858281518110611e6857611e686131b3565b6001600160a01b039092166020928302919091019091015280611e8a816131c9565b915050611e44565b50505b50509392505050565b60006001600160a01b038c16611eee5760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206f776e6572206164647265737360581b6044820152606401610b7a565b600460008154611efd906131c9565b9182905550600081815260026020526040902080546001600160a01b0319166001600160a01b038f161790559050611f3e818c87878e8e8e8d8f8c8c612174565b8b6001600160a01b03167fa69fa77c6a90b171cf4e3d9a9dd6c4e56fbd1fbbdcf3925eaf600ccaa917feab82604051611f7991815260200190565b60405180910390a29b9a5050505050505050505050565b83611f9d57600654611fa1565b6001545b806005819055506000808989604051602001611fd09291909182526001600160a01b0316602082015260400190565b60405160208183030381529060405290506000600260008c815260200190815260200160002060000160009054906101000a90046001600160a01b03169050600960009054906101000a90046001600160a01b03166001600160a01b031663930ed0138b6005548c600087878e8e8e6040518a63ffffffff1660e01b8152600401612063999897969594939291906131e4565b602060405180830381600087803b15801561207d57600080fd5b505af1158015612091573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b591906130d9565b925050506120c589898389612368565b5050600060055550505050505050565b6000838152600260205260409020546001600160a01b0316336001600160a01b03161461213b5760405162461bcd60e51b81526020600482015260146024820152732737ba103a34329036b0b935b2ba1037bbb732b960611b6044820152606401610b7a565b6000610e5b84848461246a565b600061215587878761246a565b5050505050505050565b6000610b3b836001600160a01b03841661257a565b61217f8b8383610d3f565b6121898b88610bee565b6121938b8761142a565b61219d8b86611323565b6121a78b846110da565b6121b18b856114f7565b6121bb8b8a6111a4565b6121c68b898c611ab9565b5050505050505050505050565b806121e0576006546121e4565b6001545b60058190556000858152600260205260409020546001600160a01b0316336001600160a01b03161461224f5760405162461bcd60e51b81526020600482015260146024820152732737ba103a34329036b0b935b2ba1037bbb732b960611b6044820152606401610b7a565b6009546005546040516000926001600160a01b0316916309a954cd9188919088908690612294908d9086906020019182526001600160a01b0316602082015260400190565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016122c3959493929190613245565b602060405180830381600087803b1580156122dd57600080fd5b505af11580156122f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231591906130d9565b905061232386868386612368565b5050600060055550505050565b6001600160a01b03811660009081526001830160205260408120541515610b3b565b6000610e9f825490565b6000610b3b838361266d565b80156123f05760008481526002602081815260408084206001600160a01b038816855260058101835290842086905592879052526123a99060030184612697565b50604080518581526001600160a01b03851660208201527f75675690de0899b0b869d83b44b2d926ac594426b2a0286c478ecdf815cbd33e910160405180910390a1610e36565b60008481526002602081815260408084206001600160a01b0388168552600981018352908420869055928790525261242b9060070184612697565b50604080518581526001600160a01b03851660208201527f0c2cfc7e7a16ebee66e77fb314f4bfdb5505e33e77d41c0c60604efc70fd926b9101610e2d565b600081156124f5575060008381526002602081815260408084206001600160a01b038716855260058101835290842054938790529190526124ae906003018461215f565b50604080518581526001600160a01b03851660208201527f6e7c30dc58d3daa1458c79b66ca464f5f3d8a23d9e50eb14daf1cb0923bf2900910160405180910390a1610b3b565b5060008381526002602081815260408084206001600160a01b03871685526009810183529084205493879052919052612531906007018461215f565b50604080518581526001600160a01b03851660208201527fe76a3e8b220b622b9fc2a655ab867687a93f195809eb3639f422e60936ff7eb4910160405180910390a19392505050565b6000818152600183016020526040812054801561266357600061259e600183613186565b85549091506000906125b290600190613186565b90508181146126175760008660000182815481106125d2576125d26131b3565b90600052602060002001549050808760000184815481106125f5576125f56131b3565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061262857612628613283565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610e9f565b6000915050610e9f565b6000826000018281548110612684576126846131b3565b9060005260206000200154905092915050565b6000610b3b836001600160a01b03841660006126c6838360009081526001919091016020526040902054151590565b6126fc57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610e9f565b506000610e9f565b82805461271090612f42565b90600052602060002090601f0160209004810192826127325760008555612778565b82601f1061274b5782800160ff19823516178555612778565b82800160010185558215612778579182015b8281111561277857823582559160200191906001019061275d565b50612784929150612788565b5090565b5b808211156127845760008155600101612789565b6001600160a01b03811681146127b257600080fd5b50565b600080604083850312156127c857600080fd5b8235915060208301356127da8161279d565b809150509250929050565b6000602082840312156127f757600080fd5b5035919050565b6000815180845260005b8181101561282457602081850181015186830182015201612808565b81811115612836576000602083870101525b50601f01601f19169290920160200192915050565b602081526000610b3b60208301846127fe565b60008060006060848603121561287357600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b818110156128cb5783516001600160a01b0316835292840192918401916001016128a6565b50909695505050505050565b803563ffffffff811681146128eb57600080fd5b919050565b6000806040838503121561290357600080fd5b82359150612913602084016128d7565b90509250929050565b803561ffff811681146128eb57600080fd5b80151581146127b257600080fd5b600281106127b257600080fd5b60008083601f84011261295b57600080fd5b50813567ffffffffffffffff81111561297357600080fd5b602083019150836020828501011115610a6c57600080fd5b60008060008060008060008060008060006101408c8e0312156129ad57600080fd5b8b356129b88161279d565b9a506129c660208d016128d7565b99506129d460408d016128d7565b98506129e260608d016128d7565b97506129f060808d0161291c565b965060a08c0135612a008161292e565b955060c08c0135612a108161292e565b945060e08c0135612a208161293c565b93506101008c0135612a318161293c565b92506101208c013567ffffffffffffffff811115612a4e57600080fd5b612a5a8e828f01612949565b915080935050809150509295989b509295989b9093969950565b803560ff811681146128eb57600080fd5b60008060008060008060c08789031215612a9e57600080fd5b863595506020870135612ab08161279d565b945060408701359350612ac560608801612a74565b92506080870135915060a087013590509295509295509295565b600080600060408486031215612af457600080fd5b83359250602084013567ffffffffffffffff811115612b1257600080fd5b612b1e86828701612949565b9497909650939450505050565b600080600080600060a08688031215612b4357600080fd5b853594506020860135612b558161279d565b9350612b6360408701612a74565b94979396509394606081013594506080013592915050565b60008060008060008060008060008060006101408c8e031215612b9d57600080fd5b8b359a50612bad60208d016128d7565b995060408c0135612bbd8161293c565b985060608c0135612bcd8161293c565b9750612bdb60808d016128d7565b9650612be960a08d016128d7565b9550612bf760c08d0161291c565b945060e08c0135612c078161292e565b93506101008c0135612a318161292e565b600080600080600080600060a0888a031215612c3357600080fd5b8735612c3e8161279d565b9650602088013567ffffffffffffffff80821115612c5b57600080fd5b612c678b838c01612949565b909850965060408a0135915080821115612c8057600080fd5b50612c8d8a828b01612949565b909550935050606088013591506080880135612ca88161279d565b8091505092959891949750929550565b60008060408385031215612ccb57600080fd5b8235915060208301356127da8161292e565b600080600060608486031215612cf257600080fd5b833592506020840135612d048161279d565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b600281106127b257634e487b7160e01b600052602160045260246000fd5b63ffffffff8316815260408101612d5f83612d2b565b8260208301529392505050565b60008060408385031215612d7f57600080fd5b8235915060208301356127da8161293c565b60008060408385031215612da457600080fd5b823591506129136020840161291c565b6001600160a01b038816815263ffffffff878116602083015286811660408301528516606082015260e060808201819052600090612df4908301866127fe565b61ffff9490941660a08301525090151560c09091015295945050505050565b600060208284031215612e2557600080fd5b8135610b3b8161279d565b60208101612e3d83612d2b565b91905290565b600080600060608486031215612e5857600080fd5b833592506020840135612e6a8161293c565b9150612e78604085016128d7565b90509250925092565b60008060008060008060008060006101008a8c031215612ea057600080fd5b8935612eab8161279d565b9850612eb960208b016128d7565b9750612ec760408b016128d7565b9650612ed560608b016128d7565b9550612ee360808b0161291c565b945060a08a0135612ef38161292e565b935060c08a0135612f038161292e565b925060e08a013567ffffffffffffffff811115612f1f57600080fd5b612f2b8c828d01612949565b915080935050809150509295985092959850929598565b600181811c90821680612f5657607f821691505b60208210811415612f7757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600d908201526c2737ba103a34329037bbb732b960991b604082015260600190565b600080835481600182811c915080831680612fc057607f831692505b6020808410821415612fe057634e487b7160e01b86526022600452602486fd5b818015612ff4576001811461300557613032565b60ff19861689528489019650613032565b60008a81526020902060005b8681101561302a5781548b820152908501908301613011565b505084890196505b509498975050505050505050565b8183823760009101908152919050565b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b82815260408101612d5f83612d2b565b6000602082840312156130ce57600080fd5b8151610b3b8161279d565b6000602082840312156130eb57600080fd5b5051919050565b8381526060810161310284612d2b565b83602083015263ffffffff83166040830152949350505050565b60006020828403121561312e57600080fd5b8151610b3b8161292e565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561316957613169613139565b500290565b6000821982111561318157613181613139565b500190565b60008282101561319857613198613139565b500390565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006000198214156131dd576131dd613139565b5060010190565b600061012060018060a01b03808d1684528b60208501528a60408501528960608501528160808501526132198285018a6127fe565b971660a0840152505060ff9390931660c084015260e08301919091526101009091015295945050505050565b60018060a01b038616815284602082015283604082015282606082015260a06080820152600061327860a08301846127fe565b979650505050505050565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220411d7354c9de04260f65046876835a5dcd340ba2f2d99e737e5e544f5f25acff64736f6c63430008090033", + "numDeployments": 1, + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"NotPayable\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"}],\"name\":\"BorrowerAttestation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"}],\"name\":\"BorrowerExitMarket\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"}],\"name\":\"BorrowerRevocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"}],\"name\":\"LenderAttestation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"}],\"name\":\"LenderExitMarket\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"}],\"name\":\"LenderRevocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"MarketClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"MarketCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"duration\",\"type\":\"uint32\"}],\"name\":\"SetBidExpirationTime\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"required\",\"type\":\"bool\"}],\"name\":\"SetMarketBorrowerAttestation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"feePct\",\"type\":\"uint16\"}],\"name\":\"SetMarketFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newRecipient\",\"type\":\"address\"}],\"name\":\"SetMarketFeeRecipient\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"required\",\"type\":\"bool\"}],\"name\":\"SetMarketLenderAttestation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"SetMarketOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum PaymentType\",\"name\":\"paymentType\",\"type\":\"uint8\"}],\"name\":\"SetMarketPaymentType\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"uri\",\"type\":\"string\"}],\"name\":\"SetMarketURI\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum PaymentCycleType\",\"name\":\"paymentCycleType\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"value\",\"type\":\"uint32\"}],\"name\":\"SetPaymentCycle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"duration\",\"type\":\"uint32\"}],\"name\":\"SetPaymentCycleDuration\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"duration\",\"type\":\"uint32\"}],\"name\":\"SetPaymentDefaultDuration\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CURRENT_CODE_VERSION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_expirationTime\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"attestBorrower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_expirationTime\",\"type\":\"uint256\"}],\"name\":\"attestBorrower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_expirationTime\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"attestLender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_expirationTime\",\"type\":\"uint256\"}],\"name\":\"attestLender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"borrowerAttestationSchemaId\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"borrowerExitMarket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"closeMarket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_initialOwner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_paymentCycleDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_paymentDefaultDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_bidExpirationTime\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_feePercent\",\"type\":\"uint16\"},{\"internalType\":\"bool\",\"name\":\"_requireLenderAttestation\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_requireBorrowerAttestation\",\"type\":\"bool\"},{\"internalType\":\"enum PaymentType\",\"name\":\"_paymentType\",\"type\":\"uint8\"},{\"internalType\":\"enum PaymentCycleType\",\"name\":\"_paymentCycleType\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"_uri\",\"type\":\"string\"}],\"name\":\"createMarket\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"marketId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_initialOwner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_paymentCycleDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_paymentDefaultDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_bidExpirationTime\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_feePercent\",\"type\":\"uint16\"},{\"internalType\":\"bool\",\"name\":\"_requireLenderAttestation\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_requireBorrowerAttestation\",\"type\":\"bool\"},{\"internalType\":\"string\",\"name\":\"_uri\",\"type\":\"string\"}],\"name\":\"createMarket\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"marketId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_page\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_perPage\",\"type\":\"uint256\"}],\"name\":\"getAllVerifiedBorrowersForMarket\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_page\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_perPage\",\"type\":\"uint256\"}],\"name\":\"getAllVerifiedLendersForMarket\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"}],\"name\":\"getBidExpirationTime\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketAttestationRequirements\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"lenderAttestationRequired\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"borrowerAttestationRequired\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketData\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"paymentCycleDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"paymentDefaultDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"loanExpirationTime\",\"type\":\"uint32\"},{\"internalType\":\"string\",\"name\":\"metadataURI\",\"type\":\"string\"},{\"internalType\":\"uint16\",\"name\":\"marketplaceFeePercent\",\"type\":\"uint16\"},{\"internalType\":\"bool\",\"name\":\"lenderAttestationRequired\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketFeeRecipient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getMarketplaceFee\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"fee\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getPaymentCycle\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"},{\"internalType\":\"enum PaymentCycleType\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getPaymentDefaultDuration\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"getPaymentType\",\"outputs\":[{\"internalType\":\"enum PaymentType\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TellerAS\",\"name\":\"_tellerAS\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"isMarketClosed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isPayable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"}],\"name\":\"isVerifiedBorrower\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isVerified_\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"uuid_\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"}],\"name\":\"isVerifiedLender\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isVerified_\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"uuid_\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lenderAttestationSchemaId\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"name\":\"lenderExitMarket\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"schema\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"attestor\",\"type\":\"address\"}],\"name\":\"resolve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"}],\"name\":\"revokeBorrower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_borrowerAddress\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"revokeBorrower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"_v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"_r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"revokeLender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_lenderAddress\",\"type\":\"address\"}],\"name\":\"revokeLender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_duration\",\"type\":\"uint32\"}],\"name\":\"setBidExpirationTime\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_required\",\"type\":\"bool\"}],\"name\":\"setBorrowerAttestationRequired\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_required\",\"type\":\"bool\"}],\"name\":\"setLenderAttestationRequired\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint16\",\"name\":\"_newPercent\",\"type\":\"uint16\"}],\"name\":\"setMarketFeePercent\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"setMarketFeeRecipient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"enum PaymentType\",\"name\":\"_newPaymentType\",\"type\":\"uint8\"}],\"name\":\"setMarketPaymentType\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"_uri\",\"type\":\"string\"}],\"name\":\"setMarketURI\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"enum PaymentCycleType\",\"name\":\"_paymentCycleType\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"_duration\",\"type\":\"uint32\"}],\"name\":\"setPaymentCycle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_duration\",\"type\":\"uint32\"}],\"name\":\"setPaymentDefaultDuration\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tellerAS\",\"outputs\":[{\"internalType\":\"contract TellerAS\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"transferMarketOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_paymentCycleDuration\",\"type\":\"uint32\"},{\"internalType\":\"enum PaymentType\",\"name\":\"_newPaymentType\",\"type\":\"uint8\"},{\"internalType\":\"enum PaymentCycleType\",\"name\":\"_paymentCycleType\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"_paymentDefaultDuration\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_bidExpirationTime\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_feePercent\",\"type\":\"uint16\"},{\"internalType\":\"bool\",\"name\":\"_borrowerAttestationRequired\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_lenderAttestationRequired\",\"type\":\"bool\"},{\"internalType\":\"string\",\"name\":\"_metadataURI\",\"type\":\"string\"}],\"name\":\"updateMarketSettings\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"attestBorrower(uint256,address,uint256)\":{\"details\":\"See {_attestStakeholder}.\"},\"attestBorrower(uint256,address,uint256,uint8,bytes32,bytes32)\":{\"details\":\"See {_attestStakeholderViaDelegation}.\"},\"attestLender(uint256,address,uint256)\":{\"details\":\"See {_attestStakeholder}.\"},\"attestLender(uint256,address,uint256,uint8,bytes32,bytes32)\":{\"details\":\"See {_attestStakeholderViaDelegation}.\"},\"borrowerExitMarket(uint256)\":{\"params\":{\"_marketId\":\"The market ID to leave.\"}},\"closeMarket(uint256)\":{\"params\":{\"_marketId\":\"The market ID for the market to close.\"}},\"createMarket(address,uint32,uint32,uint32,uint16,bool,bool,string)\":{\"details\":\"Uses the default EMI payment type.\",\"params\":{\"_bidExpirationTime\":\"Length of time in seconds before pending bids expire.\",\"_initialOwner\":\"Address who will initially own the market.\",\"_paymentCycleDuration\":\"Length of time in seconds before a bid's next payment is required to be made.\",\"_paymentDefaultDuration\":\"Length of time in seconds before a loan is considered in default for non-payment.\",\"_requireBorrowerAttestation\":\"Boolean that indicates if borrowers require attestation to join market.\",\"_requireLenderAttestation\":\"Boolean that indicates if lenders require attestation to join market.\",\"_uri\":\"URI string to get metadata details about the market.\"},\"returns\":{\"marketId_\":\"The market ID of the newly created market.\"}},\"createMarket(address,uint32,uint32,uint32,uint16,bool,bool,uint8,uint8,string)\":{\"params\":{\"_bidExpirationTime\":\"Length of time in seconds before pending bids expire.\",\"_initialOwner\":\"Address who will initially own the market.\",\"_paymentCycleDuration\":\"Length of time in seconds before a bid's next payment is required to be made.\",\"_paymentCycleType\":\"The payment cycle type for loans in the market - Seconds or Monthly\",\"_paymentDefaultDuration\":\"Length of time in seconds before a loan is considered in default for non-payment.\",\"_paymentType\":\"The payment type for loans in the market.\",\"_requireBorrowerAttestation\":\"Boolean that indicates if borrowers require attestation to join market.\",\"_requireLenderAttestation\":\"Boolean that indicates if lenders require attestation to join market.\",\"_uri\":\"URI string to get metadata details about the market.\"},\"returns\":{\"marketId_\":\"The market ID of the newly created market.\"}},\"getAllVerifiedBorrowersForMarket(uint256,uint256,uint256)\":{\"params\":{\"_marketId\":\"The ID of the market.\",\"_page\":\"Page index to start from.\",\"_perPage\":\"Number of items in a page to return.\"},\"returns\":{\"_0\":\"Array of addresses that have been added to a market.\"}},\"getAllVerifiedLendersForMarket(uint256,uint256,uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_page\":\"Page index to start from.\",\"_perPage\":\"Number of items in a page to return.\"},\"returns\":{\"_0\":\"Array of addresses that have been added to a market.\"}},\"getMarketAttestationRequirements(uint256)\":{\"params\":{\"_marketId\":\"The ID of the market.\"}},\"getMarketData(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"}},\"getMarketFeeRecipient(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"The address of a market's fee recipient.\"}},\"getMarketOwner(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"The address of a market's owner.\"}},\"getMarketURI(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"URI of a market's metadata.\"}},\"getMarketplaceFee(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"fee\":\"in basis points\"}},\"getPaymentCycle(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"Duration of a loan until it is delinquent.\",\"_1\":\"The type of payment cycle for loans in the market.\"}},\"getPaymentDefaultDuration(uint256)\":{\"params\":{\"_marketId\":\"The ID of a market.\"},\"returns\":{\"_0\":\"Duration of a loan repayment interval until it is default.\"}},\"getPaymentType(uint256)\":{\"params\":{\"_marketId\":\"the ID of the market.\"},\"returns\":{\"_0\":\"The type of payment for loans in the market.\"}},\"isMarketClosed(uint256)\":{\"params\":{\"_marketId\":\"The market ID for the market to check.\"}},\"isPayable()\":{\"details\":\"Returns whether the resolver supports ETH transfers\"},\"isVerifiedBorrower(uint256,address)\":{\"params\":{\"_borrowerAddress\":\"Address of the borrower to check.\",\"_marketId\":\"The ID of a market.\"},\"returns\":{\"isVerified_\":\"Boolean indicating if a borrower has been added to a market.\",\"uuid_\":\"Bytes32 representing the UUID of the borrower.\"}},\"isVerifiedLender(uint256,address)\":{\"params\":{\"_lenderAddress\":\"Address to check.\",\"_marketId\":\"The ID of a market.\"},\"returns\":{\"isVerified_\":\"Boolean indicating if a lender has been added to a market.\",\"uuid_\":\"Bytes32 representing the UUID of the lender.\"}},\"lenderExitMarket(uint256)\":{\"params\":{\"_marketId\":\"The market ID to leave.\"}},\"resolve(address,bytes,bytes,uint256,address)\":{\"details\":\"This function must only be called by the `attestLender` function above.\",\"params\":{\"\":\"@param attestor Market owner's address who signed the attestation.\",\"data\":\"Data the must include the market ID and lender's address\",\"recipient\":\"Lender's address who is being attested.\",\"schema\":\"The schema used for the attestation.\"},\"returns\":{\"_0\":\"Boolean indicating the attestation was successful.\"}},\"revokeBorrower(uint256,address)\":{\"details\":\"See {_revokeStakeholder}.\"},\"revokeBorrower(uint256,address,uint8,bytes32,bytes32)\":{\"details\":\"See {_revokeStakeholderViaDelegation}.\"},\"revokeLender(uint256,address)\":{\"details\":\"See {_revokeStakeholder}.\"},\"revokeLender(uint256,address,uint8,bytes32,bytes32)\":{\"details\":\"See {_revokeStakeholderViaDelegation}.\"},\"setBorrowerAttestationRequired(uint256,bool)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_required\":\"Boolean indicating if the market requires whitelist. Requirements: - The caller must be the current owner.\"}},\"setLenderAttestationRequired(uint256,bool)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_required\":\"Boolean indicating if the market requires whitelist. Requirements: - The caller must be the current owner.\"}},\"setMarketFeePercent(uint256,uint16)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_newPercent\":\"The percentage fee in basis points. Requirements: - The caller must be the current owner.\"}},\"setMarketFeeRecipient(uint256,address)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_recipient\":\"Address of the new fee recipient. Requirements: - The caller must be the current owner.\"}},\"setMarketPaymentType(uint256,uint8)\":{\"params\":{\"_marketId\":\"The ID of the market.\",\"_newPaymentType\":\"The payment type for the market.\"}},\"setMarketURI(uint256,string)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_uri\":\"A URI that points to a market's metadata. Requirements: - The caller must be the current owner.\"}},\"setPaymentCycle(uint256,uint8,uint32)\":{\"params\":{\"_duration\":\"Delinquency duration for new loans\",\"_marketId\":\"The ID of a market.\",\"_paymentCycleType\":\"Cycle type (seconds or monthly)\"}},\"setPaymentDefaultDuration(uint256,uint32)\":{\"params\":{\"_duration\":\"Default duration for new loans\",\"_marketId\":\"The ID of a market.\"}},\"transferMarketOwnership(uint256,address)\":{\"params\":{\"_marketId\":\"The ID of a market.\",\"_newOwner\":\"Address of the new market owner. Requirements: - The caller must be the current owner.\"}},\"updateMarketSettings(uint256,uint32,uint8,uint8,uint32,uint32,uint16,bool,bool,string)\":{\"params\":{\"_bidExpirationTime\":\"Duration of time before a bid is considered out of date\",\"_marketId\":\"The ID of a market.\",\"_metadataURI\":\"A URI that points to a market's metadata. Requirements: - The caller must be the current owner.\",\"_newPaymentType\":\"The payment type for the market.\",\"_paymentCycleDuration\":\"Delinquency duration for new loans\",\"_paymentCycleType\":\"The payment cycle type for loans in the market - Seconds or Monthly\",\"_paymentDefaultDuration\":\"Default duration for new loans\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"CURRENT_CODE_VERSION()\":{\"notice\":\"Constant Variables *\"},\"attestBorrower(uint256,address,uint256)\":{\"notice\":\"Adds a borrower to a market.\"},\"attestBorrower(uint256,address,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"Adds a borrower to a market via delegated attestation.\"},\"attestLender(uint256,address,uint256)\":{\"notice\":\"Adds a lender to a market.\"},\"attestLender(uint256,address,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"Adds a lender to a market via delegated attestation.\"},\"borrowerExitMarket(uint256)\":{\"notice\":\"Allows a borrower to voluntarily leave a market.\"},\"closeMarket(uint256)\":{\"notice\":\"Closes a market so new bids cannot be added.\"},\"createMarket(address,uint32,uint32,uint32,uint16,bool,bool,string)\":{\"notice\":\"Creates a new market.\"},\"createMarket(address,uint32,uint32,uint32,uint16,bool,bool,uint8,uint8,string)\":{\"notice\":\"Creates a new market.\"},\"getAllVerifiedBorrowersForMarket(uint256,uint256,uint256)\":{\"notice\":\"Gets addresses of all attested borrowers.\"},\"getAllVerifiedLendersForMarket(uint256,uint256,uint256)\":{\"notice\":\"Gets addresses of all attested lenders.\"},\"getMarketAttestationRequirements(uint256)\":{\"notice\":\"Gets the attestation requirements for a given market.\"},\"getMarketData(uint256)\":{\"notice\":\"Gets the data associated with a market.\"},\"getMarketFeeRecipient(uint256)\":{\"notice\":\"Gets the fee recipient of a market.\"},\"getMarketOwner(uint256)\":{\"notice\":\"Gets the address of a market's owner.\"},\"getMarketURI(uint256)\":{\"notice\":\"Gets the metadata URI of a market.\"},\"getMarketplaceFee(uint256)\":{\"notice\":\"Gets the marketplace fee in basis points\"},\"getPaymentCycle(uint256)\":{\"notice\":\"Gets the loan delinquent duration of a market.\"},\"getPaymentDefaultDuration(uint256)\":{\"notice\":\"Gets the loan default duration of a market.\"},\"getPaymentType(uint256)\":{\"notice\":\"Get the payment type of a market.\"},\"isMarketClosed(uint256)\":{\"notice\":\"Returns the status of a market being open or closed for new bids.\"},\"isVerifiedBorrower(uint256,address)\":{\"notice\":\"Checks if a borrower has been attested and added to a market.\"},\"isVerifiedLender(uint256,address)\":{\"notice\":\"Checks if a lender has been attested and added to a market.\"},\"lenderExitMarket(uint256)\":{\"notice\":\"Allows a lender to voluntarily leave a market.\"},\"resolve(address,bytes,bytes,uint256,address)\":{\"notice\":\"Verifies an attestation is valid.\"},\"revokeBorrower(uint256,address)\":{\"notice\":\"Removes a borrower from an market.\"},\"revokeBorrower(uint256,address,uint8,bytes32,bytes32)\":{\"notice\":\"Removes a borrower from a market via delegated revocation.\"},\"revokeLender(uint256,address)\":{\"notice\":\"Removes a lender from an market.\"},\"revokeLender(uint256,address,uint8,bytes32,bytes32)\":{\"notice\":\"Removes a borrower from a market via delegated revocation.\"},\"setBorrowerAttestationRequired(uint256,bool)\":{\"notice\":\"Enable/disables market whitelist for borrowers.\"},\"setLenderAttestationRequired(uint256,bool)\":{\"notice\":\"Enable/disables market whitelist for lenders.\"},\"setMarketFeePercent(uint256,uint16)\":{\"notice\":\"Sets the fee for the market.\"},\"setMarketFeeRecipient(uint256,address)\":{\"notice\":\"Sets the fee recipient address for a market.\"},\"setMarketPaymentType(uint256,uint8)\":{\"notice\":\"Set the payment type for the market.\"},\"setMarketURI(uint256,string)\":{\"notice\":\"Sets the metadata URI for a market.\"},\"setPaymentCycle(uint256,uint8,uint32)\":{\"notice\":\"Sets the duration of new loans for this market before they turn delinquent.Changing this value does not change the terms of existing loans for this market.\"},\"setPaymentDefaultDuration(uint256,uint32)\":{\"notice\":\"Sets the duration of new loans for this market before they turn defaulted.Changing this value does not change the terms of existing loans for this market.\"},\"transferMarketOwnership(uint256,address)\":{\"notice\":\"Transfers ownership of a marketplace.\"},\"updateMarketSettings(uint256,uint32,uint8,uint8,uint32,uint32,uint16,bool,bool,string)\":{\"notice\":\"Updates multiple market settings for a given market.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/MarketRegistry.sol\":\"MarketRegistry\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x3798da9e212cd00a7cda94ddb5a9721171a718e89c500d8901f810e0e37fa74e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/EAS/TellerASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../interfaces/IASResolver.sol\\\";\\n\\n/**\\n * @title A base resolver contract\\n */\\nabstract contract TellerASResolver is IASResolver {\\n error NotPayable();\\n\\n function isPayable() public pure virtual override returns (bool) {\\n return false;\\n }\\n\\n receive() external payable virtual {\\n if (!isPayable()) {\\n revert NotPayable();\\n }\\n }\\n}\\n\",\"keccak256\":\"0x8002d1725fd711dacd001e06d98fe2afc4814d2939d06df70c5b3ffcf5ec7f15\",\"license\":\"MIT\"},\"contracts/MarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Contracts\\nimport \\\"./EAS/TellerAS.sol\\\";\\nimport \\\"./EAS/TellerASResolver.sol\\\";\\n\\n//must continue to use this so storage slots are not broken\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Context.sol\\\";\\n\\n// Interfaces\\nimport \\\"./interfaces/IMarketRegistry.sol\\\";\\n\\n// Libraries\\nimport { EnumerableSet } from \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport { PaymentType } from \\\"./libraries/V2Calculations.sol\\\";\\n\\ncontract MarketRegistry is\\n IMarketRegistry,\\n Initializable,\\n Context,\\n TellerASResolver\\n{\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n /** Constant Variables **/\\n\\n uint256 public constant CURRENT_CODE_VERSION = 8;\\n\\n /* Storage Variables */\\n\\n struct Marketplace {\\n address owner;\\n string metadataURI;\\n uint16 marketplaceFeePercent; // 10000 is 100%\\n bool lenderAttestationRequired;\\n EnumerableSet.AddressSet verifiedLendersForMarket;\\n mapping(address => bytes32) lenderAttestationIds;\\n uint32 paymentCycleDuration; // unix time (seconds)\\n uint32 paymentDefaultDuration; //unix time\\n uint32 bidExpirationTime; //unix time\\n bool borrowerAttestationRequired;\\n EnumerableSet.AddressSet verifiedBorrowersForMarket;\\n mapping(address => bytes32) borrowerAttestationIds;\\n address feeRecipient;\\n PaymentType paymentType;\\n PaymentCycleType paymentCycleType;\\n }\\n\\n bytes32 public lenderAttestationSchemaId;\\n\\n mapping(uint256 => Marketplace) internal markets;\\n mapping(bytes32 => uint256) internal __uriToId; //DEPRECATED\\n uint256 public marketCount;\\n bytes32 private _attestingSchemaId;\\n bytes32 public borrowerAttestationSchemaId;\\n\\n uint256 public version;\\n\\n mapping(uint256 => bool) private marketIsClosed;\\n\\n TellerAS public tellerAS;\\n\\n /* Modifiers */\\n\\n modifier ownsMarket(uint256 _marketId) {\\n require(markets[_marketId].owner == _msgSender(), \\\"Not the owner\\\");\\n _;\\n }\\n\\n modifier withAttestingSchema(bytes32 schemaId) {\\n _attestingSchemaId = schemaId;\\n _;\\n _attestingSchemaId = bytes32(0);\\n }\\n\\n /* Events */\\n\\n event MarketCreated(address indexed owner, uint256 marketId);\\n event SetMarketURI(uint256 marketId, string uri);\\n event SetPaymentCycleDuration(uint256 marketId, uint32 duration); // DEPRECATED - used for subgraph reference\\n event SetPaymentCycle(\\n uint256 marketId,\\n PaymentCycleType paymentCycleType,\\n uint32 value\\n );\\n event SetPaymentDefaultDuration(uint256 marketId, uint32 duration);\\n event SetBidExpirationTime(uint256 marketId, uint32 duration);\\n event SetMarketFee(uint256 marketId, uint16 feePct);\\n event LenderAttestation(uint256 marketId, address lender);\\n event BorrowerAttestation(uint256 marketId, address borrower);\\n event LenderRevocation(uint256 marketId, address lender);\\n event BorrowerRevocation(uint256 marketId, address borrower);\\n event MarketClosed(uint256 marketId);\\n event LenderExitMarket(uint256 marketId, address lender);\\n event BorrowerExitMarket(uint256 marketId, address borrower);\\n event SetMarketOwner(uint256 marketId, address newOwner);\\n event SetMarketFeeRecipient(uint256 marketId, address newRecipient);\\n event SetMarketLenderAttestation(uint256 marketId, bool required);\\n event SetMarketBorrowerAttestation(uint256 marketId, bool required);\\n event SetMarketPaymentType(uint256 marketId, PaymentType paymentType);\\n\\n /* External Functions */\\n\\n function initialize(TellerAS _tellerAS) external initializer {\\n tellerAS = _tellerAS;\\n\\n lenderAttestationSchemaId = tellerAS.getASRegistry().register(\\n \\\"(uint256 marketId, address lenderAddress)\\\",\\n this\\n );\\n borrowerAttestationSchemaId = tellerAS.getASRegistry().register(\\n \\\"(uint256 marketId, address borrowerAddress)\\\",\\n this\\n );\\n }\\n\\n /**\\n * @notice Creates a new market.\\n * @param _initialOwner Address who will initially own the market.\\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\\n * @param _paymentType The payment type for loans in the market.\\n * @param _uri URI string to get metadata details about the market.\\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\\n * @return marketId_ The market ID of the newly created market.\\n */\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_) {\\n marketId_ = _createMarket(\\n _initialOwner,\\n _paymentCycleDuration,\\n _paymentDefaultDuration,\\n _bidExpirationTime,\\n _feePercent,\\n _requireLenderAttestation,\\n _requireBorrowerAttestation,\\n _paymentType,\\n _paymentCycleType,\\n _uri\\n );\\n }\\n\\n /**\\n * @notice Creates a new market.\\n * @dev Uses the default EMI payment type.\\n * @param _initialOwner Address who will initially own the market.\\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\\n * @param _uri URI string to get metadata details about the market.\\n * @return marketId_ The market ID of the newly created market.\\n */\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_) {\\n marketId_ = _createMarket(\\n _initialOwner,\\n _paymentCycleDuration,\\n _paymentDefaultDuration,\\n _bidExpirationTime,\\n _feePercent,\\n _requireLenderAttestation,\\n _requireBorrowerAttestation,\\n PaymentType.EMI,\\n PaymentCycleType.Seconds,\\n _uri\\n );\\n }\\n\\n /**\\n * @notice Creates a new market.\\n * @param _initialOwner Address who will initially own the market.\\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\\n * @param _paymentType The payment type for loans in the market.\\n * @param _uri URI string to get metadata details about the market.\\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\\n * @return marketId_ The market ID of the newly created market.\\n */\\n function _createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) internal returns (uint256 marketId_) {\\n require(_initialOwner != address(0), \\\"Invalid owner address\\\");\\n // Increment market ID counter\\n marketId_ = ++marketCount;\\n\\n // Set the market owner\\n markets[marketId_].owner = _initialOwner;\\n\\n // Initialize market settings\\n _setMarketSettings(\\n marketId_,\\n _paymentCycleDuration,\\n _paymentType,\\n _paymentCycleType,\\n _paymentDefaultDuration,\\n _bidExpirationTime,\\n _feePercent,\\n _requireBorrowerAttestation,\\n _requireLenderAttestation,\\n _uri\\n );\\n\\n emit MarketCreated(_initialOwner, marketId_);\\n }\\n\\n /**\\n * @notice Closes a market so new bids cannot be added.\\n * @param _marketId The market ID for the market to close.\\n */\\n\\n function closeMarket(uint256 _marketId) public ownsMarket(_marketId) {\\n if (!marketIsClosed[_marketId]) {\\n marketIsClosed[_marketId] = true;\\n\\n emit MarketClosed(_marketId);\\n }\\n }\\n\\n /**\\n * @notice Returns the status of a market being open or closed for new bids.\\n * @param _marketId The market ID for the market to check.\\n */\\n function isMarketClosed(uint256 _marketId)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return marketIsClosed[_marketId];\\n }\\n\\n /**\\n * @notice Adds a lender to a market.\\n * @dev See {_attestStakeholder}.\\n */\\n function attestLender(\\n uint256 _marketId,\\n address _lenderAddress,\\n uint256 _expirationTime\\n ) external {\\n _attestStakeholder(_marketId, _lenderAddress, _expirationTime, true);\\n }\\n\\n /**\\n * @notice Adds a lender to a market via delegated attestation.\\n * @dev See {_attestStakeholderViaDelegation}.\\n */\\n function attestLender(\\n uint256 _marketId,\\n address _lenderAddress,\\n uint256 _expirationTime,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) external {\\n _attestStakeholderViaDelegation(\\n _marketId,\\n _lenderAddress,\\n _expirationTime,\\n true,\\n _v,\\n _r,\\n _s\\n );\\n }\\n\\n /**\\n * @notice Removes a lender from an market.\\n * @dev See {_revokeStakeholder}.\\n */\\n function revokeLender(uint256 _marketId, address _lenderAddress) external {\\n _revokeStakeholder(_marketId, _lenderAddress, true);\\n }\\n\\n /**\\n * @notice Removes a borrower from a market via delegated revocation.\\n * @dev See {_revokeStakeholderViaDelegation}.\\n */\\n function revokeLender(\\n uint256 _marketId,\\n address _lenderAddress,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) external {\\n _revokeStakeholderViaDelegation(\\n _marketId,\\n _lenderAddress,\\n true,\\n _v,\\n _r,\\n _s\\n );\\n }\\n\\n /**\\n * @notice Allows a lender to voluntarily leave a market.\\n * @param _marketId The market ID to leave.\\n */\\n function lenderExitMarket(uint256 _marketId) external {\\n // Remove lender address from market set\\n bool response = markets[_marketId].verifiedLendersForMarket.remove(\\n _msgSender()\\n );\\n if (response) {\\n emit LenderExitMarket(_marketId, _msgSender());\\n }\\n }\\n\\n /**\\n * @notice Adds a borrower to a market.\\n * @dev See {_attestStakeholder}.\\n */\\n function attestBorrower(\\n uint256 _marketId,\\n address _borrowerAddress,\\n uint256 _expirationTime\\n ) external {\\n _attestStakeholder(_marketId, _borrowerAddress, _expirationTime, false);\\n }\\n\\n /**\\n * @notice Adds a borrower to a market via delegated attestation.\\n * @dev See {_attestStakeholderViaDelegation}.\\n */\\n function attestBorrower(\\n uint256 _marketId,\\n address _borrowerAddress,\\n uint256 _expirationTime,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) external {\\n _attestStakeholderViaDelegation(\\n _marketId,\\n _borrowerAddress,\\n _expirationTime,\\n false,\\n _v,\\n _r,\\n _s\\n );\\n }\\n\\n /**\\n * @notice Removes a borrower from an market.\\n * @dev See {_revokeStakeholder}.\\n */\\n function revokeBorrower(uint256 _marketId, address _borrowerAddress)\\n external\\n {\\n _revokeStakeholder(_marketId, _borrowerAddress, false);\\n }\\n\\n /**\\n * @notice Removes a borrower from a market via delegated revocation.\\n * @dev See {_revokeStakeholderViaDelegation}.\\n */\\n function revokeBorrower(\\n uint256 _marketId,\\n address _borrowerAddress,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) external {\\n _revokeStakeholderViaDelegation(\\n _marketId,\\n _borrowerAddress,\\n false,\\n _v,\\n _r,\\n _s\\n );\\n }\\n\\n /**\\n * @notice Allows a borrower to voluntarily leave a market.\\n * @param _marketId The market ID to leave.\\n */\\n function borrowerExitMarket(uint256 _marketId) external {\\n // Remove borrower address from market set\\n bool response = markets[_marketId].verifiedBorrowersForMarket.remove(\\n _msgSender()\\n );\\n if (response) {\\n emit BorrowerExitMarket(_marketId, _msgSender());\\n }\\n }\\n\\n /**\\n * @notice Verifies an attestation is valid.\\n * @dev This function must only be called by the `attestLender` function above.\\n * @param recipient Lender's address who is being attested.\\n * @param schema The schema used for the attestation.\\n * @param data Data the must include the market ID and lender's address\\n * @param\\n * @param attestor Market owner's address who signed the attestation.\\n * @return Boolean indicating the attestation was successful.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 /* expirationTime */,\\n address attestor\\n ) external payable override returns (bool) {\\n bytes32 attestationSchemaId = keccak256(\\n abi.encodePacked(schema, address(this))\\n );\\n (uint256 marketId, address lenderAddress) = abi.decode(\\n data,\\n (uint256, address)\\n );\\n return\\n (_attestingSchemaId == attestationSchemaId &&\\n recipient == lenderAddress &&\\n attestor == markets[marketId].owner) ||\\n attestor == address(this);\\n }\\n\\n /**\\n * @notice Transfers ownership of a marketplace.\\n * @param _marketId The ID of a market.\\n * @param _newOwner Address of the new market owner.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function transferMarketOwnership(uint256 _marketId, address _newOwner)\\n public\\n ownsMarket(_marketId)\\n {\\n markets[_marketId].owner = _newOwner;\\n emit SetMarketOwner(_marketId, _newOwner);\\n }\\n\\n /**\\n * @notice Updates multiple market settings for a given market.\\n * @param _marketId The ID of a market.\\n * @param _paymentCycleDuration Delinquency duration for new loans\\n * @param _newPaymentType The payment type for the market.\\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\\n * @param _paymentDefaultDuration Default duration for new loans\\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\\n * @param _metadataURI A URI that points to a market's metadata.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function updateMarketSettings(\\n uint256 _marketId,\\n uint32 _paymentCycleDuration,\\n PaymentType _newPaymentType,\\n PaymentCycleType _paymentCycleType,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _borrowerAttestationRequired,\\n bool _lenderAttestationRequired,\\n string calldata _metadataURI\\n ) public ownsMarket(_marketId) {\\n _setMarketSettings(\\n _marketId,\\n _paymentCycleDuration,\\n _newPaymentType,\\n _paymentCycleType,\\n _paymentDefaultDuration,\\n _bidExpirationTime,\\n _feePercent,\\n _borrowerAttestationRequired,\\n _lenderAttestationRequired,\\n _metadataURI\\n );\\n }\\n\\n /**\\n * @notice Sets the fee recipient address for a market.\\n * @param _marketId The ID of a market.\\n * @param _recipient Address of the new fee recipient.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setMarketFeeRecipient(uint256 _marketId, address _recipient)\\n public\\n ownsMarket(_marketId)\\n {\\n markets[_marketId].feeRecipient = _recipient;\\n emit SetMarketFeeRecipient(_marketId, _recipient);\\n }\\n\\n /**\\n * @notice Sets the metadata URI for a market.\\n * @param _marketId The ID of a market.\\n * @param _uri A URI that points to a market's metadata.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setMarketURI(uint256 _marketId, string calldata _uri)\\n public\\n ownsMarket(_marketId)\\n {\\n //We do string comparison by checking the hashes of the strings against one another\\n if (\\n keccak256(abi.encodePacked(_uri)) !=\\n keccak256(abi.encodePacked(markets[_marketId].metadataURI))\\n ) {\\n markets[_marketId].metadataURI = _uri;\\n\\n emit SetMarketURI(_marketId, _uri);\\n }\\n }\\n\\n /**\\n * @notice Sets the duration of new loans for this market before they turn delinquent.\\n * @notice Changing this value does not change the terms of existing loans for this market.\\n * @param _marketId The ID of a market.\\n * @param _paymentCycleType Cycle type (seconds or monthly)\\n * @param _duration Delinquency duration for new loans\\n */\\n function setPaymentCycle(\\n uint256 _marketId,\\n PaymentCycleType _paymentCycleType,\\n uint32 _duration\\n ) public ownsMarket(_marketId) {\\n require(\\n (_paymentCycleType == PaymentCycleType.Seconds) ||\\n (_paymentCycleType == PaymentCycleType.Monthly &&\\n _duration == 0),\\n \\\"monthly payment cycle duration cannot be set\\\"\\n );\\n Marketplace storage market = markets[_marketId];\\n uint32 duration = _paymentCycleType == PaymentCycleType.Seconds\\n ? _duration\\n : 30 days;\\n if (\\n _paymentCycleType != market.paymentCycleType ||\\n duration != market.paymentCycleDuration\\n ) {\\n markets[_marketId].paymentCycleType = _paymentCycleType;\\n markets[_marketId].paymentCycleDuration = duration;\\n\\n emit SetPaymentCycle(_marketId, _paymentCycleType, duration);\\n }\\n }\\n\\n /**\\n * @notice Sets the duration of new loans for this market before they turn defaulted.\\n * @notice Changing this value does not change the terms of existing loans for this market.\\n * @param _marketId The ID of a market.\\n * @param _duration Default duration for new loans\\n */\\n function setPaymentDefaultDuration(uint256 _marketId, uint32 _duration)\\n public\\n ownsMarket(_marketId)\\n {\\n if (_duration != markets[_marketId].paymentDefaultDuration) {\\n markets[_marketId].paymentDefaultDuration = _duration;\\n\\n emit SetPaymentDefaultDuration(_marketId, _duration);\\n }\\n }\\n\\n function setBidExpirationTime(uint256 _marketId, uint32 _duration)\\n public\\n ownsMarket(_marketId)\\n {\\n if (_duration != markets[_marketId].bidExpirationTime) {\\n markets[_marketId].bidExpirationTime = _duration;\\n\\n emit SetBidExpirationTime(_marketId, _duration);\\n }\\n }\\n\\n /**\\n * @notice Sets the fee for the market.\\n * @param _marketId The ID of a market.\\n * @param _newPercent The percentage fee in basis points.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setMarketFeePercent(uint256 _marketId, uint16 _newPercent)\\n public\\n ownsMarket(_marketId)\\n {\\n require(_newPercent >= 0 && _newPercent <= 10000, \\\"invalid percent\\\");\\n if (_newPercent != markets[_marketId].marketplaceFeePercent) {\\n markets[_marketId].marketplaceFeePercent = _newPercent;\\n emit SetMarketFee(_marketId, _newPercent);\\n }\\n }\\n\\n /**\\n * @notice Set the payment type for the market.\\n * @param _marketId The ID of the market.\\n * @param _newPaymentType The payment type for the market.\\n */\\n function setMarketPaymentType(\\n uint256 _marketId,\\n PaymentType _newPaymentType\\n ) public ownsMarket(_marketId) {\\n if (_newPaymentType != markets[_marketId].paymentType) {\\n markets[_marketId].paymentType = _newPaymentType;\\n emit SetMarketPaymentType(_marketId, _newPaymentType);\\n }\\n }\\n\\n /**\\n * @notice Enable/disables market whitelist for lenders.\\n * @param _marketId The ID of a market.\\n * @param _required Boolean indicating if the market requires whitelist.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setLenderAttestationRequired(uint256 _marketId, bool _required)\\n public\\n ownsMarket(_marketId)\\n {\\n if (_required != markets[_marketId].lenderAttestationRequired) {\\n markets[_marketId].lenderAttestationRequired = _required;\\n emit SetMarketLenderAttestation(_marketId, _required);\\n }\\n }\\n\\n /**\\n * @notice Enable/disables market whitelist for borrowers.\\n * @param _marketId The ID of a market.\\n * @param _required Boolean indicating if the market requires whitelist.\\n *\\n * Requirements:\\n * - The caller must be the current owner.\\n */\\n function setBorrowerAttestationRequired(uint256 _marketId, bool _required)\\n public\\n ownsMarket(_marketId)\\n {\\n if (_required != markets[_marketId].borrowerAttestationRequired) {\\n markets[_marketId].borrowerAttestationRequired = _required;\\n emit SetMarketBorrowerAttestation(_marketId, _required);\\n }\\n }\\n\\n /**\\n * @notice Gets the data associated with a market.\\n * @param _marketId The ID of a market.\\n */\\n function getMarketData(uint256 _marketId)\\n public\\n view\\n returns (\\n address owner,\\n uint32 paymentCycleDuration,\\n uint32 paymentDefaultDuration,\\n uint32 loanExpirationTime,\\n string memory metadataURI,\\n uint16 marketplaceFeePercent,\\n bool lenderAttestationRequired\\n )\\n {\\n return (\\n markets[_marketId].owner,\\n markets[_marketId].paymentCycleDuration,\\n markets[_marketId].paymentDefaultDuration,\\n markets[_marketId].bidExpirationTime,\\n markets[_marketId].metadataURI,\\n markets[_marketId].marketplaceFeePercent,\\n markets[_marketId].lenderAttestationRequired\\n );\\n }\\n\\n /**\\n * @notice Gets the attestation requirements for a given market.\\n * @param _marketId The ID of the market.\\n */\\n function getMarketAttestationRequirements(uint256 _marketId)\\n public\\n view\\n returns (\\n bool lenderAttestationRequired,\\n bool borrowerAttestationRequired\\n )\\n {\\n return (\\n markets[_marketId].lenderAttestationRequired,\\n markets[_marketId].borrowerAttestationRequired\\n );\\n }\\n\\n /**\\n * @notice Gets the address of a market's owner.\\n * @param _marketId The ID of a market.\\n * @return The address of a market's owner.\\n */\\n function getMarketOwner(uint256 _marketId)\\n public\\n view\\n override\\n returns (address)\\n {\\n return markets[_marketId].owner;\\n }\\n\\n /**\\n * @notice Gets the fee recipient of a market.\\n * @param _marketId The ID of a market.\\n * @return The address of a market's fee recipient.\\n */\\n function getMarketFeeRecipient(uint256 _marketId)\\n public\\n view\\n override\\n returns (address)\\n {\\n address recipient = markets[_marketId].feeRecipient;\\n\\n if (recipient == address(0)) {\\n return markets[_marketId].owner;\\n }\\n\\n return recipient;\\n }\\n\\n /**\\n * @notice Gets the metadata URI of a market.\\n * @param _marketId The ID of a market.\\n * @return URI of a market's metadata.\\n */\\n function getMarketURI(uint256 _marketId)\\n public\\n view\\n override\\n returns (string memory)\\n {\\n return markets[_marketId].metadataURI;\\n }\\n\\n /**\\n * @notice Gets the loan delinquent duration of a market.\\n * @param _marketId The ID of a market.\\n * @return Duration of a loan until it is delinquent.\\n * @return The type of payment cycle for loans in the market.\\n */\\n function getPaymentCycle(uint256 _marketId)\\n public\\n view\\n override\\n returns (uint32, PaymentCycleType)\\n {\\n return (\\n markets[_marketId].paymentCycleDuration,\\n markets[_marketId].paymentCycleType\\n );\\n }\\n\\n /**\\n * @notice Gets the loan default duration of a market.\\n * @param _marketId The ID of a market.\\n * @return Duration of a loan repayment interval until it is default.\\n */\\n function getPaymentDefaultDuration(uint256 _marketId)\\n public\\n view\\n override\\n returns (uint32)\\n {\\n return markets[_marketId].paymentDefaultDuration;\\n }\\n\\n /**\\n * @notice Get the payment type of a market.\\n * @param _marketId the ID of the market.\\n * @return The type of payment for loans in the market.\\n */\\n function getPaymentType(uint256 _marketId)\\n public\\n view\\n override\\n returns (PaymentType)\\n {\\n return markets[_marketId].paymentType;\\n }\\n\\n function getBidExpirationTime(uint256 marketId)\\n public\\n view\\n override\\n returns (uint32)\\n {\\n return markets[marketId].bidExpirationTime;\\n }\\n\\n /**\\n * @notice Gets the marketplace fee in basis points\\n * @param _marketId The ID of a market.\\n * @return fee in basis points\\n */\\n function getMarketplaceFee(uint256 _marketId)\\n public\\n view\\n override\\n returns (uint16 fee)\\n {\\n return markets[_marketId].marketplaceFeePercent;\\n }\\n\\n /**\\n * @notice Checks if a lender has been attested and added to a market.\\n * @param _marketId The ID of a market.\\n * @param _lenderAddress Address to check.\\n * @return isVerified_ Boolean indicating if a lender has been added to a market.\\n * @return uuid_ Bytes32 representing the UUID of the lender.\\n */\\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\\n public\\n view\\n override\\n returns (bool isVerified_, bytes32 uuid_)\\n {\\n return\\n _isVerified(\\n _lenderAddress,\\n markets[_marketId].lenderAttestationRequired,\\n markets[_marketId].lenderAttestationIds,\\n markets[_marketId].verifiedLendersForMarket\\n );\\n }\\n\\n /**\\n * @notice Checks if a borrower has been attested and added to a market.\\n * @param _marketId The ID of a market.\\n * @param _borrowerAddress Address of the borrower to check.\\n * @return isVerified_ Boolean indicating if a borrower has been added to a market.\\n * @return uuid_ Bytes32 representing the UUID of the borrower.\\n */\\n function isVerifiedBorrower(uint256 _marketId, address _borrowerAddress)\\n public\\n view\\n override\\n returns (bool isVerified_, bytes32 uuid_)\\n {\\n return\\n _isVerified(\\n _borrowerAddress,\\n markets[_marketId].borrowerAttestationRequired,\\n markets[_marketId].borrowerAttestationIds,\\n markets[_marketId].verifiedBorrowersForMarket\\n );\\n }\\n\\n /**\\n * @notice Gets addresses of all attested lenders.\\n * @param _marketId The ID of a market.\\n * @param _page Page index to start from.\\n * @param _perPage Number of items in a page to return.\\n * @return Array of addresses that have been added to a market.\\n */\\n function getAllVerifiedLendersForMarket(\\n uint256 _marketId,\\n uint256 _page,\\n uint256 _perPage\\n ) public view returns (address[] memory) {\\n EnumerableSet.AddressSet storage set = markets[_marketId]\\n .verifiedLendersForMarket;\\n\\n return _getStakeholdersForMarket(set, _page, _perPage);\\n }\\n\\n /**\\n * @notice Gets addresses of all attested borrowers.\\n * @param _marketId The ID of the market.\\n * @param _page Page index to start from.\\n * @param _perPage Number of items in a page to return.\\n * @return Array of addresses that have been added to a market.\\n */\\n function getAllVerifiedBorrowersForMarket(\\n uint256 _marketId,\\n uint256 _page,\\n uint256 _perPage\\n ) public view returns (address[] memory) {\\n EnumerableSet.AddressSet storage set = markets[_marketId]\\n .verifiedBorrowersForMarket;\\n return _getStakeholdersForMarket(set, _page, _perPage);\\n }\\n\\n /**\\n * @notice Sets multiple market settings for a given market.\\n * @param _marketId The ID of a market.\\n * @param _paymentCycleDuration Delinquency duration for new loans\\n * @param _newPaymentType The payment type for the market.\\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\\n * @param _paymentDefaultDuration Default duration for new loans\\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\\n * @param _metadataURI A URI that points to a market's metadata.\\n */\\n function _setMarketSettings(\\n uint256 _marketId,\\n uint32 _paymentCycleDuration,\\n PaymentType _newPaymentType,\\n PaymentCycleType _paymentCycleType,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _borrowerAttestationRequired,\\n bool _lenderAttestationRequired,\\n string calldata _metadataURI\\n ) internal {\\n setMarketURI(_marketId, _metadataURI);\\n setPaymentDefaultDuration(_marketId, _paymentDefaultDuration);\\n setBidExpirationTime(_marketId, _bidExpirationTime);\\n setMarketFeePercent(_marketId, _feePercent);\\n setLenderAttestationRequired(_marketId, _lenderAttestationRequired);\\n setBorrowerAttestationRequired(_marketId, _borrowerAttestationRequired);\\n setMarketPaymentType(_marketId, _newPaymentType);\\n setPaymentCycle(_marketId, _paymentCycleType, _paymentCycleDuration);\\n }\\n\\n /**\\n * @notice Gets addresses of all attested relevant stakeholders.\\n * @param _set The stored set of stakeholders to index from.\\n * @param _page Page index to start from.\\n * @param _perPage Number of items in a page to return.\\n * @return stakeholders_ Array of addresses that have been added to a market.\\n */\\n function _getStakeholdersForMarket(\\n EnumerableSet.AddressSet storage _set,\\n uint256 _page,\\n uint256 _perPage\\n ) internal view returns (address[] memory stakeholders_) {\\n uint256 len = _set.length();\\n\\n uint256 start = _page * _perPage;\\n if (start <= len) {\\n uint256 end = start + _perPage;\\n // Ensure we do not go out of bounds\\n if (end > len) {\\n end = len;\\n }\\n\\n stakeholders_ = new address[](end - start);\\n for (uint256 i = start; i < end; i++) {\\n stakeholders_[i] = _set.at(i);\\n }\\n }\\n }\\n\\n /* Internal Functions */\\n\\n /**\\n * @notice Adds a stakeholder (lender or borrower) to a market.\\n * @param _marketId The market ID to add a borrower to.\\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\\n * @param _expirationTime The expiration time of the attestation.\\n * @param _expirationTime The expiration time of the attestation.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n */\\n function _attestStakeholder(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n uint256 _expirationTime,\\n bool _isLender\\n )\\n internal\\n withAttestingSchema(\\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\\n )\\n {\\n require(\\n _msgSender() == markets[_marketId].owner,\\n \\\"Not the market owner\\\"\\n );\\n\\n // Submit attestation for borrower to join a market\\n bytes32 uuid = tellerAS.attest(\\n _stakeholderAddress,\\n _attestingSchemaId, // set by the modifier\\n _expirationTime,\\n 0,\\n abi.encode(_marketId, _stakeholderAddress)\\n );\\n _attestStakeholderVerification(\\n _marketId,\\n _stakeholderAddress,\\n uuid,\\n _isLender\\n );\\n }\\n\\n /**\\n * @notice Adds a stakeholder (lender or borrower) to a market via delegated attestation.\\n * @dev The signature must match that of the market owner.\\n * @param _marketId The market ID to add a lender to.\\n * @param _stakeholderAddress The address of the lender to add to the market.\\n * @param _expirationTime The expiration time of the attestation.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n * @param _v Signature value\\n * @param _r Signature value\\n * @param _s Signature value\\n */\\n function _attestStakeholderViaDelegation(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n uint256 _expirationTime,\\n bool _isLender,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n )\\n internal\\n withAttestingSchema(\\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\\n )\\n {\\n // NOTE: block scope to prevent stack too deep!\\n bytes32 uuid;\\n {\\n bytes memory data = abi.encode(_marketId, _stakeholderAddress);\\n address attestor = markets[_marketId].owner;\\n // Submit attestation for stakeholder to join a market (attestation must be signed by market owner)\\n uuid = tellerAS.attestByDelegation(\\n _stakeholderAddress,\\n _attestingSchemaId, // set by the modifier\\n _expirationTime,\\n 0,\\n data,\\n attestor,\\n _v,\\n _r,\\n _s\\n );\\n }\\n _attestStakeholderVerification(\\n _marketId,\\n _stakeholderAddress,\\n uuid,\\n _isLender\\n );\\n }\\n\\n /**\\n * @notice Adds a stakeholder (borrower/lender) to a market.\\n * @param _marketId The market ID to add a stakeholder to.\\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\\n * @param _uuid The UUID of the attestation created.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n */\\n function _attestStakeholderVerification(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n bytes32 _uuid,\\n bool _isLender\\n ) internal {\\n if (_isLender) {\\n // Store the lender attestation ID for the market ID\\n markets[_marketId].lenderAttestationIds[\\n _stakeholderAddress\\n ] = _uuid;\\n // Add lender address to market set\\n markets[_marketId].verifiedLendersForMarket.add(\\n _stakeholderAddress\\n );\\n\\n emit LenderAttestation(_marketId, _stakeholderAddress);\\n } else {\\n // Store the lender attestation ID for the market ID\\n markets[_marketId].borrowerAttestationIds[\\n _stakeholderAddress\\n ] = _uuid;\\n // Add lender address to market set\\n markets[_marketId].verifiedBorrowersForMarket.add(\\n _stakeholderAddress\\n );\\n\\n emit BorrowerAttestation(_marketId, _stakeholderAddress);\\n }\\n }\\n\\n /**\\n * @notice Removes a stakeholder from an market.\\n * @dev The caller must be the market owner.\\n * @param _marketId The market ID to remove the borrower from.\\n * @param _stakeholderAddress The address of the borrower to remove from the market.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n */\\n function _revokeStakeholder(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n bool _isLender\\n ) internal {\\n require(\\n _msgSender() == markets[_marketId].owner,\\n \\\"Not the market owner\\\"\\n );\\n\\n bytes32 uuid = _revokeStakeholderVerification(\\n _marketId,\\n _stakeholderAddress,\\n _isLender\\n );\\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\\n // tellerAS.revoke(uuid);\\n }\\n\\n /**\\n * @notice Removes a stakeholder from an market via delegated revocation.\\n * @param _marketId The market ID to remove the borrower from.\\n * @param _stakeholderAddress The address of the borrower to remove from the market.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n * @param _v Signature value\\n * @param _r Signature value\\n * @param _s Signature value\\n */\\n function _revokeStakeholderViaDelegation(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n bool _isLender,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) internal {\\n bytes32 uuid = _revokeStakeholderVerification(\\n _marketId,\\n _stakeholderAddress,\\n _isLender\\n );\\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\\n // address attestor = markets[_marketId].owner;\\n // tellerAS.revokeByDelegation(uuid, attestor, _v, _r, _s);\\n }\\n\\n /**\\n * @notice Removes a stakeholder (borrower/lender) from a market.\\n * @param _marketId The market ID to remove the lender from.\\n * @param _stakeholderAddress The address of the stakeholder to remove from the market.\\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\\n * @return uuid_ The ID of the previously verified attestation.\\n */\\n function _revokeStakeholderVerification(\\n uint256 _marketId,\\n address _stakeholderAddress,\\n bool _isLender\\n ) internal returns (bytes32 uuid_) {\\n if (_isLender) {\\n uuid_ = markets[_marketId].lenderAttestationIds[\\n _stakeholderAddress\\n ];\\n // Remove lender address from market set\\n markets[_marketId].verifiedLendersForMarket.remove(\\n _stakeholderAddress\\n );\\n\\n emit LenderRevocation(_marketId, _stakeholderAddress);\\n } else {\\n uuid_ = markets[_marketId].borrowerAttestationIds[\\n _stakeholderAddress\\n ];\\n // Remove borrower address from market set\\n markets[_marketId].verifiedBorrowersForMarket.remove(\\n _stakeholderAddress\\n );\\n\\n emit BorrowerRevocation(_marketId, _stakeholderAddress);\\n }\\n }\\n\\n /**\\n * @notice Checks if a stakeholder has been attested and added to a market.\\n * @param _stakeholderAddress Address of the stakeholder to check.\\n * @param _attestationRequired Stored boolean indicating if attestation is required for the stakeholder class.\\n * @param _stakeholderAttestationIds Mapping of attested Ids for the stakeholder class.\\n */\\n function _isVerified(\\n address _stakeholderAddress,\\n bool _attestationRequired,\\n mapping(address => bytes32) storage _stakeholderAttestationIds,\\n EnumerableSet.AddressSet storage _verifiedStakeholderForMarket\\n ) internal view returns (bool isVerified_, bytes32 uuid_) {\\n if (_attestationRequired) {\\n isVerified_ =\\n _verifiedStakeholderForMarket.contains(_stakeholderAddress) &&\\n tellerAS.isAttestationActive(\\n _stakeholderAttestationIds[_stakeholderAddress]\\n );\\n uuid_ = _stakeholderAttestationIds[_stakeholderAddress];\\n } else {\\n isVerified_ = true;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x81b5568ae3770dadab527bed63a37b5c1029047daf3bbeae01d07e44176edf68\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\\n external\\n view\\n returns (uint256 _amount);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x27778a3446cdbfed6356d5047f9926231261b37def2712a3cc63e3779350e5e4\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506132cf806100206000396000f3fe6080604052600436106102975760003560e01c80637f027a1a1161015a578063bd536e6e116100c1578063d6e794dd1161007a578063d6e794dd14610956578063ddfafef61461099d578063e4050e29146109bd578063e690e84e146109dd578063ec979082146109fd578063f9fa934514610a1357600080fd5b8063bd536e6e1461088f578063be99279b146108af578063bfacba3d146108cf578063c4d66de814610902578063c995cddc14610922578063ce46e0461461094257600080fd5b806397eb575b1161011357806397eb575b14610796578063a5630f19146107b6578063aa542fa51461080f578063ae4180951461082f578063b6b6d77f1461084f578063bc4c34951461086f57600080fd5b80637f027a1a1461069d5780638b636632146106bd5780638b975cda146106dd5780638eff9ea4146106fd578063947a75b41461076357806394e8e97e1461077657600080fd5b80633ef19a9b116101fe578063583b16ae116101b7578063583b16ae146105e75780636054b175146106075780636441379614610627578063679700d9146106475780637694d2ec1461065d5780637cfc18181461067d57600080fd5b80633ef19a9b1461053c5780633fa7f6881461055c5780634148f94c1461057c578063455154e514610591578063532f5694146105b157806354fd4d50146105d157600080fd5b80631db2b0d9116102505780631db2b0d91461043d5780631ebc7da81461046a5780632f1be8f91461048a578063344e553d146104aa5780633c0db788146104d85780633d369029146104ee57600080fd5b8063066e7513146102bc578063082fc54d146102f85780630a2e98e41461034a57806311bed5bb146103925780631a4808d2146103d05780631cc672df146103fd57600080fd5b366102b757604051631574f9f360e01b815260040160405180910390fd5b005b600080fd5b3480156102c857600080fd5b506102dc6102d73660046127b5565b610a33565b6040805192151583526020830191909152015b60405180910390f35b34801561030457600080fd5b506103356103133660046127e5565b600090815260026020526040902060060154600160401b900463ffffffff1690565b60405163ffffffff90911681526020016102ef565b34801561035657600080fd5b5061037f6103653660046127e5565b6000908152600260208190526040909120015461ffff1690565b60405161ffff90911681526020016102ef565b34801561039e57600080fd5b506103356103ad3660046127e5565b600090815260026020526040902060060154640100000000900463ffffffff1690565b3480156103dc57600080fd5b506103f06103eb3660046127e5565b610a73565b6040516102ef919061284b565b34801561040957600080fd5b5061042d6104183660046127e5565b60009081526008602052604090205460ff1690565b60405190151581526020016102ef565b34801561044957600080fd5b5061045d61045836600461285e565b610b18565b6040516102ef919061288a565b34801561047657600080fd5b506102b56104853660046127b5565b610b42565b34801561049657600080fd5b506102b56104a53660046128f0565b610bee565b3480156104b657600080fd5b506104ca6104c536600461298b565b610cbe565b6040519081526020016102ef565b3480156104e457600080fd5b506104ca60015481565b3480156104fa57600080fd5b506105246105093660046127e5565b6000908152600260205260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016102ef565b34801561054857600080fd5b506102dc6105573660046127b5565b610ce3565b34801561056857600080fd5b506102b5610577366004612a85565b610d17565b34801561058857600080fd5b506104ca600881565b34801561059d57600080fd5b506102b56105ac3660046127b5565b610d2f565b3480156105bd57600080fd5b506102b56105cc366004612adf565b610d3f565b3480156105dd57600080fd5b506104ca60075481565b3480156105f357600080fd5b506102b5610602366004612a85565b610e3c565b34801561061357600080fd5b506102b5610622366004612b2b565b610e4c565b34801561063357600080fd5b506105246106423660046127e5565b610e62565b34801561065357600080fd5b506104ca60065481565b34801561066957600080fd5b5061045d61067836600461285e565b610ea5565b34801561068957600080fd5b506102b56106983660046127b5565b610ec4565b3480156106a957600080fd5b506102b56106b83660046127e5565b610f5b565b3480156106c957600080fd5b506102b56106d83660046127b5565b610fc7565b3480156106e957600080fd5b506102b56106f8366004612b7b565b610fd3565b34801561070957600080fd5b5061074c6107183660046127e5565b6000908152600260208190526040909120908101546006909101546201000090910460ff90811692600160601b9092041690565b6040805192151583529015156020830152016102ef565b61042d610771366004612c18565b61102c565b34801561078257600080fd5b506102b5610791366004612cb8565b6110da565b3480156107a257600080fd5b506102b56107b1366004612cdd565b611197565b3480156107c257600080fd5b506108016107d13660046127e5565b60009081526002602052604090206006810154600a9091015463ffffffff90911691600160a81b90910460ff1690565b6040516102ef929190612d49565b34801561081b57600080fd5b506102b561082a366004612d6c565b6111a4565b34801561083b57600080fd5b506102b561084a3660046127e5565b61128a565b34801561085b57600080fd5b506102b561086a366004612d91565b611323565b34801561087b57600080fd5b506102b561088a366004612b2b565b61141b565b34801561089b57600080fd5b506102b56108aa3660046128f0565b61142a565b3480156108bb57600080fd5b506102b56108ca366004612cb8565b6114f7565b3480156108db57600080fd5b506108ef6108ea3660046127e5565b6115b6565b6040516102ef9796959493929190612db4565b34801561090e57600080fd5b506102b561091d366004612e13565b6116c8565b34801561092e57600080fd5b506102b561093d3660046127e5565b611a61565b34801561094e57600080fd5b50600061042d565b34801561096257600080fd5b506109906109713660046127e5565b6000908152600260205260409020600a0154600160a01b900460ff1690565b6040516102ef9190612e30565b3480156109a957600080fd5b50600954610524906001600160a01b031681565b3480156109c957600080fd5b506102b56109d8366004612cdd565b611aac565b3480156109e957600080fd5b506102b56109f8366004612e43565b611ab9565b348015610a0957600080fd5b506104ca60045481565b348015610a1f57600080fd5b506104ca610a2e366004612e81565b611cb9565b600082815260026020526040812060068101548291610a67918591600160601b90910460ff16906009810190600701611cdd565b915091505b9250929050565b6000818152600260205260409020600101805460609190610a9390612f42565b80601f0160208091040260200160405190810160405280929190818152602001828054610abf90612f42565b8015610b0c5780601f10610ae157610100808354040283529160200191610b0c565b820191906000526020600020905b815481529060010190602001808311610aef57829003601f168201915b50505050509050919050565b6000838152600260205260409020606090600301610b37818585611db7565b9150505b9392505050565b60008281526002602052604090205482906001600160a01b03163314610b835760405162461bcd60e51b8152600401610b7a90612f7d565b60405180910390fd5b600083815260026020908152604091829020600a0180546001600160a01b0319166001600160a01b0386169081179091558251868152918201527ffc7e26c4fffcd77fc52c81b32a6a6b7838b5592ced8c14c1a46e2b4a322c568a91015b60405180910390a1505050565b60008281526002602052604090205482906001600160a01b03163314610c265760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602052604090206006015463ffffffff8381166401000000009092041614610cb957600083815260026020908152604091829020600601805467ffffffff00000000191664010000000063ffffffff8716908102919091179091558251868152918201527f3e49e2efeacab7e8344acd4e7940449bf62039aa3734c34fa6d3525654be81019101610be1565b505050565b6000610cd38c8c8c8c8c8c8c8c8c8c8c611e9e565b9c9b505050505050505050505050565b60008281526002602081905260408220908101548291610a679185916201000090910460ff16906005810190600301611cdd565b610d278686866001878787611f90565b505050505050565b610d3b828260006120d5565b5050565b60008381526002602052604090205483906001600160a01b03163314610d775760405162461bcd60e51b8152600401610b7a90612f7d565b6000848152600260209081526040918290209151610d99926001019101612fa4565b604051602081830303815290604052805190602001208383604051602001610dc2929190613040565b6040516020818303038152906040528051906020012014610e36576000848152600260205260409020610df9906001018484612704565b507f6218b53065a32d32b3f52d9ad728c1b826a2aae15fc1ee92f83836debbcc1029848484604051610e2d93929190613050565b60405180910390a15b50505050565b610d278686866000878787611f90565b610e5b85856001868686612148565b5050505050565b6000818152600260205260408120600a01546001600160a01b031680610e9f5750506000908152600260205260409020546001600160a01b031690565b92915050565b6000838152600260205260409020606090600701610b37818585611db7565b60008281526002602052604090205482906001600160a01b03163314610efc5760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251868152918201527ff68f2d4b68e0d54a81a3b8e53403ddec34a1e288cf6a6f6b3621c0a47b6e36f99101610be1565b6000818152600260205260408120610f76906003013361215f565b90508015610d3b577f55e867ccc9ac324e2c193ce4ed25397fb890213c704685f2c9fbe5bd7507298682335b604080519283526001600160a01b039091166020830152015b60405180910390a15050565b610d3b828260016120d5565b60008b8152600260205260409020548b906001600160a01b0316331461100b5760405162461bcd60e51b8152600401610b7a90612f7d565b61101e8c8c8c8c8c8c8c8c8c8c8c612174565b505050505050505050505050565b60008087873060405160200161104493929190613086565b60408051601f198184030181529190528051602090910120905060008061106d878901896127b5565b91509150826005541480156110935750806001600160a01b03168b6001600160a01b0316145b80156110b857506000828152600260205260409020546001600160a01b038681169116145b806110cb57506001600160a01b03851630145b9b9a5050505050505050505050565b60008281526002602052604090205482906001600160a01b031633146111125760405162461bcd60e51b8152600401610b7a90612f7d565b6000838152600260208190526040909120015462010000900460ff16151582151514610cb957600083815260026020818152604092839020909101805462ff0000191662010000861515908102919091179091558251868152918201527f4666a8529dea37114f2ecc11706d613f7a59a7967f8467da6877820b83d405a19101610be1565b610cb983838360016121d3565b60008281526002602052604090205482906001600160a01b031633146111dc5760405162461bcd60e51b8152600401610b7a90612f7d565b6000838152600260205260409020600a0154600160a01b900460ff16600181111561120957611209612d15565b82600181111561121b5761121b612d15565b14610cb9576000838152600260205260409020600a01805483919060ff60a01b1916600160a01b83600181111561125457611254612d15565b02179055507ff81d9cc918f72edfc74e6b61d4e19ef9a739e94a0e9715b108e6af62275142ef8383604051610be19291906130ac565b60008181526002602052604090205481906001600160a01b031633146112c25760405162461bcd60e51b8152600401610b7a90612f7d565b60008281526008602052604090205460ff16610d3b5760008281526008602052604090819020805460ff19166001179055517f9dc30b8eda31a6a144e092e5de600955523a6a925cc15cc1d1b9b4872cfa615590610fbb9084815260200190565b60008281526002602052604090205482906001600160a01b0316331461135b5760405162461bcd60e51b8152600401610b7a90612f7d565b6127108261ffff1611156113a35760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b6044820152606401610b7a565b6000838152600260208190526040909120015461ffff838116911614610cb957600083815260026020818152604092839020909101805461ffff191661ffff86169081179091558251868152918201527f9c6f3e426c05d512408d4ecf517e5155756288155088ad45a81c0e111e3d18549101610be1565b610e5b85856000868686612148565b60008281526002602052604090205482906001600160a01b031633146114625760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602052604090206006015463ffffffff838116600160401b9092041614610cb95760008381526002602090815260409182902060060180546bffffffff00000000000000001916600160401b63ffffffff8716908102919091179091558251868152918201527ff0275a50e761f3b1635fa59ce199b1f2268b3fcb7fbdfb18c21aa3d2d78aa7b79101610be1565b60008281526002602052604090205482906001600160a01b0316331461152f5760405162461bcd60e51b8152600401610b7a90612f7d565b600083815260026020526040902060060154600160601b900460ff16151582151514610cb957600083815260026020908152604091829020600601805460ff60601b1916600160601b861515908102919091179091558251868152918201527fc906280af595fe94779bb9a972f24fe4e0ed7f76bebb4ee0eb9a5f30d6dd4c879101610be1565b60008181526002602081905260408220805460068201549282015460019092018054859485948594606094869485946001600160a01b039093169363ffffffff808516946401000000008104821694600160401b90910490911692909161ffff8116916201000090910460ff1690839061162f90612f42565b80601f016020809104026020016040519081016040528092919081815260200182805461165b90612f42565b80156116a85780601f1061167d576101008083540402835291602001916116a8565b820191906000526020600020905b81548152906001019060200180831161168b57829003601f168201915b505050505092509650965096509650965096509650919395979092949650565b600054610100900460ff16158080156116e85750600054600160ff909116105b806117025750303b158015611702575060005460ff166001145b6117655760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b7a565b6000805460ff191660011790558015611788576000805461ff0019166101001790555b600980546001600160a01b0319166001600160a01b038416908117909155604080516381fa6cd360e01b815290516381fa6cd391600480820192602092909190829003018186803b1580156117dc57600080fd5b505afa1580156117f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181491906130bc565b6040805163a99e7e2960e01b81526004810191909152602960448201527f2875696e74323536206d61726b657449642c2061646472657373206c656e646560648201526872416464726573732960b81b60848201523060248201526001600160a01b03919091169063a99e7e299060a401602060405180830381600087803b15801561189f57600080fd5b505af11580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d791906130d9565b600155600954604080516381fa6cd360e01b815290516001600160a01b03909216916381fa6cd391600480820192602092909190829003018186803b15801561191f57600080fd5b505afa158015611933573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195791906130bc565b6040805163a99e7e2960e01b81526004810191909152602b60448201527f2875696e74323536206d61726b657449642c206164647265737320626f72726f60648201526a776572416464726573732960a81b60848201523060248201526001600160a01b03919091169063a99e7e299060a401602060405180830381600087803b1580156119e457600080fd5b505af11580156119f8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1c91906130d9565b6006558015610d3b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610fbb565b6000818152600260205260408120611a7c906007013361215f565b90508015610d3b577f914ccbaf2f5c9c2f4b7c6be3497b6b2ceb6ce2d050aec6eb2e0e31b8f9f67f0c8233610fa2565b610cb983838360006121d3565b60008381526002602052604090205483906001600160a01b03163314611af15760405162461bcd60e51b8152600401610b7a90612f7d565b6000836001811115611b0557611b05612d15565b1480611b3157506001836001811115611b2057611b20612d15565b148015611b31575063ffffffff8216155b611b925760405162461bcd60e51b815260206004820152602c60248201527f6d6f6e74686c79207061796d656e74206379636c65206475726174696f6e206360448201526b185b9b9bdd081899481cd95d60a21b6064820152608401610b7a565b60008481526002602052604081209080856001811115611bb457611bb4612d15565b14611bc25762278d00611bc4565b835b600a830154909150600160a81b900460ff166001811115611be757611be7612d15565b856001811115611bf957611bf9612d15565b141580611c135750600682015463ffffffff828116911614155b15610d27576000868152600260205260409020600a01805486919060ff60a81b1916600160a81b836001811115611c4c57611c4c612d15565b021790555060008681526002602052604090819020600601805463ffffffff191663ffffffff8416179055517fbb20033c58b125e31641bfd5e2f4bd906d684e27472fab0648527cc39cb2918c90611ca9908890889085906130f2565b60405180910390a1505050505050565b6000611ccf8a8a8a8a8a8a8a6000808c8c611e9e565b9a9950505050505050505050565b6000808415611da957611cf08387612330565b8015611d8657506009546001600160a01b03878116600090815260208790526040908190205490516330cd251f60e21b8152600481019190915291169063c334947c9060240160206040518083038186803b158015611d4e57600080fd5b505afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d86919061311c565b6001600160a01b0387166000908152602086905260409020549092509050611dae565b600191505b94509492505050565b60606000611dc485612352565b90506000611dd2848661314f565b9050818111611e95576000611de7858361316e565b905082811115611df45750815b611dfe8282613186565b67ffffffffffffffff811115611e1657611e1661319d565b604051908082528060200260200182016040528015611e3f578160200160208202803683370190505b509350815b81811015611e9257611e56888261235c565b858281518110611e6857611e686131b3565b6001600160a01b039092166020928302919091019091015280611e8a816131c9565b915050611e44565b50505b50509392505050565b60006001600160a01b038c16611eee5760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206f776e6572206164647265737360581b6044820152606401610b7a565b600460008154611efd906131c9565b9182905550600081815260026020526040902080546001600160a01b0319166001600160a01b038f161790559050611f3e818c87878e8e8e8d8f8c8c612174565b8b6001600160a01b03167fa69fa77c6a90b171cf4e3d9a9dd6c4e56fbd1fbbdcf3925eaf600ccaa917feab82604051611f7991815260200190565b60405180910390a29b9a5050505050505050505050565b83611f9d57600654611fa1565b6001545b806005819055506000808989604051602001611fd09291909182526001600160a01b0316602082015260400190565b60405160208183030381529060405290506000600260008c815260200190815260200160002060000160009054906101000a90046001600160a01b03169050600960009054906101000a90046001600160a01b03166001600160a01b031663930ed0138b6005548c600087878e8e8e6040518a63ffffffff1660e01b8152600401612063999897969594939291906131e4565b602060405180830381600087803b15801561207d57600080fd5b505af1158015612091573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b591906130d9565b925050506120c589898389612368565b5050600060055550505050505050565b6000838152600260205260409020546001600160a01b0316336001600160a01b03161461213b5760405162461bcd60e51b81526020600482015260146024820152732737ba103a34329036b0b935b2ba1037bbb732b960611b6044820152606401610b7a565b6000610e5b84848461246a565b600061215587878761246a565b5050505050505050565b6000610b3b836001600160a01b03841661257a565b61217f8b8383610d3f565b6121898b88610bee565b6121938b8761142a565b61219d8b86611323565b6121a78b846110da565b6121b18b856114f7565b6121bb8b8a6111a4565b6121c68b898c611ab9565b5050505050505050505050565b806121e0576006546121e4565b6001545b60058190556000858152600260205260409020546001600160a01b0316336001600160a01b03161461224f5760405162461bcd60e51b81526020600482015260146024820152732737ba103a34329036b0b935b2ba1037bbb732b960611b6044820152606401610b7a565b6009546005546040516000926001600160a01b0316916309a954cd9188919088908690612294908d9086906020019182526001600160a01b0316602082015260400190565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016122c3959493929190613245565b602060405180830381600087803b1580156122dd57600080fd5b505af11580156122f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231591906130d9565b905061232386868386612368565b5050600060055550505050565b6001600160a01b03811660009081526001830160205260408120541515610b3b565b6000610e9f825490565b6000610b3b838361266d565b80156123f05760008481526002602081815260408084206001600160a01b038816855260058101835290842086905592879052526123a99060030184612697565b50604080518581526001600160a01b03851660208201527f75675690de0899b0b869d83b44b2d926ac594426b2a0286c478ecdf815cbd33e910160405180910390a1610e36565b60008481526002602081815260408084206001600160a01b0388168552600981018352908420869055928790525261242b9060070184612697565b50604080518581526001600160a01b03851660208201527f0c2cfc7e7a16ebee66e77fb314f4bfdb5505e33e77d41c0c60604efc70fd926b9101610e2d565b600081156124f5575060008381526002602081815260408084206001600160a01b038716855260058101835290842054938790529190526124ae906003018461215f565b50604080518581526001600160a01b03851660208201527f6e7c30dc58d3daa1458c79b66ca464f5f3d8a23d9e50eb14daf1cb0923bf2900910160405180910390a1610b3b565b5060008381526002602081815260408084206001600160a01b03871685526009810183529084205493879052919052612531906007018461215f565b50604080518581526001600160a01b03851660208201527fe76a3e8b220b622b9fc2a655ab867687a93f195809eb3639f422e60936ff7eb4910160405180910390a19392505050565b6000818152600183016020526040812054801561266357600061259e600183613186565b85549091506000906125b290600190613186565b90508181146126175760008660000182815481106125d2576125d26131b3565b90600052602060002001549050808760000184815481106125f5576125f56131b3565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061262857612628613283565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610e9f565b6000915050610e9f565b6000826000018281548110612684576126846131b3565b9060005260206000200154905092915050565b6000610b3b836001600160a01b03841660006126c6838360009081526001919091016020526040902054151590565b6126fc57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610e9f565b506000610e9f565b82805461271090612f42565b90600052602060002090601f0160209004810192826127325760008555612778565b82601f1061274b5782800160ff19823516178555612778565b82800160010185558215612778579182015b8281111561277857823582559160200191906001019061275d565b50612784929150612788565b5090565b5b808211156127845760008155600101612789565b6001600160a01b03811681146127b257600080fd5b50565b600080604083850312156127c857600080fd5b8235915060208301356127da8161279d565b809150509250929050565b6000602082840312156127f757600080fd5b5035919050565b6000815180845260005b8181101561282457602081850181015186830182015201612808565b81811115612836576000602083870101525b50601f01601f19169290920160200192915050565b602081526000610b3b60208301846127fe565b60008060006060848603121561287357600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b818110156128cb5783516001600160a01b0316835292840192918401916001016128a6565b50909695505050505050565b803563ffffffff811681146128eb57600080fd5b919050565b6000806040838503121561290357600080fd5b82359150612913602084016128d7565b90509250929050565b803561ffff811681146128eb57600080fd5b80151581146127b257600080fd5b600281106127b257600080fd5b60008083601f84011261295b57600080fd5b50813567ffffffffffffffff81111561297357600080fd5b602083019150836020828501011115610a6c57600080fd5b60008060008060008060008060008060006101408c8e0312156129ad57600080fd5b8b356129b88161279d565b9a506129c660208d016128d7565b99506129d460408d016128d7565b98506129e260608d016128d7565b97506129f060808d0161291c565b965060a08c0135612a008161292e565b955060c08c0135612a108161292e565b945060e08c0135612a208161293c565b93506101008c0135612a318161293c565b92506101208c013567ffffffffffffffff811115612a4e57600080fd5b612a5a8e828f01612949565b915080935050809150509295989b509295989b9093969950565b803560ff811681146128eb57600080fd5b60008060008060008060c08789031215612a9e57600080fd5b863595506020870135612ab08161279d565b945060408701359350612ac560608801612a74565b92506080870135915060a087013590509295509295509295565b600080600060408486031215612af457600080fd5b83359250602084013567ffffffffffffffff811115612b1257600080fd5b612b1e86828701612949565b9497909650939450505050565b600080600080600060a08688031215612b4357600080fd5b853594506020860135612b558161279d565b9350612b6360408701612a74565b94979396509394606081013594506080013592915050565b60008060008060008060008060008060006101408c8e031215612b9d57600080fd5b8b359a50612bad60208d016128d7565b995060408c0135612bbd8161293c565b985060608c0135612bcd8161293c565b9750612bdb60808d016128d7565b9650612be960a08d016128d7565b9550612bf760c08d0161291c565b945060e08c0135612c078161292e565b93506101008c0135612a318161292e565b600080600080600080600060a0888a031215612c3357600080fd5b8735612c3e8161279d565b9650602088013567ffffffffffffffff80821115612c5b57600080fd5b612c678b838c01612949565b909850965060408a0135915080821115612c8057600080fd5b50612c8d8a828b01612949565b909550935050606088013591506080880135612ca88161279d565b8091505092959891949750929550565b60008060408385031215612ccb57600080fd5b8235915060208301356127da8161292e565b600080600060608486031215612cf257600080fd5b833592506020840135612d048161279d565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b600281106127b257634e487b7160e01b600052602160045260246000fd5b63ffffffff8316815260408101612d5f83612d2b565b8260208301529392505050565b60008060408385031215612d7f57600080fd5b8235915060208301356127da8161293c565b60008060408385031215612da457600080fd5b823591506129136020840161291c565b6001600160a01b038816815263ffffffff878116602083015286811660408301528516606082015260e060808201819052600090612df4908301866127fe565b61ffff9490941660a08301525090151560c09091015295945050505050565b600060208284031215612e2557600080fd5b8135610b3b8161279d565b60208101612e3d83612d2b565b91905290565b600080600060608486031215612e5857600080fd5b833592506020840135612e6a8161293c565b9150612e78604085016128d7565b90509250925092565b60008060008060008060008060006101008a8c031215612ea057600080fd5b8935612eab8161279d565b9850612eb960208b016128d7565b9750612ec760408b016128d7565b9650612ed560608b016128d7565b9550612ee360808b0161291c565b945060a08a0135612ef38161292e565b935060c08a0135612f038161292e565b925060e08a013567ffffffffffffffff811115612f1f57600080fd5b612f2b8c828d01612949565b915080935050809150509295985092959850929598565b600181811c90821680612f5657607f821691505b60208210811415612f7757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600d908201526c2737ba103a34329037bbb732b960991b604082015260600190565b600080835481600182811c915080831680612fc057607f831692505b6020808410821415612fe057634e487b7160e01b86526022600452602486fd5b818015612ff4576001811461300557613032565b60ff19861689528489019650613032565b60008a81526020902060005b8681101561302a5781548b820152908501908301613011565b505084890196505b509498975050505050505050565b8183823760009101908152919050565b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b82815260408101612d5f83612d2b565b6000602082840312156130ce57600080fd5b8151610b3b8161279d565b6000602082840312156130eb57600080fd5b5051919050565b8381526060810161310284612d2b565b83602083015263ffffffff83166040830152949350505050565b60006020828403121561312e57600080fd5b8151610b3b8161292e565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561316957613169613139565b500290565b6000821982111561318157613181613139565b500190565b60008282101561319857613198613139565b500390565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006000198214156131dd576131dd613139565b5060010190565b600061012060018060a01b03808d1684528b60208501528a60408501528960608501528160808501526132198285018a6127fe565b971660a0840152505060ff9390931660c084015260e08301919091526101009091015295945050505050565b60018060a01b038616815284602082015283604082015282606082015260a06080820152600061327860a08301846127fe565b979650505050505050565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220c074c40012994dc2125608cac83e0768790fb2ae51755c124fcacd95cad98c3f64736f6c63430008090033", + "deployedBytecode": "0x6080604052600436106102975760003560e01c80637f027a1a1161015a578063bd536e6e116100c1578063d6e794dd1161007a578063d6e794dd14610956578063ddfafef61461099d578063e4050e29146109bd578063e690e84e146109dd578063ec979082146109fd578063f9fa934514610a1357600080fd5b8063bd536e6e1461088f578063be99279b146108af578063bfacba3d146108cf578063c4d66de814610902578063c995cddc14610922578063ce46e0461461094257600080fd5b806397eb575b1161011357806397eb575b14610796578063a5630f19146107b6578063aa542fa51461080f578063ae4180951461082f578063b6b6d77f1461084f578063bc4c34951461086f57600080fd5b80637f027a1a1461069d5780638b636632146106bd5780638b975cda146106dd5780638eff9ea4146106fd578063947a75b41461076357806394e8e97e1461077657600080fd5b80633ef19a9b116101fe578063583b16ae116101b7578063583b16ae146105e75780636054b175146106075780636441379614610627578063679700d9146106475780637694d2ec1461065d5780637cfc18181461067d57600080fd5b80633ef19a9b1461053c5780633fa7f6881461055c5780634148f94c1461057c578063455154e514610591578063532f5694146105b157806354fd4d50146105d157600080fd5b80631db2b0d9116102505780631db2b0d91461043d5780631ebc7da81461046a5780632f1be8f91461048a578063344e553d146104aa5780633c0db788146104d85780633d369029146104ee57600080fd5b8063066e7513146102bc578063082fc54d146102f85780630a2e98e41461034a57806311bed5bb146103925780631a4808d2146103d05780631cc672df146103fd57600080fd5b366102b757604051631574f9f360e01b815260040160405180910390fd5b005b600080fd5b3480156102c857600080fd5b506102dc6102d73660046127b5565b610a33565b6040805192151583526020830191909152015b60405180910390f35b34801561030457600080fd5b506103356103133660046127e5565b600090815260026020526040902060060154600160401b900463ffffffff1690565b60405163ffffffff90911681526020016102ef565b34801561035657600080fd5b5061037f6103653660046127e5565b6000908152600260208190526040909120015461ffff1690565b60405161ffff90911681526020016102ef565b34801561039e57600080fd5b506103356103ad3660046127e5565b600090815260026020526040902060060154640100000000900463ffffffff1690565b3480156103dc57600080fd5b506103f06103eb3660046127e5565b610a73565b6040516102ef919061284b565b34801561040957600080fd5b5061042d6104183660046127e5565b60009081526008602052604090205460ff1690565b60405190151581526020016102ef565b34801561044957600080fd5b5061045d61045836600461285e565b610b18565b6040516102ef919061288a565b34801561047657600080fd5b506102b56104853660046127b5565b610b42565b34801561049657600080fd5b506102b56104a53660046128f0565b610bee565b3480156104b657600080fd5b506104ca6104c536600461298b565b610cbe565b6040519081526020016102ef565b3480156104e457600080fd5b506104ca60015481565b3480156104fa57600080fd5b506105246105093660046127e5565b6000908152600260205260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016102ef565b34801561054857600080fd5b506102dc6105573660046127b5565b610ce3565b34801561056857600080fd5b506102b5610577366004612a85565b610d17565b34801561058857600080fd5b506104ca600881565b34801561059d57600080fd5b506102b56105ac3660046127b5565b610d2f565b3480156105bd57600080fd5b506102b56105cc366004612adf565b610d3f565b3480156105dd57600080fd5b506104ca60075481565b3480156105f357600080fd5b506102b5610602366004612a85565b610e3c565b34801561061357600080fd5b506102b5610622366004612b2b565b610e4c565b34801561063357600080fd5b506105246106423660046127e5565b610e62565b34801561065357600080fd5b506104ca60065481565b34801561066957600080fd5b5061045d61067836600461285e565b610ea5565b34801561068957600080fd5b506102b56106983660046127b5565b610ec4565b3480156106a957600080fd5b506102b56106b83660046127e5565b610f5b565b3480156106c957600080fd5b506102b56106d83660046127b5565b610fc7565b3480156106e957600080fd5b506102b56106f8366004612b7b565b610fd3565b34801561070957600080fd5b5061074c6107183660046127e5565b6000908152600260208190526040909120908101546006909101546201000090910460ff90811692600160601b9092041690565b6040805192151583529015156020830152016102ef565b61042d610771366004612c18565b61102c565b34801561078257600080fd5b506102b5610791366004612cb8565b6110da565b3480156107a257600080fd5b506102b56107b1366004612cdd565b611197565b3480156107c257600080fd5b506108016107d13660046127e5565b60009081526002602052604090206006810154600a9091015463ffffffff90911691600160a81b90910460ff1690565b6040516102ef929190612d49565b34801561081b57600080fd5b506102b561082a366004612d6c565b6111a4565b34801561083b57600080fd5b506102b561084a3660046127e5565b61128a565b34801561085b57600080fd5b506102b561086a366004612d91565b611323565b34801561087b57600080fd5b506102b561088a366004612b2b565b61141b565b34801561089b57600080fd5b506102b56108aa3660046128f0565b61142a565b3480156108bb57600080fd5b506102b56108ca366004612cb8565b6114f7565b3480156108db57600080fd5b506108ef6108ea3660046127e5565b6115b6565b6040516102ef9796959493929190612db4565b34801561090e57600080fd5b506102b561091d366004612e13565b6116c8565b34801561092e57600080fd5b506102b561093d3660046127e5565b611a61565b34801561094e57600080fd5b50600061042d565b34801561096257600080fd5b506109906109713660046127e5565b6000908152600260205260409020600a0154600160a01b900460ff1690565b6040516102ef9190612e30565b3480156109a957600080fd5b50600954610524906001600160a01b031681565b3480156109c957600080fd5b506102b56109d8366004612cdd565b611aac565b3480156109e957600080fd5b506102b56109f8366004612e43565b611ab9565b348015610a0957600080fd5b506104ca60045481565b348015610a1f57600080fd5b506104ca610a2e366004612e81565b611cb9565b600082815260026020526040812060068101548291610a67918591600160601b90910460ff16906009810190600701611cdd565b915091505b9250929050565b6000818152600260205260409020600101805460609190610a9390612f42565b80601f0160208091040260200160405190810160405280929190818152602001828054610abf90612f42565b8015610b0c5780601f10610ae157610100808354040283529160200191610b0c565b820191906000526020600020905b815481529060010190602001808311610aef57829003601f168201915b50505050509050919050565b6000838152600260205260409020606090600301610b37818585611db7565b9150505b9392505050565b60008281526002602052604090205482906001600160a01b03163314610b835760405162461bcd60e51b8152600401610b7a90612f7d565b60405180910390fd5b600083815260026020908152604091829020600a0180546001600160a01b0319166001600160a01b0386169081179091558251868152918201527ffc7e26c4fffcd77fc52c81b32a6a6b7838b5592ced8c14c1a46e2b4a322c568a91015b60405180910390a1505050565b60008281526002602052604090205482906001600160a01b03163314610c265760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602052604090206006015463ffffffff8381166401000000009092041614610cb957600083815260026020908152604091829020600601805467ffffffff00000000191664010000000063ffffffff8716908102919091179091558251868152918201527f3e49e2efeacab7e8344acd4e7940449bf62039aa3734c34fa6d3525654be81019101610be1565b505050565b6000610cd38c8c8c8c8c8c8c8c8c8c8c611e9e565b9c9b505050505050505050505050565b60008281526002602081905260408220908101548291610a679185916201000090910460ff16906005810190600301611cdd565b610d278686866001878787611f90565b505050505050565b610d3b828260006120d5565b5050565b60008381526002602052604090205483906001600160a01b03163314610d775760405162461bcd60e51b8152600401610b7a90612f7d565b6000848152600260209081526040918290209151610d99926001019101612fa4565b604051602081830303815290604052805190602001208383604051602001610dc2929190613040565b6040516020818303038152906040528051906020012014610e36576000848152600260205260409020610df9906001018484612704565b507f6218b53065a32d32b3f52d9ad728c1b826a2aae15fc1ee92f83836debbcc1029848484604051610e2d93929190613050565b60405180910390a15b50505050565b610d278686866000878787611f90565b610e5b85856001868686612148565b5050505050565b6000818152600260205260408120600a01546001600160a01b031680610e9f5750506000908152600260205260409020546001600160a01b031690565b92915050565b6000838152600260205260409020606090600701610b37818585611db7565b60008281526002602052604090205482906001600160a01b03163314610efc5760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251868152918201527ff68f2d4b68e0d54a81a3b8e53403ddec34a1e288cf6a6f6b3621c0a47b6e36f99101610be1565b6000818152600260205260408120610f76906003013361215f565b90508015610d3b577f55e867ccc9ac324e2c193ce4ed25397fb890213c704685f2c9fbe5bd7507298682335b604080519283526001600160a01b039091166020830152015b60405180910390a15050565b610d3b828260016120d5565b60008b8152600260205260409020548b906001600160a01b0316331461100b5760405162461bcd60e51b8152600401610b7a90612f7d565b61101e8c8c8c8c8c8c8c8c8c8c8c612174565b505050505050505050505050565b60008087873060405160200161104493929190613086565b60408051601f198184030181529190528051602090910120905060008061106d878901896127b5565b91509150826005541480156110935750806001600160a01b03168b6001600160a01b0316145b80156110b857506000828152600260205260409020546001600160a01b038681169116145b806110cb57506001600160a01b03851630145b9b9a5050505050505050505050565b60008281526002602052604090205482906001600160a01b031633146111125760405162461bcd60e51b8152600401610b7a90612f7d565b6000838152600260208190526040909120015462010000900460ff16151582151514610cb957600083815260026020818152604092839020909101805462ff0000191662010000861515908102919091179091558251868152918201527f4666a8529dea37114f2ecc11706d613f7a59a7967f8467da6877820b83d405a19101610be1565b610cb983838360016121d3565b60008281526002602052604090205482906001600160a01b031633146111dc5760405162461bcd60e51b8152600401610b7a90612f7d565b6000838152600260205260409020600a0154600160a01b900460ff16600181111561120957611209612d15565b82600181111561121b5761121b612d15565b14610cb9576000838152600260205260409020600a01805483919060ff60a01b1916600160a01b83600181111561125457611254612d15565b02179055507ff81d9cc918f72edfc74e6b61d4e19ef9a739e94a0e9715b108e6af62275142ef8383604051610be19291906130ac565b60008181526002602052604090205481906001600160a01b031633146112c25760405162461bcd60e51b8152600401610b7a90612f7d565b60008281526008602052604090205460ff16610d3b5760008281526008602052604090819020805460ff19166001179055517f9dc30b8eda31a6a144e092e5de600955523a6a925cc15cc1d1b9b4872cfa615590610fbb9084815260200190565b60008281526002602052604090205482906001600160a01b0316331461135b5760405162461bcd60e51b8152600401610b7a90612f7d565b6127108261ffff1611156113a35760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b6044820152606401610b7a565b6000838152600260208190526040909120015461ffff838116911614610cb957600083815260026020818152604092839020909101805461ffff191661ffff86169081179091558251868152918201527f9c6f3e426c05d512408d4ecf517e5155756288155088ad45a81c0e111e3d18549101610be1565b610e5b85856000868686612148565b60008281526002602052604090205482906001600160a01b031633146114625760405162461bcd60e51b8152600401610b7a90612f7d565b60008381526002602052604090206006015463ffffffff838116600160401b9092041614610cb95760008381526002602090815260409182902060060180546bffffffff00000000000000001916600160401b63ffffffff8716908102919091179091558251868152918201527ff0275a50e761f3b1635fa59ce199b1f2268b3fcb7fbdfb18c21aa3d2d78aa7b79101610be1565b60008281526002602052604090205482906001600160a01b0316331461152f5760405162461bcd60e51b8152600401610b7a90612f7d565b600083815260026020526040902060060154600160601b900460ff16151582151514610cb957600083815260026020908152604091829020600601805460ff60601b1916600160601b861515908102919091179091558251868152918201527fc906280af595fe94779bb9a972f24fe4e0ed7f76bebb4ee0eb9a5f30d6dd4c879101610be1565b60008181526002602081905260408220805460068201549282015460019092018054859485948594606094869485946001600160a01b039093169363ffffffff808516946401000000008104821694600160401b90910490911692909161ffff8116916201000090910460ff1690839061162f90612f42565b80601f016020809104026020016040519081016040528092919081815260200182805461165b90612f42565b80156116a85780601f1061167d576101008083540402835291602001916116a8565b820191906000526020600020905b81548152906001019060200180831161168b57829003601f168201915b505050505092509650965096509650965096509650919395979092949650565b600054610100900460ff16158080156116e85750600054600160ff909116105b806117025750303b158015611702575060005460ff166001145b6117655760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b7a565b6000805460ff191660011790558015611788576000805461ff0019166101001790555b600980546001600160a01b0319166001600160a01b038416908117909155604080516381fa6cd360e01b815290516381fa6cd391600480820192602092909190829003018186803b1580156117dc57600080fd5b505afa1580156117f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181491906130bc565b6040805163a99e7e2960e01b81526004810191909152602960448201527f2875696e74323536206d61726b657449642c2061646472657373206c656e646560648201526872416464726573732960b81b60848201523060248201526001600160a01b03919091169063a99e7e299060a401602060405180830381600087803b15801561189f57600080fd5b505af11580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d791906130d9565b600155600954604080516381fa6cd360e01b815290516001600160a01b03909216916381fa6cd391600480820192602092909190829003018186803b15801561191f57600080fd5b505afa158015611933573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195791906130bc565b6040805163a99e7e2960e01b81526004810191909152602b60448201527f2875696e74323536206d61726b657449642c206164647265737320626f72726f60648201526a776572416464726573732960a81b60848201523060248201526001600160a01b03919091169063a99e7e299060a401602060405180830381600087803b1580156119e457600080fd5b505af11580156119f8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1c91906130d9565b6006558015610d3b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610fbb565b6000818152600260205260408120611a7c906007013361215f565b90508015610d3b577f914ccbaf2f5c9c2f4b7c6be3497b6b2ceb6ce2d050aec6eb2e0e31b8f9f67f0c8233610fa2565b610cb983838360006121d3565b60008381526002602052604090205483906001600160a01b03163314611af15760405162461bcd60e51b8152600401610b7a90612f7d565b6000836001811115611b0557611b05612d15565b1480611b3157506001836001811115611b2057611b20612d15565b148015611b31575063ffffffff8216155b611b925760405162461bcd60e51b815260206004820152602c60248201527f6d6f6e74686c79207061796d656e74206379636c65206475726174696f6e206360448201526b185b9b9bdd081899481cd95d60a21b6064820152608401610b7a565b60008481526002602052604081209080856001811115611bb457611bb4612d15565b14611bc25762278d00611bc4565b835b600a830154909150600160a81b900460ff166001811115611be757611be7612d15565b856001811115611bf957611bf9612d15565b141580611c135750600682015463ffffffff828116911614155b15610d27576000868152600260205260409020600a01805486919060ff60a81b1916600160a81b836001811115611c4c57611c4c612d15565b021790555060008681526002602052604090819020600601805463ffffffff191663ffffffff8416179055517fbb20033c58b125e31641bfd5e2f4bd906d684e27472fab0648527cc39cb2918c90611ca9908890889085906130f2565b60405180910390a1505050505050565b6000611ccf8a8a8a8a8a8a8a6000808c8c611e9e565b9a9950505050505050505050565b6000808415611da957611cf08387612330565b8015611d8657506009546001600160a01b03878116600090815260208790526040908190205490516330cd251f60e21b8152600481019190915291169063c334947c9060240160206040518083038186803b158015611d4e57600080fd5b505afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d86919061311c565b6001600160a01b0387166000908152602086905260409020549092509050611dae565b600191505b94509492505050565b60606000611dc485612352565b90506000611dd2848661314f565b9050818111611e95576000611de7858361316e565b905082811115611df45750815b611dfe8282613186565b67ffffffffffffffff811115611e1657611e1661319d565b604051908082528060200260200182016040528015611e3f578160200160208202803683370190505b509350815b81811015611e9257611e56888261235c565b858281518110611e6857611e686131b3565b6001600160a01b039092166020928302919091019091015280611e8a816131c9565b915050611e44565b50505b50509392505050565b60006001600160a01b038c16611eee5760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206f776e6572206164647265737360581b6044820152606401610b7a565b600460008154611efd906131c9565b9182905550600081815260026020526040902080546001600160a01b0319166001600160a01b038f161790559050611f3e818c87878e8e8e8d8f8c8c612174565b8b6001600160a01b03167fa69fa77c6a90b171cf4e3d9a9dd6c4e56fbd1fbbdcf3925eaf600ccaa917feab82604051611f7991815260200190565b60405180910390a29b9a5050505050505050505050565b83611f9d57600654611fa1565b6001545b806005819055506000808989604051602001611fd09291909182526001600160a01b0316602082015260400190565b60405160208183030381529060405290506000600260008c815260200190815260200160002060000160009054906101000a90046001600160a01b03169050600960009054906101000a90046001600160a01b03166001600160a01b031663930ed0138b6005548c600087878e8e8e6040518a63ffffffff1660e01b8152600401612063999897969594939291906131e4565b602060405180830381600087803b15801561207d57600080fd5b505af1158015612091573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b591906130d9565b925050506120c589898389612368565b5050600060055550505050505050565b6000838152600260205260409020546001600160a01b0316336001600160a01b03161461213b5760405162461bcd60e51b81526020600482015260146024820152732737ba103a34329036b0b935b2ba1037bbb732b960611b6044820152606401610b7a565b6000610e5b84848461246a565b600061215587878761246a565b5050505050505050565b6000610b3b836001600160a01b03841661257a565b61217f8b8383610d3f565b6121898b88610bee565b6121938b8761142a565b61219d8b86611323565b6121a78b846110da565b6121b18b856114f7565b6121bb8b8a6111a4565b6121c68b898c611ab9565b5050505050505050505050565b806121e0576006546121e4565b6001545b60058190556000858152600260205260409020546001600160a01b0316336001600160a01b03161461224f5760405162461bcd60e51b81526020600482015260146024820152732737ba103a34329036b0b935b2ba1037bbb732b960611b6044820152606401610b7a565b6009546005546040516000926001600160a01b0316916309a954cd9188919088908690612294908d9086906020019182526001600160a01b0316602082015260400190565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016122c3959493929190613245565b602060405180830381600087803b1580156122dd57600080fd5b505af11580156122f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231591906130d9565b905061232386868386612368565b5050600060055550505050565b6001600160a01b03811660009081526001830160205260408120541515610b3b565b6000610e9f825490565b6000610b3b838361266d565b80156123f05760008481526002602081815260408084206001600160a01b038816855260058101835290842086905592879052526123a99060030184612697565b50604080518581526001600160a01b03851660208201527f75675690de0899b0b869d83b44b2d926ac594426b2a0286c478ecdf815cbd33e910160405180910390a1610e36565b60008481526002602081815260408084206001600160a01b0388168552600981018352908420869055928790525261242b9060070184612697565b50604080518581526001600160a01b03851660208201527f0c2cfc7e7a16ebee66e77fb314f4bfdb5505e33e77d41c0c60604efc70fd926b9101610e2d565b600081156124f5575060008381526002602081815260408084206001600160a01b038716855260058101835290842054938790529190526124ae906003018461215f565b50604080518581526001600160a01b03851660208201527f6e7c30dc58d3daa1458c79b66ca464f5f3d8a23d9e50eb14daf1cb0923bf2900910160405180910390a1610b3b565b5060008381526002602081815260408084206001600160a01b03871685526009810183529084205493879052919052612531906007018461215f565b50604080518581526001600160a01b03851660208201527fe76a3e8b220b622b9fc2a655ab867687a93f195809eb3639f422e60936ff7eb4910160405180910390a19392505050565b6000818152600183016020526040812054801561266357600061259e600183613186565b85549091506000906125b290600190613186565b90508181146126175760008660000182815481106125d2576125d26131b3565b90600052602060002001549050808760000184815481106125f5576125f56131b3565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061262857612628613283565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610e9f565b6000915050610e9f565b6000826000018281548110612684576126846131b3565b9060005260206000200154905092915050565b6000610b3b836001600160a01b03841660006126c6838360009081526001919091016020526040902054151590565b6126fc57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610e9f565b506000610e9f565b82805461271090612f42565b90600052602060002090601f0160209004810192826127325760008555612778565b82601f1061274b5782800160ff19823516178555612778565b82800160010185558215612778579182015b8281111561277857823582559160200191906001019061275d565b50612784929150612788565b5090565b5b808211156127845760008155600101612789565b6001600160a01b03811681146127b257600080fd5b50565b600080604083850312156127c857600080fd5b8235915060208301356127da8161279d565b809150509250929050565b6000602082840312156127f757600080fd5b5035919050565b6000815180845260005b8181101561282457602081850181015186830182015201612808565b81811115612836576000602083870101525b50601f01601f19169290920160200192915050565b602081526000610b3b60208301846127fe565b60008060006060848603121561287357600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b818110156128cb5783516001600160a01b0316835292840192918401916001016128a6565b50909695505050505050565b803563ffffffff811681146128eb57600080fd5b919050565b6000806040838503121561290357600080fd5b82359150612913602084016128d7565b90509250929050565b803561ffff811681146128eb57600080fd5b80151581146127b257600080fd5b600281106127b257600080fd5b60008083601f84011261295b57600080fd5b50813567ffffffffffffffff81111561297357600080fd5b602083019150836020828501011115610a6c57600080fd5b60008060008060008060008060008060006101408c8e0312156129ad57600080fd5b8b356129b88161279d565b9a506129c660208d016128d7565b99506129d460408d016128d7565b98506129e260608d016128d7565b97506129f060808d0161291c565b965060a08c0135612a008161292e565b955060c08c0135612a108161292e565b945060e08c0135612a208161293c565b93506101008c0135612a318161293c565b92506101208c013567ffffffffffffffff811115612a4e57600080fd5b612a5a8e828f01612949565b915080935050809150509295989b509295989b9093969950565b803560ff811681146128eb57600080fd5b60008060008060008060c08789031215612a9e57600080fd5b863595506020870135612ab08161279d565b945060408701359350612ac560608801612a74565b92506080870135915060a087013590509295509295509295565b600080600060408486031215612af457600080fd5b83359250602084013567ffffffffffffffff811115612b1257600080fd5b612b1e86828701612949565b9497909650939450505050565b600080600080600060a08688031215612b4357600080fd5b853594506020860135612b558161279d565b9350612b6360408701612a74565b94979396509394606081013594506080013592915050565b60008060008060008060008060008060006101408c8e031215612b9d57600080fd5b8b359a50612bad60208d016128d7565b995060408c0135612bbd8161293c565b985060608c0135612bcd8161293c565b9750612bdb60808d016128d7565b9650612be960a08d016128d7565b9550612bf760c08d0161291c565b945060e08c0135612c078161292e565b93506101008c0135612a318161292e565b600080600080600080600060a0888a031215612c3357600080fd5b8735612c3e8161279d565b9650602088013567ffffffffffffffff80821115612c5b57600080fd5b612c678b838c01612949565b909850965060408a0135915080821115612c8057600080fd5b50612c8d8a828b01612949565b909550935050606088013591506080880135612ca88161279d565b8091505092959891949750929550565b60008060408385031215612ccb57600080fd5b8235915060208301356127da8161292e565b600080600060608486031215612cf257600080fd5b833592506020840135612d048161279d565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b600281106127b257634e487b7160e01b600052602160045260246000fd5b63ffffffff8316815260408101612d5f83612d2b565b8260208301529392505050565b60008060408385031215612d7f57600080fd5b8235915060208301356127da8161293c565b60008060408385031215612da457600080fd5b823591506129136020840161291c565b6001600160a01b038816815263ffffffff878116602083015286811660408301528516606082015260e060808201819052600090612df4908301866127fe565b61ffff9490941660a08301525090151560c09091015295945050505050565b600060208284031215612e2557600080fd5b8135610b3b8161279d565b60208101612e3d83612d2b565b91905290565b600080600060608486031215612e5857600080fd5b833592506020840135612e6a8161293c565b9150612e78604085016128d7565b90509250925092565b60008060008060008060008060006101008a8c031215612ea057600080fd5b8935612eab8161279d565b9850612eb960208b016128d7565b9750612ec760408b016128d7565b9650612ed560608b016128d7565b9550612ee360808b0161291c565b945060a08a0135612ef38161292e565b935060c08a0135612f038161292e565b925060e08a013567ffffffffffffffff811115612f1f57600080fd5b612f2b8c828d01612949565b915080935050809150509295985092959850929598565b600181811c90821680612f5657607f821691505b60208210811415612f7757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600d908201526c2737ba103a34329037bbb732b960991b604082015260600190565b600080835481600182811c915080831680612fc057607f831692505b6020808410821415612fe057634e487b7160e01b86526022600452602486fd5b818015612ff4576001811461300557613032565b60ff19861689528489019650613032565b60008a81526020902060005b8681101561302a5781548b820152908501908301613011565b505084890196505b509498975050505050505050565b8183823760009101908152919050565b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b82815260408101612d5f83612d2b565b6000602082840312156130ce57600080fd5b8151610b3b8161279d565b6000602082840312156130eb57600080fd5b5051919050565b8381526060810161310284612d2b565b83602083015263ffffffff83166040830152949350505050565b60006020828403121561312e57600080fd5b8151610b3b8161292e565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561316957613169613139565b500290565b6000821982111561318157613181613139565b500190565b60008282101561319857613198613139565b500390565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006000198214156131dd576131dd613139565b5060010190565b600061012060018060a01b03808d1684528b60208501528a60408501528960608501528160808501526132198285018a6127fe565b971660a0840152505060ff9390931660c084015260e08301919091526101009091015295945050505050565b60018060a01b038616815284602082015283604082015282606082015260a06080820152600061327860a08301846127fe565b979650505050505050565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220c074c40012994dc2125608cac83e0768790fb2ae51755c124fcacd95cad98c3f64736f6c63430008090033", "devdoc": { "kind": "dev", "methods": { @@ -1934,7 +1934,7 @@ "storageLayout": { "storage": [ { - "astId": 7401, + "astId": 6027, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "_initialized", "offset": 0, @@ -1942,7 +1942,7 @@ "type": "t_uint8" }, { - "astId": 7404, + "astId": 6030, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "_initializing", "offset": 1, @@ -1950,7 +1950,7 @@ "type": "t_bool" }, { - "astId": 18129, + "astId": 17242, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "lenderAttestationSchemaId", "offset": 0, @@ -1958,15 +1958,15 @@ "type": "t_bytes32" }, { - "astId": 18134, + "astId": 17247, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "markets", "offset": 0, "slot": "2", - "type": "t_mapping(t_uint256,t_struct(Marketplace)18127_storage)" + "type": "t_mapping(t_uint256,t_struct(Marketplace)17240_storage)" }, { - "astId": 18138, + "astId": 17251, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "__uriToId", "offset": 0, @@ -1974,7 +1974,7 @@ "type": "t_mapping(t_bytes32,t_uint256)" }, { - "astId": 18140, + "astId": 17253, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "marketCount", "offset": 0, @@ -1982,7 +1982,7 @@ "type": "t_uint256" }, { - "astId": 18142, + "astId": 17255, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "_attestingSchemaId", "offset": 0, @@ -1990,7 +1990,7 @@ "type": "t_bytes32" }, { - "astId": 18144, + "astId": 17257, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "borrowerAttestationSchemaId", "offset": 0, @@ -1998,7 +1998,7 @@ "type": "t_bytes32" }, { - "astId": 18146, + "astId": 17259, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "version", "offset": 0, @@ -2006,7 +2006,7 @@ "type": "t_uint256" }, { - "astId": 18150, + "astId": 17263, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "marketIsClosed", "offset": 0, @@ -2014,12 +2014,12 @@ "type": "t_mapping(t_uint256,t_bool)" }, { - "astId": 18153, + "astId": 17266, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "tellerAS", "offset": 0, "slot": "9", - "type": "t_contract(TellerAS)16603" + "type": "t_contract(TellerAS)14978" } ], "types": { @@ -2044,17 +2044,17 @@ "label": "bytes32", "numberOfBytes": "32" }, - "t_contract(TellerAS)16603": { + "t_contract(TellerAS)14978": { "encoding": "inplace", "label": "contract TellerAS", "numberOfBytes": "20" }, - "t_enum(PaymentCycleType)27363": { + "t_enum(PaymentCycleType)26941": { "encoding": "inplace", "label": "enum PaymentCycleType", "numberOfBytes": "1" }, - "t_enum(PaymentType)27360": { + "t_enum(PaymentType)26938": { "encoding": "inplace", "label": "enum PaymentType", "numberOfBytes": "1" @@ -2080,39 +2080,39 @@ "numberOfBytes": "32", "value": "t_bool" }, - "t_mapping(t_uint256,t_struct(Marketplace)18127_storage)": { + "t_mapping(t_uint256,t_struct(Marketplace)17240_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct MarketRegistry.Marketplace)", "numberOfBytes": "32", - "value": "t_struct(Marketplace)18127_storage" + "value": "t_struct(Marketplace)17240_storage" }, "t_string_storage": { "encoding": "bytes", "label": "string", "numberOfBytes": "32" }, - "t_struct(AddressSet)14293_storage": { + "t_struct(AddressSet)12647_storage": { "encoding": "inplace", "label": "struct EnumerableSet.AddressSet", "members": [ { - "astId": 14292, + "astId": 12646, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "_inner", "offset": 0, "slot": "0", - "type": "t_struct(Set)13978_storage" + "type": "t_struct(Set)12332_storage" } ], "numberOfBytes": "64" }, - "t_struct(Marketplace)18127_storage": { + "t_struct(Marketplace)17240_storage": { "encoding": "inplace", "label": "struct MarketRegistry.Marketplace", "members": [ { - "astId": 18090, + "astId": 17203, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "owner", "offset": 0, @@ -2120,7 +2120,7 @@ "type": "t_address" }, { - "astId": 18092, + "astId": 17205, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "metadataURI", "offset": 0, @@ -2128,7 +2128,7 @@ "type": "t_string_storage" }, { - "astId": 18094, + "astId": 17207, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "marketplaceFeePercent", "offset": 0, @@ -2136,7 +2136,7 @@ "type": "t_uint16" }, { - "astId": 18096, + "astId": 17209, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "lenderAttestationRequired", "offset": 2, @@ -2144,15 +2144,15 @@ "type": "t_bool" }, { - "astId": 18099, + "astId": 17212, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "verifiedLendersForMarket", "offset": 0, "slot": "3", - "type": "t_struct(AddressSet)14293_storage" + "type": "t_struct(AddressSet)12647_storage" }, { - "astId": 18103, + "astId": 17216, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "lenderAttestationIds", "offset": 0, @@ -2160,7 +2160,7 @@ "type": "t_mapping(t_address,t_bytes32)" }, { - "astId": 18105, + "astId": 17218, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "paymentCycleDuration", "offset": 0, @@ -2168,7 +2168,7 @@ "type": "t_uint32" }, { - "astId": 18107, + "astId": 17220, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "paymentDefaultDuration", "offset": 4, @@ -2176,7 +2176,7 @@ "type": "t_uint32" }, { - "astId": 18109, + "astId": 17222, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "bidExpirationTime", "offset": 8, @@ -2184,7 +2184,7 @@ "type": "t_uint32" }, { - "astId": 18111, + "astId": 17224, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "borrowerAttestationRequired", "offset": 12, @@ -2192,15 +2192,15 @@ "type": "t_bool" }, { - "astId": 18114, + "astId": 17227, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "verifiedBorrowersForMarket", "offset": 0, "slot": "7", - "type": "t_struct(AddressSet)14293_storage" + "type": "t_struct(AddressSet)12647_storage" }, { - "astId": 18118, + "astId": 17231, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "borrowerAttestationIds", "offset": 0, @@ -2208,7 +2208,7 @@ "type": "t_mapping(t_address,t_bytes32)" }, { - "astId": 18120, + "astId": 17233, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "feeRecipient", "offset": 0, @@ -2216,30 +2216,30 @@ "type": "t_address" }, { - "astId": 18123, + "astId": 17236, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "paymentType", "offset": 20, "slot": "10", - "type": "t_enum(PaymentType)27360" + "type": "t_enum(PaymentType)26938" }, { - "astId": 18126, + "astId": 17239, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "paymentCycleType", "offset": 21, "slot": "10", - "type": "t_enum(PaymentCycleType)27363" + "type": "t_enum(PaymentCycleType)26941" } ], "numberOfBytes": "352" }, - "t_struct(Set)13978_storage": { + "t_struct(Set)12332_storage": { "encoding": "inplace", "label": "struct EnumerableSet.Set", "members": [ { - "astId": 13973, + "astId": 12327, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "_values", "offset": 0, @@ -2247,7 +2247,7 @@ "type": "t_array(t_bytes32)dyn_storage" }, { - "astId": 13977, + "astId": 12331, "contract": "contracts/MarketRegistry.sol:MarketRegistry", "label": "_indexes", "offset": 0, diff --git a/packages/contracts/deployments/goerli/MarketRegistry_Proxy.json b/packages/contracts/deployments/goerli/MarketRegistry_Proxy.json index 714ef611b..ee9d9282f 100644 --- a/packages/contracts/deployments/goerli/MarketRegistry_Proxy.json +++ b/packages/contracts/deployments/goerli/MarketRegistry_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", + "address": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", "abi": [ { "inputs": [ @@ -146,92 +146,92 @@ "type": "receive" } ], - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", - "transactionIndex": 1, - "gasUsed": "1119671", - "logsBloom": "0x04000000000000000000000000000002400000000000000000000000000000004100000000000000000000000000000080000000000000000000400000050000000000000020000000000000000002000000000000040000000000000000000000000000000000400000000000000000000000842000000000000000000008000000000000000000000000000000000000000040000080000000000000800000000000000000000000000100000400000000000000000000000000000000000000000020000000000000000000040000000000000404000000000000000040002000000000000000000000000000008000000000008008000000008000004000", - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c", - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", + "transactionIndex": 8, + "gasUsed": "1119967", + "logsBloom": "0x04000000000000000000000100000000400000010000000000000000000000000000000000000000000000000000000000000000000000000000000001040000000000000000000000000000000002000000000000040000000000000010000000000000000000000000000001000000000000800008000000000000000000000000000000000000000000000000000000000040000080000000000000800200000000004000000000000100000400000000000000000000000000040000000200000028000000000000000000040000000000008404000000000000004040010000000000000000000000000000000002000000008008000000000000000000", + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00", + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", "logs": [ { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000b43707f26d6356ae753e9c92d3c94d23c70c4057" + "0x000000000000000000000000f2b061a749ef7f983dd95aa00c698815dbfde414" ], "data": "0x", "logIndex": 0, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" }, { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x66ed2c7123FE6e95EE5Dfd27EaCD30cedb5F9cD2", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x16Ba53DDE085132b6cEb93334335f4236f6B58d4", "topics": [ "0x51a1a037ef8a642f8b5528429785b5a54e6ee54fb2d2db4b4a44480b5302d55b", - "0xa527b8a9866551c67a288f5890f65baf7ca9161bbefb8e0deb3d64d69b5a1ec6", + "0xe9fe23c0d1e41ff6510824323dafb6410722e8028be36ae209ba341c91fcad24", "0x0000000000000000000000000000000000000000000000000000000000000001" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000074ffc87282ab32c8e0969e26f93c820a213ae14600000000000000000000000074ffc87282ab32c8e0969e26f93c820a213ae14600000000000000000000000000000000000000000000000000000000000000292875696e74323536206d61726b657449642c2061646472657373206c656e64657241646472657373290000000000000000000000000000000000000000000000", + "data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000004f6908b97e4e985b849174f9904faf0a0e5041300000000000000000000000004f6908b97e4e985b849174f9904faf0a0e5041300000000000000000000000000000000000000000000000000000000000000292875696e74323536206d61726b657449642c2061646472657373206c656e64657241646472657373290000000000000000000000000000000000000000000000", "logIndex": 1, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" }, { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x66ed2c7123FE6e95EE5Dfd27EaCD30cedb5F9cD2", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x16Ba53DDE085132b6cEb93334335f4236f6B58d4", "topics": [ "0x51a1a037ef8a642f8b5528429785b5a54e6ee54fb2d2db4b4a44480b5302d55b", - "0xf76f4df82397149508696f392a80f2e2a6f717faf979b87d4636f37a00e91346", + "0x2b1743137d15722b02cc9049d12967bd29f1bfc8788995c02e3548d246e89024", "0x0000000000000000000000000000000000000000000000000000000000000002" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000074ffc87282ab32c8e0969e26f93c820a213ae14600000000000000000000000074ffc87282ab32c8e0969e26f93c820a213ae146000000000000000000000000000000000000000000000000000000000000002b2875696e74323536206d61726b657449642c206164647265737320626f72726f7765724164647265737329000000000000000000000000000000000000000000", + "data": "0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000004f6908b97e4e985b849174f9904faf0a0e5041300000000000000000000000004f6908b97e4e985b849174f9904faf0a0e50413000000000000000000000000000000000000000000000000000000000000002b2875696e74323536206d61726b657449642c206164647265737320626f72726f7765724164647265737329000000000000000000000000000000000000000000", "logIndex": 2, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" }, { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 3, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" }, { - "transactionIndex": 1, - "blockNumber": 8538442, - "transactionHash": "0xa483828107614708c307e656b8588a921c1eec5abe4ce361b199b582f5eef32d", - "address": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", + "transactionIndex": 8, + "blockNumber": 8688911, + "transactionHash": "0xb9b9613cbe37efa71931af2c373c8c5e9c2ad175b57d84f45d7bf019496a35bf", + "address": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 4, - "blockHash": "0x56436727aa0af7371ff4943f1d6cb013089ffae56c141e691bf69feacb05b79c" + "blockHash": "0x668434a379a96428741b3ef55a0c957c1d1a488b7f791746f23ff8236aabcb00" } ], - "blockNumber": 8538442, - "cumulativeGasUsed": "1140671", + "blockNumber": 8688911, + "cumulativeGasUsed": "1287967", "status": 1, "byzantium": true }, "args": [ - "0xb43707f26D6356ae753E9C92d3C94D23c70c4057", - "0x5956c8158bde236d8e3638362ff7555C329A839B", - "0xc4d66de80000000000000000000000002858023076c86347cdd7dea4f38aa215cbbca91b" + "0xf2b061a749EF7f983DD95Aa00C698815dBfde414", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0xc4d66de80000000000000000000000002b6e11aeb39af806794ba2edc975632084a375b2" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", diff --git a/packages/contracts/deployments/goerli/MetaForwarder.json b/packages/contracts/deployments/goerli/MetaForwarder.json index 039fff752..94d41912f 100644 --- a/packages/contracts/deployments/goerli/MetaForwarder.json +++ b/packages/contracts/deployments/goerli/MetaForwarder.json @@ -1,5 +1,5 @@ { - "address": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", + "address": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", "abi": [ { "anonymous": false, @@ -302,63 +302,63 @@ "type": "constructor" } ], - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", - "transactionIndex": 5, - "gasUsed": "790276", - "logsBloom": "0x00000000000000000000000000000000400000200000000000000000000000000000000000000000000000000000000000000000000020000000000800000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020200000000000080000040000000000000400000000000000000000000004000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xdd8500bfae682e38acdfebd381c4de25cf2fcf5f1cbc05fec15298bbdb30e20a", - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", + "transactionIndex": 11, + "gasUsed": "790570", + "logsBloom": "0x00000000000000000000000000800000400000000000000000000000002000000000000000000000000000000000000000000000010800000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000004000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000080000000", + "blockHash": "0x48377b81aeb0519b5146e4a14daaab08537a83d1c0e2f207664a5518ab2f2ba6", + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", "logs": [ { - "transactionIndex": 5, - "blockNumber": 8538446, - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", - "address": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", + "transactionIndex": 11, + "blockNumber": 8688904, + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", + "address": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000003d62a3a999eddf2d3dbb0cff341e60f34701816f" + "0x000000000000000000000000a2feded24002c8fc4c338828e0be58c6bc81d9cd" ], "data": "0x", "logIndex": 0, - "blockHash": "0xdd8500bfae682e38acdfebd381c4de25cf2fcf5f1cbc05fec15298bbdb30e20a" + "blockHash": "0x48377b81aeb0519b5146e4a14daaab08537a83d1c0e2f207664a5518ab2f2ba6" }, { - "transactionIndex": 5, - "blockNumber": 8538446, - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", - "address": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", + "transactionIndex": 11, + "blockNumber": 8688904, + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", + "address": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 1, - "blockHash": "0xdd8500bfae682e38acdfebd381c4de25cf2fcf5f1cbc05fec15298bbdb30e20a" + "blockHash": "0x48377b81aeb0519b5146e4a14daaab08537a83d1c0e2f207664a5518ab2f2ba6" }, { - "transactionIndex": 5, - "blockNumber": 8538446, - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", - "address": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", + "transactionIndex": 11, + "blockNumber": 8688904, + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", + "address": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 2, - "blockHash": "0xdd8500bfae682e38acdfebd381c4de25cf2fcf5f1cbc05fec15298bbdb30e20a" + "blockHash": "0x48377b81aeb0519b5146e4a14daaab08537a83d1c0e2f207664a5518ab2f2ba6" } ], - "blockNumber": 8538446, - "cumulativeGasUsed": "895276", + "blockNumber": 8688904, + "cumulativeGasUsed": "1021634", "status": 1, "byzantium": true }, "args": [ - "0x3D62a3A999edDF2d3dbB0CFf341E60F34701816F", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0xA2FEdeD24002C8FC4c338828E0Be58C6Bc81d9cd", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x8129fc1c" ], "numDeployments": 1, @@ -370,7 +370,7 @@ "methodName": "initialize", "args": [] }, - "implementation": "0x3D62a3A999edDF2d3dbB0CFf341E60F34701816F", + "implementation": "0xA2FEdeD24002C8FC4c338828E0Be58C6Bc81d9cd", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/MetaForwarder_Implementation.json b/packages/contracts/deployments/goerli/MetaForwarder_Implementation.json index cf827732a..4325ec815 100644 --- a/packages/contracts/deployments/goerli/MetaForwarder_Implementation.json +++ b/packages/contracts/deployments/goerli/MetaForwarder_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0x3D62a3A999edDF2d3dbB0CFf341E60F34701816F", + "address": "0xA2FEdeD24002C8FC4c338828E0Be58C6Bc81d9cd", "abi": [ { "anonymous": false, @@ -158,25 +158,25 @@ "type": "function" } ], - "transactionHash": "0xa9ae7d2b87df7cf0c02c3c8cd4abea71dc784fba1a692b6a32775e19d87ca203", + "transactionHash": "0x301e17f3f737dbc6ff44be8cce0f0d84e6ce119acb9951be56b9c6164fd1cab4", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x3D62a3A999edDF2d3dbB0CFf341E60F34701816F", - "transactionIndex": 4, - "gasUsed": "696924", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xA2FEdeD24002C8FC4c338828E0Be58C6Bc81d9cd", + "transactionIndex": 9, + "gasUsed": "697114", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x790132e6cef35c4d2c6c2ba635eb83dea2df5f55dcca85b60ba5d4d8cd72639e", - "transactionHash": "0xa9ae7d2b87df7cf0c02c3c8cd4abea71dc784fba1a692b6a32775e19d87ca203", + "blockHash": "0xdeb6a9f1c415a4de6623a2fb8082221e9077e9dd1504cb60bfa41c6e00884201", + "transactionHash": "0x301e17f3f737dbc6ff44be8cce0f0d84e6ce119acb9951be56b9c6164fd1cab4", "logs": [], - "blockNumber": 8538445, - "cumulativeGasUsed": "780924", + "blockNumber": 8688903, + "cumulativeGasUsed": "1067537", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "556fedad003f0c0b44fba88774cf2ef3", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct MinimalForwarderUpgradeable.ForwardRequest\",\"name\":\"req\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"execute\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"}],\"name\":\"getNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct MinimalForwarderUpgradeable.ForwardRequest\",\"name\":\"req\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"verify\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/MetaForwarder.sol\":\"MetaForwarder\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (metatx/MinimalForwarder.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/cryptography/ECDSAUpgradeable.sol\\\";\\nimport \\\"../utils/cryptography/EIP712Upgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Simple minimal forwarder to be used together with an ERC2771 compatible contract. See {ERC2771Context}.\\n *\\n * MinimalForwarder is mainly meant for testing, as it is missing features to be a good production-ready forwarder. This\\n * contract does not intend to have all the properties that are needed for a sound forwarding system. A fully\\n * functioning forwarding system with good properties requires more complexity. We suggest you look at other projects\\n * such as the GSN which do have the goal of building a system like that.\\n */\\ncontract MinimalForwarderUpgradeable is Initializable, EIP712Upgradeable {\\n using ECDSAUpgradeable for bytes32;\\n\\n struct ForwardRequest {\\n address from;\\n address to;\\n uint256 value;\\n uint256 gas;\\n uint256 nonce;\\n bytes data;\\n }\\n\\n bytes32 private constant _TYPEHASH =\\n keccak256(\\\"ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data)\\\");\\n\\n mapping(address => uint256) private _nonces;\\n\\n function __MinimalForwarder_init() internal onlyInitializing {\\n __EIP712_init_unchained(\\\"MinimalForwarder\\\", \\\"0.0.1\\\");\\n }\\n\\n function __MinimalForwarder_init_unchained() internal onlyInitializing {}\\n\\n function getNonce(address from) public view returns (uint256) {\\n return _nonces[from];\\n }\\n\\n function verify(ForwardRequest calldata req, bytes calldata signature) public view returns (bool) {\\n address signer = _hashTypedDataV4(\\n keccak256(abi.encode(_TYPEHASH, req.from, req.to, req.value, req.gas, req.nonce, keccak256(req.data)))\\n ).recover(signature);\\n return _nonces[req.from] == req.nonce && signer == req.from;\\n }\\n\\n function execute(ForwardRequest calldata req, bytes calldata signature)\\n public\\n payable\\n returns (bool, bytes memory)\\n {\\n require(verify(req, signature), \\\"MinimalForwarder: signature does not match request\\\");\\n _nonces[req.from] = req.nonce + 1;\\n\\n (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}(\\n abi.encodePacked(req.data, req.from)\\n );\\n\\n // Validate that the relayer has sent enough gas for the call.\\n // See https://ronan.eth.limo/blog/ethereum-gas-dangers/\\n if (gasleft() <= req.gas / 63) {\\n // We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since\\n // neither revert or assert consume all gas since Solidity 0.8.0\\n // https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require\\n /// @solidity memory-safe-assembly\\n assembly {\\n invalid()\\n }\\n }\\n\\n return (success, returndata);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xf5c393c6441027590d141adc100f8886f297233442c13e3d49072dd46516b249\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0x6b9a5d35b744b25529a2856a8093e7c03fb35a34b1c4fb5499e560f8ade140da\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../StringsUpgradeable.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSAUpgradeable {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV // Deprecated in v4.8\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", StringsUpgradeable.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0x12f297cafe6e2847ae0378502f155654d0764b532a9873c8afe4350950fa7971\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./ECDSAUpgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\\n *\\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\\n *\\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\\n * ({_hashTypedDataV4}).\\n *\\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\\n * the chain id to protect against replay attacks on an eventual fork of the chain.\\n *\\n * NOTE: This contract implements the version of the encoding known as \\\"v4\\\", as implemented by the JSON RPC method\\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\\n *\\n * _Available since v3.4._\\n *\\n * @custom:storage-size 52\\n */\\nabstract contract EIP712Upgradeable is Initializable {\\n /* solhint-disable var-name-mixedcase */\\n bytes32 private _HASHED_NAME;\\n bytes32 private _HASHED_VERSION;\\n bytes32 private constant _TYPE_HASH = keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\");\\n\\n /* solhint-enable var-name-mixedcase */\\n\\n /**\\n * @dev Initializes the domain separator and parameter caches.\\n *\\n * The meaning of `name` and `version` is specified in\\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\\n *\\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\\n * - `version`: the current major version of the signing domain.\\n *\\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\\n * contract upgrade].\\n */\\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\\n __EIP712_init_unchained(name, version);\\n }\\n\\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\\n bytes32 hashedName = keccak256(bytes(name));\\n bytes32 hashedVersion = keccak256(bytes(version));\\n _HASHED_NAME = hashedName;\\n _HASHED_VERSION = hashedVersion;\\n }\\n\\n /**\\n * @dev Returns the domain separator for the current chain.\\n */\\n function _domainSeparatorV4() internal view returns (bytes32) {\\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\\n }\\n\\n function _buildDomainSeparator(\\n bytes32 typeHash,\\n bytes32 nameHash,\\n bytes32 versionHash\\n ) private view returns (bytes32) {\\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\\n }\\n\\n /**\\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\\n * function returns the hash of the fully encoded EIP712 message for this domain.\\n *\\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\\n *\\n * ```solidity\\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\\n * keccak256(\\\"Mail(address to,string contents)\\\"),\\n * mailTo,\\n * keccak256(bytes(mailContents))\\n * )));\\n * address signer = ECDSA.recover(digest, signature);\\n * ```\\n */\\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\\n }\\n\\n /**\\n * @dev The hash of the name parameter for the EIP712 domain.\\n *\\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\\n * are a concern.\\n */\\n function _EIP712NameHash() internal virtual view returns (bytes32) {\\n return _HASHED_NAME;\\n }\\n\\n /**\\n * @dev The hash of the version parameter for the EIP712 domain.\\n *\\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\\n * are a concern.\\n */\\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\\n return _HASHED_VERSION;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x3017aded62c4a2b9707f5f06f92934e592c1c9b6f384b91b51340a6d5f841931\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"contracts/MetaForwarder.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol\\\";\\n\\ncontract MetaForwarder is MinimalForwarderUpgradeable {\\n function initialize() external initializer {\\n __EIP712_init_unchained(\\\"TellerMetaForwarder\\\", \\\"0.0.1\\\");\\n }\\n}\\n\",\"keccak256\":\"0xfa5f10c89d1f48cacdab608796075b70d6997e7c10024eeb67b4c1c2de4d65f2\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b50610ba6806100206000396000f3fe60806040526004361061003f5760003560e01c80632d0335ab1461004457806347153f821461008d5780638129fc1c146100ae578063bf5d3bdb146100c5575b600080fd5b34801561005057600080fd5b5061007a61005f36600461093e565b6001600160a01b031660009081526035602052604090205490565b6040519081526020015b60405180910390f35b6100a061009b36600461096e565b6100f5565b604051610084929190610a3d565b3480156100ba57600080fd5b506100c361028f565b005b3480156100d157600080fd5b506100e56100e036600461096e565b6103ea565b6040519015158152602001610084565b600060606101048585856103ea565b6101705760405162461bcd60e51b815260206004820152603260248201527f4d696e696d616c466f727761726465723a207369676e617475726520646f6573604482015271081b9bdd081b585d18da081c995c5d595cdd60721b60648201526084015b60405180910390fd5b61017f60808601356001610a79565b60356000610190602089018961093e565b6001600160a01b03166001600160a01b03168152602001908152602001600020819055506000808660200160208101906101ca919061093e565b6001600160a01b0316606088013560408901356101ea60a08b018b610a9f565b6101f760208d018d61093e565b60405160200161020993929190610ae6565b60408051601f198184030181529082905261022391610b0c565b600060405180830381858888f193505050503d8060008114610261576040519150601f19603f3d011682016040523d82523d6000602084013e610266565b606091505b50909250905061027b603f6060890135610b28565b5a1161028357fe5b90969095509350505050565b600054610100900460ff16158080156102af5750600054600160ff909116105b806102c95750303b1580156102c9575060005460ff166001145b61032c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610167565b6000805460ff19166001179055801561034f576000805461ff0019166101001790555b6103a1604051806040016040528060138152602001722a32b63632b926b2ba30a337b93bb0b93232b960691b81525060405180604001604052806005815260200164302e302e3160d81b815250610569565b80156103e7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6000806104fd84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506104f792507fdd8f4b70b0f4393e889bd39128a30628a78b61816a9eb8199759e7a349657e48915061045a905060208a018a61093e565b61046a60408b0160208c0161093e565b60408b013560608c013560808d013561048660a08f018f610a9f565b604051610494929190610b4a565b6040805191829003822060208301989098526001600160a01b0396871690820152949093166060850152608084019190915260a083015260c082015260e081019190915261010001604051602081830303815290604052805190602001206105ee565b90610642565b9050608085013560356000610515602089018961093e565b6001600160a01b03166001600160a01b0316815260200190815260200160002054148015610560575061054b602086018661093e565b6001600160a01b0316816001600160a01b0316145b95945050505050565b600054610100900460ff166105d45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610167565b815160209283012081519190920120600191909155600255565b600061063c6105fb610666565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b92915050565b600080600061065185856106e6565b9150915061065e8161072c565b509392505050565b60006106e17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f61069560015490565b6002546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b60008082516041141561071d5760208301516040840151606085015160001a6107118782858561087a565b94509450505050610725565b506000905060025b9250929050565b600081600481111561074057610740610b5a565b14156107495750565b600181600481111561075d5761075d610b5a565b14156107ab5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610167565b60028160048111156107bf576107bf610b5a565b141561080d5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610167565b600381600481111561082157610821610b5a565b14156103e75760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610167565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156108b15750600090506003610935565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610905573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661092e57600060019250925050610935565b9150600090505b94509492505050565b60006020828403121561095057600080fd5b81356001600160a01b038116811461096757600080fd5b9392505050565b60008060006040848603121561098357600080fd5b833567ffffffffffffffff8082111561099b57600080fd5b9085019060c082880312156109af57600080fd5b909350602085013590808211156109c557600080fd5b818601915086601f8301126109d957600080fd5b8135818111156109e857600080fd5b8760208285010111156109fa57600080fd5b6020830194508093505050509250925092565b60005b83811015610a28578181015183820152602001610a10565b83811115610a37576000848401525b50505050565b82151581526040602082015260008251806040840152610a64816060850160208701610a0d565b601f01601f1916919091016060019392505050565b60008219821115610a9a57634e487b7160e01b600052601160045260246000fd5b500190565b6000808335601e19843603018112610ab657600080fd5b83018035915067ffffffffffffffff821115610ad157600080fd5b60200191503681900382131561072557600080fd5b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b60008251610b1e818460208701610a0d565b9190910192915050565b600082610b4557634e487b7160e01b600052601260045260246000fd5b500490565b8183823760009101908152919050565b634e487b7160e01b600052602160045260246000fdfea26469706673582212201312f3cc133cbdbe86c238977457592d66ba240f1cae076951acb1124235a18064736f6c63430008090033", "deployedBytecode": "0x60806040526004361061003f5760003560e01c80632d0335ab1461004457806347153f821461008d5780638129fc1c146100ae578063bf5d3bdb146100c5575b600080fd5b34801561005057600080fd5b5061007a61005f36600461093e565b6001600160a01b031660009081526035602052604090205490565b6040519081526020015b60405180910390f35b6100a061009b36600461096e565b6100f5565b604051610084929190610a3d565b3480156100ba57600080fd5b506100c361028f565b005b3480156100d157600080fd5b506100e56100e036600461096e565b6103ea565b6040519015158152602001610084565b600060606101048585856103ea565b6101705760405162461bcd60e51b815260206004820152603260248201527f4d696e696d616c466f727761726465723a207369676e617475726520646f6573604482015271081b9bdd081b585d18da081c995c5d595cdd60721b60648201526084015b60405180910390fd5b61017f60808601356001610a79565b60356000610190602089018961093e565b6001600160a01b03166001600160a01b03168152602001908152602001600020819055506000808660200160208101906101ca919061093e565b6001600160a01b0316606088013560408901356101ea60a08b018b610a9f565b6101f760208d018d61093e565b60405160200161020993929190610ae6565b60408051601f198184030181529082905261022391610b0c565b600060405180830381858888f193505050503d8060008114610261576040519150601f19603f3d011682016040523d82523d6000602084013e610266565b606091505b50909250905061027b603f6060890135610b28565b5a1161028357fe5b90969095509350505050565b600054610100900460ff16158080156102af5750600054600160ff909116105b806102c95750303b1580156102c9575060005460ff166001145b61032c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610167565b6000805460ff19166001179055801561034f576000805461ff0019166101001790555b6103a1604051806040016040528060138152602001722a32b63632b926b2ba30a337b93bb0b93232b960691b81525060405180604001604052806005815260200164302e302e3160d81b815250610569565b80156103e7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6000806104fd84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506104f792507fdd8f4b70b0f4393e889bd39128a30628a78b61816a9eb8199759e7a349657e48915061045a905060208a018a61093e565b61046a60408b0160208c0161093e565b60408b013560608c013560808d013561048660a08f018f610a9f565b604051610494929190610b4a565b6040805191829003822060208301989098526001600160a01b0396871690820152949093166060850152608084019190915260a083015260c082015260e081019190915261010001604051602081830303815290604052805190602001206105ee565b90610642565b9050608085013560356000610515602089018961093e565b6001600160a01b03166001600160a01b0316815260200190815260200160002054148015610560575061054b602086018661093e565b6001600160a01b0316816001600160a01b0316145b95945050505050565b600054610100900460ff166105d45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610167565b815160209283012081519190920120600191909155600255565b600061063c6105fb610666565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b92915050565b600080600061065185856106e6565b9150915061065e8161072c565b509392505050565b60006106e17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f61069560015490565b6002546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b60008082516041141561071d5760208301516040840151606085015160001a6107118782858561087a565b94509450505050610725565b506000905060025b9250929050565b600081600481111561074057610740610b5a565b14156107495750565b600181600481111561075d5761075d610b5a565b14156107ab5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610167565b60028160048111156107bf576107bf610b5a565b141561080d5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610167565b600381600481111561082157610821610b5a565b14156103e75760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610167565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156108b15750600090506003610935565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610905573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661092e57600060019250925050610935565b9150600090505b94509492505050565b60006020828403121561095057600080fd5b81356001600160a01b038116811461096757600080fd5b9392505050565b60008060006040848603121561098357600080fd5b833567ffffffffffffffff8082111561099b57600080fd5b9085019060c082880312156109af57600080fd5b909350602085013590808211156109c557600080fd5b818601915086601f8301126109d957600080fd5b8135818111156109e857600080fd5b8760208285010111156109fa57600080fd5b6020830194508093505050509250925092565b60005b83811015610a28578181015183820152602001610a10565b83811115610a37576000848401525b50505050565b82151581526040602082015260008251806040840152610a64816060850160208701610a0d565b601f01601f1916919091016060019392505050565b60008219821115610a9a57634e487b7160e01b600052601160045260246000fd5b500190565b6000808335601e19843603018112610ab657600080fd5b83018035915067ffffffffffffffff821115610ad157600080fd5b60200191503681900382131561072557600080fd5b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b60008251610b1e818460208701610a0d565b9190910192915050565b600082610b4557634e487b7160e01b600052601260045260246000fd5b500490565b8183823760009101908152919050565b634e487b7160e01b600052602160045260246000fdfea26469706673582212201312f3cc133cbdbe86c238977457592d66ba240f1cae076951acb1124235a18064736f6c63430008090033", @@ -193,7 +193,7 @@ "storageLayout": { "storage": [ { - "astId": 1625, + "astId": 326, "contract": "contracts/MetaForwarder.sol:MetaForwarder", "label": "_initialized", "offset": 0, @@ -201,7 +201,7 @@ "type": "t_uint8" }, { - "astId": 1628, + "astId": 329, "contract": "contracts/MetaForwarder.sol:MetaForwarder", "label": "_initializing", "offset": 1, @@ -209,7 +209,7 @@ "type": "t_bool" }, { - "astId": 4458, + "astId": 3159, "contract": "contracts/MetaForwarder.sol:MetaForwarder", "label": "_HASHED_NAME", "offset": 0, @@ -217,7 +217,7 @@ "type": "t_bytes32" }, { - "astId": 4460, + "astId": 3161, "contract": "contracts/MetaForwarder.sol:MetaForwarder", "label": "_HASHED_VERSION", "offset": 0, @@ -225,7 +225,7 @@ "type": "t_bytes32" }, { - "astId": 4598, + "astId": 3299, "contract": "contracts/MetaForwarder.sol:MetaForwarder", "label": "__gap", "offset": 0, @@ -233,7 +233,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 1465, + "astId": 166, "contract": "contracts/MetaForwarder.sol:MetaForwarder", "label": "_nonces", "offset": 0, @@ -241,7 +241,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 1617, + "astId": 318, "contract": "contracts/MetaForwarder.sol:MetaForwarder", "label": "__gap", "offset": 0, diff --git a/packages/contracts/deployments/goerli/MetaForwarder_Proxy.json b/packages/contracts/deployments/goerli/MetaForwarder_Proxy.json index e99ea1260..6795a970e 100644 --- a/packages/contracts/deployments/goerli/MetaForwarder_Proxy.json +++ b/packages/contracts/deployments/goerli/MetaForwarder_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", + "address": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", "abi": [ { "inputs": [ @@ -146,63 +146,63 @@ "type": "receive" } ], - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", - "transactionIndex": 5, - "gasUsed": "790276", - "logsBloom": "0x00000000000000000000000000000000400000200000000000000000000000000000000000000000000000000000000000000000000020000000000800000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020200000000000080000040000000000000400000000000000000000000004000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xdd8500bfae682e38acdfebd381c4de25cf2fcf5f1cbc05fec15298bbdb30e20a", - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", + "transactionIndex": 11, + "gasUsed": "790570", + "logsBloom": "0x00000000000000000000000000800000400000000000000000000000002000000000000000000000000000000000000000000000010800000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000004000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000080000000", + "blockHash": "0x48377b81aeb0519b5146e4a14daaab08537a83d1c0e2f207664a5518ab2f2ba6", + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", "logs": [ { - "transactionIndex": 5, - "blockNumber": 8538446, - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", - "address": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", + "transactionIndex": 11, + "blockNumber": 8688904, + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", + "address": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000003d62a3a999eddf2d3dbb0cff341e60f34701816f" + "0x000000000000000000000000a2feded24002c8fc4c338828e0be58c6bc81d9cd" ], "data": "0x", "logIndex": 0, - "blockHash": "0xdd8500bfae682e38acdfebd381c4de25cf2fcf5f1cbc05fec15298bbdb30e20a" + "blockHash": "0x48377b81aeb0519b5146e4a14daaab08537a83d1c0e2f207664a5518ab2f2ba6" }, { - "transactionIndex": 5, - "blockNumber": 8538446, - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", - "address": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", + "transactionIndex": 11, + "blockNumber": 8688904, + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", + "address": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 1, - "blockHash": "0xdd8500bfae682e38acdfebd381c4de25cf2fcf5f1cbc05fec15298bbdb30e20a" + "blockHash": "0x48377b81aeb0519b5146e4a14daaab08537a83d1c0e2f207664a5518ab2f2ba6" }, { - "transactionIndex": 5, - "blockNumber": 8538446, - "transactionHash": "0xb56c74f52b30ca191323514237ca8a7924981a3c57f530750d6925285957a013", - "address": "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F", + "transactionIndex": 11, + "blockNumber": 8688904, + "transactionHash": "0x43f9df6f544a58f17ff3b3c9baf4d564e9c31ed447719154b12df9b02df6f7ad", + "address": "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 2, - "blockHash": "0xdd8500bfae682e38acdfebd381c4de25cf2fcf5f1cbc05fec15298bbdb30e20a" + "blockHash": "0x48377b81aeb0519b5146e4a14daaab08537a83d1c0e2f207664a5518ab2f2ba6" } ], - "blockNumber": 8538446, - "cumulativeGasUsed": "895276", + "blockNumber": 8688904, + "cumulativeGasUsed": "1021634", "status": 1, "byzantium": true }, "args": [ - "0x3D62a3A999edDF2d3dbB0CFf341E60F34701816F", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0xA2FEdeD24002C8FC4c338828E0Be58C6Bc81d9cd", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x8129fc1c" ], "numDeployments": 1, diff --git a/packages/contracts/deployments/goerli/OpenAllowlist.json b/packages/contracts/deployments/goerli/OpenAllowlist.json new file mode 100644 index 000000000..28165cf1a --- /dev/null +++ b/packages/contracts/deployments/goerli/OpenAllowlist.json @@ -0,0 +1,273 @@ +{ + "address": "0xd37e257E234Ee58d25849d7071689A4F63A74459", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "commitmentId", + "type": "uint256" + } + ], + "name": "UpdatedAllowList", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "addressIsAllowed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ], + "transactionHash": "0x36ae30631d696eddd2369f1d12ceef5ff017f096f12c3d712d3b04061783f543", + "receipt": { + "to": null, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xd37e257E234Ee58d25849d7071689A4F63A74459", + "transactionIndex": 16, + "gasUsed": "720722", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000040000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000800000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000014000000000000000000040400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x982c238bf66b00990584559fa1f1ff0dd64afb29df99c4f0ea5a87902869b369", + "transactionHash": "0x36ae30631d696eddd2369f1d12ceef5ff017f096f12c3d712d3b04061783f543", + "logs": [ + { + "transactionIndex": 16, + "blockNumber": 8689042, + "transactionHash": "0x36ae30631d696eddd2369f1d12ceef5ff017f096f12c3d712d3b04061783f543", + "address": "0xd37e257E234Ee58d25849d7071689A4F63A74459", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000b95ab1668e84644b54256b4f207faf3f43e7482e" + ], + "data": "0x", + "logIndex": 5, + "blockHash": "0x982c238bf66b00990584559fa1f1ff0dd64afb29df99c4f0ea5a87902869b369" + }, + { + "transactionIndex": 16, + "blockNumber": 8689042, + "transactionHash": "0x36ae30631d696eddd2369f1d12ceef5ff017f096f12c3d712d3b04061783f543", + "address": "0xd37e257E234Ee58d25849d7071689A4F63A74459", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", + "logIndex": 6, + "blockHash": "0x982c238bf66b00990584559fa1f1ff0dd64afb29df99c4f0ea5a87902869b369" + } + ], + "blockNumber": 8689042, + "cumulativeGasUsed": "1305880", + "status": 1, + "byzantium": true + }, + "args": [ + "0xB95ab1668e84644B54256b4f207Faf3F43e7482e", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0x" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "implementation": "0xB95ab1668e84644B54256b4f207Faf3F43e7482e", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/goerli/OpenAllowlist_Implementation.json b/packages/contracts/deployments/goerli/OpenAllowlist_Implementation.json new file mode 100644 index 000000000..4d83e5a87 --- /dev/null +++ b/packages/contracts/deployments/goerli/OpenAllowlist_Implementation.json @@ -0,0 +1,83 @@ +{ + "address": "0xB95ab1668e84644B54256b4f207Faf3F43e7482e", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "commitmentId", + "type": "uint256" + } + ], + "name": "UpdatedAllowList", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "addressIsAllowed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x62df76df4181f5e1b80abfad9769e0493c145b7b5f12596f77c30bd791ba8f87", + "receipt": { + "to": null, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xB95ab1668e84644B54256b4f207Faf3F43e7482e", + "transactionIndex": 10, + "gasUsed": "95785", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x3ebc0ce290f568fadad0716d5f71b6aa55c8800815a196a4e89134b21c8c58a5", + "transactionHash": "0x62df76df4181f5e1b80abfad9769e0493c145b7b5f12596f77c30bd791ba8f87", + "logs": [], + "blockNumber": 8689041, + "cumulativeGasUsed": "476810", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"commitmentId\",\"type\":\"uint256\"}],\"name\":\"UpdatedAllowList\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"addressIsAllowed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/allowlist/OpenAllowlist.sol\":\"OpenAllowlist\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/allowlist/OpenAllowlist.sol\":{\"content\":\"\\npragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\nimport \\\"../interfaces/allowlist/IAllowlistManager.sol\\\";\\n \\n\\ncontract OpenAllowlist is IAllowlistManager {\\n \\n event UpdatedAllowList(uint256 commitmentId); \\n\\n constructor( ){ \\n \\n }\\n\\n function addressIsAllowed(uint256, address) public virtual returns (bool) {\\n return true;\\n }\\n\\n \\n}\",\"keccak256\":\"0xa56fef86b903c5d30eb8db9c7181de0bd0babcce189b8c59cb0aceae733464e3\",\"license\":\"MIT\"},\"contracts/interfaces/allowlist/IAllowlistManager.sol\":{\"content\":\"\\n\\n\\ninterface IAllowlistManager {\\n\\n \\n function addressIsAllowed(uint256 _commitmentId,address _account) external returns (bool allowed_) ;\\n \\n}\",\"keccak256\":\"0x98b599ad422554ec62b370cad7c7c976a8698b4eb416229e07282f7fc0925ad5\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5060c48061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063b0b5316d14602d575b600080fd5b604060383660046054565b600192915050565b604051901515815260200160405180910390f35b60008060408385031215606657600080fd5b8235915060208301356001600160a01b0381168114608357600080fd5b80915050925092905056fea264697066735822122029fbf2e43a4514252fecd104dee724239be7e1a56ed24d1599279241e265c86b64736f6c63430008090033", + "deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063b0b5316d14602d575b600080fd5b604060383660046054565b600192915050565b604051901515815260200160405180910390f35b60008060408385031215606657600080fd5b8235915060208301356001600160a01b0381168114608357600080fd5b80915050925092905056fea264697066735822122029fbf2e43a4514252fecd104dee724239be7e1a56ed24d1599279241e265c86b64736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/goerli/OpenAllowlist_Proxy.json b/packages/contracts/deployments/goerli/OpenAllowlist_Proxy.json new file mode 100644 index 000000000..a0c1eb5df --- /dev/null +++ b/packages/contracts/deployments/goerli/OpenAllowlist_Proxy.json @@ -0,0 +1,235 @@ +{ + "address": "0xd37e257E234Ee58d25849d7071689A4F63A74459", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x36ae30631d696eddd2369f1d12ceef5ff017f096f12c3d712d3b04061783f543", + "receipt": { + "to": null, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xd37e257E234Ee58d25849d7071689A4F63A74459", + "transactionIndex": 16, + "gasUsed": "720722", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000040000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000800000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000014000000000000000000040400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x982c238bf66b00990584559fa1f1ff0dd64afb29df99c4f0ea5a87902869b369", + "transactionHash": "0x36ae30631d696eddd2369f1d12ceef5ff017f096f12c3d712d3b04061783f543", + "logs": [ + { + "transactionIndex": 16, + "blockNumber": 8689042, + "transactionHash": "0x36ae30631d696eddd2369f1d12ceef5ff017f096f12c3d712d3b04061783f543", + "address": "0xd37e257E234Ee58d25849d7071689A4F63A74459", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000b95ab1668e84644b54256b4f207faf3f43e7482e" + ], + "data": "0x", + "logIndex": 5, + "blockHash": "0x982c238bf66b00990584559fa1f1ff0dd64afb29df99c4f0ea5a87902869b369" + }, + { + "transactionIndex": 16, + "blockNumber": 8689042, + "transactionHash": "0x36ae30631d696eddd2369f1d12ceef5ff017f096f12c3d712d3b04061783f543", + "address": "0xd37e257E234Ee58d25849d7071689A4F63A74459", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", + "logIndex": 6, + "blockHash": "0x982c238bf66b00990584559fa1f1ff0dd64afb29df99c4f0ea5a87902869b369" + } + ], + "blockNumber": 8689042, + "cumulativeGasUsed": "1305880", + "status": 1, + "byzantium": true + }, + "args": [ + "0xB95ab1668e84644B54256b4f207Faf3F43e7482e", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0x" + ], + "numDeployments": 1, + "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", + "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/contracts/deployments/goerli/ReputationManager.json b/packages/contracts/deployments/goerli/ReputationManager.json index 4a9311804..64c832c6c 100644 --- a/packages/contracts/deployments/goerli/ReputationManager.json +++ b/packages/contracts/deployments/goerli/ReputationManager.json @@ -1,5 +1,5 @@ { - "address": "0x8cDb56283A26684D6020B3589615df2eDEDc3C8C", + "address": "0x01B14a902BCfa11005e4251fa1aA302C04c438B7", "abi": [ { "anonymous": false, @@ -361,51 +361,51 @@ "type": "constructor" } ], - "transactionHash": "0x0f16959e169ca35e6f2cb648a3e55da3977ce712a7f0b171659a45edd06d535f", + "transactionHash": "0x0a591e52970f2f4af5b9e2abe7add03db51ac6a2000cd5b976d5ef3ed5b319ac", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x8cDb56283A26684D6020B3589615df2eDEDc3C8C", - "transactionIndex": 6, - "gasUsed": "720430", - "logsBloom": "0x00000000000000004000000004000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800800000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000008000000000000000000000000000080000000000000000000002000000020000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x7762a3a2786f7bb0a879fa1d24922c64554764d2c7b0520327260b1ccb21e34d", - "transactionHash": "0x0f16959e169ca35e6f2cb648a3e55da3977ce712a7f0b171659a45edd06d535f", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x01B14a902BCfa11005e4251fa1aA302C04c438B7", + "transactionIndex": 2, + "gasUsed": "720722", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000002000000000000000000000000000000000002000000000000000000000000000000000000800000000000000000000000000000000000000000000000080000000000000010000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000004000000000000400000000000000000000008000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xcb7f45fa96a63c78a2f8e1254b2bdf20541e383805cf04d63a54d63f69acddad", + "transactionHash": "0x0a591e52970f2f4af5b9e2abe7add03db51ac6a2000cd5b976d5ef3ed5b319ac", "logs": [ { - "transactionIndex": 6, - "blockNumber": 8538449, - "transactionHash": "0x0f16959e169ca35e6f2cb648a3e55da3977ce712a7f0b171659a45edd06d535f", - "address": "0x8cDb56283A26684D6020B3589615df2eDEDc3C8C", + "transactionIndex": 2, + "blockNumber": 8688906, + "transactionHash": "0x0a591e52970f2f4af5b9e2abe7add03db51ac6a2000cd5b976d5ef3ed5b319ac", + "address": "0x01B14a902BCfa11005e4251fa1aA302C04c438B7", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000002db50ef7f702fb335ee7abb915a28aead2cb3ee8" + "0x000000000000000000000000453f4520ccbe1c973af373bd7b1193f7b7b55948" ], "data": "0x", "logIndex": 0, - "blockHash": "0x7762a3a2786f7bb0a879fa1d24922c64554764d2c7b0520327260b1ccb21e34d" + "blockHash": "0xcb7f45fa96a63c78a2f8e1254b2bdf20541e383805cf04d63a54d63f69acddad" }, { - "transactionIndex": 6, - "blockNumber": 8538449, - "transactionHash": "0x0f16959e169ca35e6f2cb648a3e55da3977ce712a7f0b171659a45edd06d535f", - "address": "0x8cDb56283A26684D6020B3589615df2eDEDc3C8C", + "transactionIndex": 2, + "blockNumber": 8688906, + "transactionHash": "0x0a591e52970f2f4af5b9e2abe7add03db51ac6a2000cd5b976d5ef3ed5b319ac", + "address": "0x01B14a902BCfa11005e4251fa1aA302C04c438B7", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 1, - "blockHash": "0x7762a3a2786f7bb0a879fa1d24922c64554764d2c7b0520327260b1ccb21e34d" + "blockHash": "0xcb7f45fa96a63c78a2f8e1254b2bdf20541e383805cf04d63a54d63f69acddad" } ], - "blockNumber": 8538449, - "cumulativeGasUsed": "846430", + "blockNumber": 8688906, + "cumulativeGasUsed": "762722", "status": 1, "byzantium": true }, "args": [ - "0x2Db50eF7F702fB335ee7AbB915a28AeAD2cb3eE8", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0x453F4520CCBE1c973Af373bd7B1193f7b7b55948", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x" ], "numDeployments": 1, @@ -413,7 +413,7 @@ "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", - "implementation": "0x2Db50eF7F702fB335ee7AbB915a28AeAD2cb3eE8", + "implementation": "0x453F4520CCBE1c973Af373bd7B1193f7b7b55948", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/ReputationManager_Implementation.json b/packages/contracts/deployments/goerli/ReputationManager_Implementation.json index 6c3c82185..964a0f0f4 100644 --- a/packages/contracts/deployments/goerli/ReputationManager_Implementation.json +++ b/packages/contracts/deployments/goerli/ReputationManager_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0x2Db50eF7F702fB335ee7AbB915a28AeAD2cb3eE8", + "address": "0x453F4520CCBE1c973Af373bd7B1193f7b7b55948", "abi": [ { "anonymous": false, @@ -217,28 +217,28 @@ "type": "function" } ], - "transactionHash": "0x6f9dafb648e706ce6c134545e1297d23c5dd65aff9d7f237ea1dccde0f54ce35", + "transactionHash": "0xf5244371a76487dcdc8c960df2081cfaf386710599c42bd37f1455203db8c775", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x2Db50eF7F702fB335ee7AbB915a28AeAD2cb3eE8", - "transactionIndex": 3, - "gasUsed": "711505", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x453F4520CCBE1c973Af373bd7B1193f7b7b55948", + "transactionIndex": 9, + "gasUsed": "711699", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x09105eebaae4e77307fee833b8779e32d75dd5850518f8be09627bdfdc2ea6e5", - "transactionHash": "0x6f9dafb648e706ce6c134545e1297d23c5dd65aff9d7f237ea1dccde0f54ce35", + "blockHash": "0xc28a8168866caa7eec903e00ae7d0960e9f7774b8dbb5ef6b97e4a6ab479efcd", + "transactionHash": "0xf5244371a76487dcdc8c960df2081cfaf386710599c42bd37f1455203db8c775", "logs": [], - "blockNumber": 8538447, - "cumulativeGasUsed": "774505", + "blockNumber": 8688905, + "cumulativeGasUsed": "900699", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "060a0e06ef3f72cfc1caa979d18de7ca", - "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"enum RepMark\",\"name\":\"repMark\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"MarkAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"enum RepMark\",\"name\":\"repMark\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"MarkRemoved\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CONTROLLER\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"getCurrentDefaultLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"getCurrentDelinquentLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"getDefaultedLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"getDelinquentLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tellerV2\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tellerV2\",\"outputs\":[{\"internalType\":\"contract ITellerV2\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"updateAccountReputation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"updateAccountReputation\",\"outputs\":[{\"internalType\":\"enum RepMark\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"initialize(address)\":{\"notice\":\"Initializes the proxy.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ReputationManager.sol\":\"ReputationManager\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x3798da9e212cd00a7cda94ddb5a9721171a718e89c500d8901f810e0e37fa74e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/ReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\n// Interfaces\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\n\\n// Libraries\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract ReputationManager is IReputationManager, Initializable {\\n using EnumerableSet for EnumerableSet.UintSet;\\n\\n bytes32 public constant CONTROLLER = keccak256(\\\"CONTROLLER\\\");\\n\\n ITellerV2 public tellerV2;\\n mapping(address => EnumerableSet.UintSet) private _delinquencies;\\n mapping(address => EnumerableSet.UintSet) private _defaults;\\n mapping(address => EnumerableSet.UintSet) private _currentDelinquencies;\\n mapping(address => EnumerableSet.UintSet) private _currentDefaults;\\n\\n event MarkAdded(\\n address indexed account,\\n RepMark indexed repMark,\\n uint256 bidId\\n );\\n event MarkRemoved(\\n address indexed account,\\n RepMark indexed repMark,\\n uint256 bidId\\n );\\n\\n /**\\n * @notice Initializes the proxy.\\n */\\n function initialize(address _tellerV2) external initializer {\\n tellerV2 = ITellerV2(_tellerV2);\\n }\\n\\n function getDelinquentLoanIds(address _account)\\n public\\n override\\n returns (uint256[] memory)\\n {\\n updateAccountReputation(_account);\\n return _delinquencies[_account].values();\\n }\\n\\n function getDefaultedLoanIds(address _account)\\n public\\n override\\n returns (uint256[] memory)\\n {\\n updateAccountReputation(_account);\\n return _defaults[_account].values();\\n }\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n public\\n override\\n returns (uint256[] memory)\\n {\\n updateAccountReputation(_account);\\n return _currentDelinquencies[_account].values();\\n }\\n\\n function getCurrentDefaultLoanIds(address _account)\\n public\\n override\\n returns (uint256[] memory)\\n {\\n updateAccountReputation(_account);\\n return _currentDefaults[_account].values();\\n }\\n\\n function updateAccountReputation(address _account) public override {\\n uint256[] memory activeBidIds = tellerV2.getBorrowerActiveLoanIds(\\n _account\\n );\\n for (uint256 i; i < activeBidIds.length; i++) {\\n _applyReputation(_account, activeBidIds[i]);\\n }\\n }\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n public\\n override\\n returns (RepMark)\\n {\\n return _applyReputation(_account, _bidId);\\n }\\n\\n function _applyReputation(address _account, uint256 _bidId)\\n internal\\n returns (RepMark mark_)\\n {\\n mark_ = RepMark.Good;\\n\\n if (tellerV2.isLoanDefaulted(_bidId)) {\\n mark_ = RepMark.Default;\\n\\n // Remove delinquent status\\n _removeMark(_account, _bidId, RepMark.Delinquent);\\n } else if (tellerV2.isPaymentLate(_bidId)) {\\n mark_ = RepMark.Delinquent;\\n }\\n\\n // Mark status if not \\\"Good\\\"\\n if (mark_ != RepMark.Good) {\\n _addMark(_account, _bidId, mark_);\\n }\\n }\\n\\n function _addMark(address _account, uint256 _bidId, RepMark _mark)\\n internal\\n {\\n if (_mark == RepMark.Delinquent) {\\n _delinquencies[_account].add(_bidId);\\n _currentDelinquencies[_account].add(_bidId);\\n } else if (_mark == RepMark.Default) {\\n _defaults[_account].add(_bidId);\\n _currentDefaults[_account].add(_bidId);\\n }\\n\\n emit MarkAdded(_account, _mark, _bidId);\\n }\\n\\n function _removeMark(address _account, uint256 _bidId, RepMark _mark)\\n internal\\n {\\n if (_mark == RepMark.Delinquent) {\\n _currentDelinquencies[_account].remove(_bidId);\\n } else if (_mark == RepMark.Default) {\\n _currentDefaults[_account].remove(_bidId);\\n }\\n\\n emit MarkRemoved(_account, _mark, _bidId);\\n }\\n}\\n\",\"keccak256\":\"0xad9c8a70f7f3caf1e3d2875f166a8a85ca8524ff0ae0168a96c85291c459d8d5\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public _lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public _totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal lendingTokensSet;\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x600fd24b7211e1883081b4389fbc715365afe563a56808f904a83235e6efbe2b\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x549d37cb1390adad543f2e7b1ad46104c4326c4af7dbccda35116833103a6465\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x62c61e6811becc51d0d644e54c342279565e9d8ff5a386cde5a784440a404da7\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b50610beb806100206000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063941675db11610066578063941675db146100fc578063c4d66de81461012d578063c7312e4714610140578063e0d5343d14610160578063ee0fc1211461017357600080fd5b806303c04b2814610098578063287b498a146100c15780637076185c146100d457806376604b37146100e9575b600080fd5b6100ab6100a6366004610984565b6101a8565b6040516100b8919061099f565b60405180910390f35b6100ab6100cf366004610984565b6101da565b6100e76100e2366004610984565b610206565b005b6100ab6100f7366004610984565b6102d8565b600054610115906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100e761013b366004610984565b610304565b61015361014e3660046109e3565b610434565b6040516100b89190610a23565b6100ab61016e366004610984565b610447565b61019a7f70546d1c92f8c2132ae23a23f5177aa8526356051c7510df99f50e012d22152981565b6040519081526020016100b8565b60606101b382610206565b6001600160a01b03821660009081526002602052604090206101d49061046f565b92915050565b60606101e582610206565b6001600160a01b03821660009081526004602052604090206101d49061046f565b6000805460405163054de0ff60e01b81526001600160a01b038481166004830152620100009092049091169063054de0ff9060240160006040518083038186803b15801561025357600080fd5b505afa158015610267573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261028f9190810190610a61565b905060005b81518110156102d3576102c0838383815181106102b3576102b3610b1f565b602002602001015161047c565b50806102cb81610b4b565b915050610294565b505050565b60606102e382610206565b6001600160a01b03821660009081526001602052604090206101d49061046f565b600054610100900460ff16158080156103245750600054600160ff909116105b8061033e5750303b15801561033e575060005460ff166001145b6103a55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff1916600117905580156103c8576000805461ff0019166101001790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015610430576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6000610440838361047c565b9392505050565b606061045282610206565b6001600160a01b03821660009081526003602052604090206101d4905b60606000610440836105c5565b6000805460405163e8cbab0960e01b815260048101849052620100009091046001600160a01b03169063e8cbab099060240160206040518083038186803b1580156104c657600080fd5b505afa1580156104da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104fe9190610b66565b156105175750600261051283836001610621565b6105a1565b60005460405163093f561760e01b815260048101849052620100009091046001600160a01b03169063093f56179060240160206040518083038186803b15801561056057600080fd5b505afa158015610574573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105989190610b66565b156105a1575060015b60008160028111156105b5576105b5610a0d565b146101d4576101d48383836106fb565b60608160000180548060200260200160405190810160405280929190818152602001828054801561061557602002820191906000526020600020905b815481526020019060010190808311610601575b50505050509050919050565b600181600281111561063557610635610a0d565b1415610663576001600160a01b038316600090815260036020526040902061065d908361080e565b506106a1565b600281600281111561067757610677610a0d565b14156106a1576001600160a01b038316600090815260046020526040902061069f908361080e565b505b8060028111156106b3576106b3610a0d565b836001600160a01b03167f3b90fa143863a45908a7b69d67a369f6e401bfc21b1f1873b2c18f7dfdf0dd27846040516106ee91815260200190565b60405180910390a3505050565b600181600281111561070f5761070f610a0d565b1415610760576001600160a01b0383166000908152600160205260409020610737908361081a565b506001600160a01b038316600090815260036020526040902061075a908361081a565b506107c1565b600281600281111561077457610774610a0d565b14156107c1576001600160a01b038316600090815260026020526040902061079c908361081a565b506001600160a01b03831660009081526004602052604090206107bf908361081a565b505b8060028111156107d3576107d3610a0d565b836001600160a01b03167f07ffa1c77b3c4d3bf16ff59253da47ed8e8a4367376d6caf4bf66469977bc5db846040516106ee91815260200190565b60006104408383610826565b60006104408383610919565b6000818152600183016020526040812054801561090f57600061084a600183610b88565b855490915060009061085e90600190610b88565b90508181146108c357600086600001828154811061087e5761087e610b1f565b90600052602060002001549050808760000184815481106108a1576108a1610b1f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806108d4576108d4610b9f565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506101d4565b60009150506101d4565b6000818152600183016020526040812054610960575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556101d4565b5060006101d4565b80356001600160a01b038116811461097f57600080fd5b919050565b60006020828403121561099657600080fd5b61044082610968565b6020808252825182820181905260009190848201906040850190845b818110156109d7578351835292840192918401916001016109bb565b50909695505050505050565b600080604083850312156109f657600080fd5b6109ff83610968565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6020810160038310610a4557634e487b7160e01b600052602160045260246000fd5b91905290565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215610a7457600080fd5b825167ffffffffffffffff80821115610a8c57600080fd5b818501915085601f830112610aa057600080fd5b815181811115610ab257610ab2610a4b565b8060051b604051601f19603f83011681018181108582111715610ad757610ad7610a4b565b604052918252848201925083810185019188831115610af557600080fd5b938501935b82851015610b1357845184529385019392850192610afa565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415610b5f57610b5f610b35565b5060010190565b600060208284031215610b7857600080fd5b8151801515811461044057600080fd5b600082821015610b9a57610b9a610b35565b500390565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220d09d10c0526482a046efa0c64e90ffd936df3fa6d328f5f3cc3257e3b35606a664736f6c63430008090033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063941675db11610066578063941675db146100fc578063c4d66de81461012d578063c7312e4714610140578063e0d5343d14610160578063ee0fc1211461017357600080fd5b806303c04b2814610098578063287b498a146100c15780637076185c146100d457806376604b37146100e9575b600080fd5b6100ab6100a6366004610984565b6101a8565b6040516100b8919061099f565b60405180910390f35b6100ab6100cf366004610984565b6101da565b6100e76100e2366004610984565b610206565b005b6100ab6100f7366004610984565b6102d8565b600054610115906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100e761013b366004610984565b610304565b61015361014e3660046109e3565b610434565b6040516100b89190610a23565b6100ab61016e366004610984565b610447565b61019a7f70546d1c92f8c2132ae23a23f5177aa8526356051c7510df99f50e012d22152981565b6040519081526020016100b8565b60606101b382610206565b6001600160a01b03821660009081526002602052604090206101d49061046f565b92915050565b60606101e582610206565b6001600160a01b03821660009081526004602052604090206101d49061046f565b6000805460405163054de0ff60e01b81526001600160a01b038481166004830152620100009092049091169063054de0ff9060240160006040518083038186803b15801561025357600080fd5b505afa158015610267573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261028f9190810190610a61565b905060005b81518110156102d3576102c0838383815181106102b3576102b3610b1f565b602002602001015161047c565b50806102cb81610b4b565b915050610294565b505050565b60606102e382610206565b6001600160a01b03821660009081526001602052604090206101d49061046f565b600054610100900460ff16158080156103245750600054600160ff909116105b8061033e5750303b15801561033e575060005460ff166001145b6103a55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff1916600117905580156103c8576000805461ff0019166101001790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015610430576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6000610440838361047c565b9392505050565b606061045282610206565b6001600160a01b03821660009081526003602052604090206101d4905b60606000610440836105c5565b6000805460405163e8cbab0960e01b815260048101849052620100009091046001600160a01b03169063e8cbab099060240160206040518083038186803b1580156104c657600080fd5b505afa1580156104da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104fe9190610b66565b156105175750600261051283836001610621565b6105a1565b60005460405163093f561760e01b815260048101849052620100009091046001600160a01b03169063093f56179060240160206040518083038186803b15801561056057600080fd5b505afa158015610574573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105989190610b66565b156105a1575060015b60008160028111156105b5576105b5610a0d565b146101d4576101d48383836106fb565b60608160000180548060200260200160405190810160405280929190818152602001828054801561061557602002820191906000526020600020905b815481526020019060010190808311610601575b50505050509050919050565b600181600281111561063557610635610a0d565b1415610663576001600160a01b038316600090815260036020526040902061065d908361080e565b506106a1565b600281600281111561067757610677610a0d565b14156106a1576001600160a01b038316600090815260046020526040902061069f908361080e565b505b8060028111156106b3576106b3610a0d565b836001600160a01b03167f3b90fa143863a45908a7b69d67a369f6e401bfc21b1f1873b2c18f7dfdf0dd27846040516106ee91815260200190565b60405180910390a3505050565b600181600281111561070f5761070f610a0d565b1415610760576001600160a01b0383166000908152600160205260409020610737908361081a565b506001600160a01b038316600090815260036020526040902061075a908361081a565b506107c1565b600281600281111561077457610774610a0d565b14156107c1576001600160a01b038316600090815260026020526040902061079c908361081a565b506001600160a01b03831660009081526004602052604090206107bf908361081a565b505b8060028111156107d3576107d3610a0d565b836001600160a01b03167f07ffa1c77b3c4d3bf16ff59253da47ed8e8a4367376d6caf4bf66469977bc5db846040516106ee91815260200190565b60006104408383610826565b60006104408383610919565b6000818152600183016020526040812054801561090f57600061084a600183610b88565b855490915060009061085e90600190610b88565b90508181146108c357600086600001828154811061087e5761087e610b1f565b90600052602060002001549050808760000184815481106108a1576108a1610b1f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806108d4576108d4610b9f565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506101d4565b60009150506101d4565b6000818152600183016020526040812054610960575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556101d4565b5060006101d4565b80356001600160a01b038116811461097f57600080fd5b919050565b60006020828403121561099657600080fd5b61044082610968565b6020808252825182820181905260009190848201906040850190845b818110156109d7578351835292840192918401916001016109bb565b50909695505050505050565b600080604083850312156109f657600080fd5b6109ff83610968565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6020810160038310610a4557634e487b7160e01b600052602160045260246000fd5b91905290565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215610a7457600080fd5b825167ffffffffffffffff80821115610a8c57600080fd5b818501915085601f830112610aa057600080fd5b815181811115610ab257610ab2610a4b565b8060051b604051601f19603f83011681018181108582111715610ad757610ad7610a4b565b604052918252848201925083810185019188831115610af557600080fd5b938501935b82851015610b1357845184529385019392850192610afa565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415610b5f57610b5f610b35565b5060010190565b600060208284031215610b7857600080fd5b8151801515811461044057600080fd5b600082821015610b9a57610b9a610b35565b500390565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220d09d10c0526482a046efa0c64e90ffd936df3fa6d328f5f3cc3257e3b35606a664736f6c63430008090033", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"enum RepMark\",\"name\":\"repMark\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"MarkAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"enum RepMark\",\"name\":\"repMark\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"MarkRemoved\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CONTROLLER\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"getCurrentDefaultLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"getCurrentDelinquentLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"getDefaultedLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"getDelinquentLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tellerV2\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tellerV2\",\"outputs\":[{\"internalType\":\"contract ITellerV2\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"updateAccountReputation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"updateAccountReputation\",\"outputs\":[{\"internalType\":\"enum RepMark\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"initialize(address)\":{\"notice\":\"Initializes the proxy.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ReputationManager.sol\":\"ReputationManager\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/Address.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x3798da9e212cd00a7cda94ddb5a9721171a718e89c500d8901f810e0e37fa74e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/ReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\n// Interfaces\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/utils/Initializable.sol\\\";\\n\\n// Libraries\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\n\\ncontract ReputationManager is IReputationManager, Initializable {\\n using EnumerableSet for EnumerableSet.UintSet;\\n\\n bytes32 public constant CONTROLLER = keccak256(\\\"CONTROLLER\\\");\\n\\n ITellerV2 public tellerV2;\\n mapping(address => EnumerableSet.UintSet) private _delinquencies;\\n mapping(address => EnumerableSet.UintSet) private _defaults;\\n mapping(address => EnumerableSet.UintSet) private _currentDelinquencies;\\n mapping(address => EnumerableSet.UintSet) private _currentDefaults;\\n\\n event MarkAdded(\\n address indexed account,\\n RepMark indexed repMark,\\n uint256 bidId\\n );\\n event MarkRemoved(\\n address indexed account,\\n RepMark indexed repMark,\\n uint256 bidId\\n );\\n\\n /**\\n * @notice Initializes the proxy.\\n */\\n function initialize(address _tellerV2) external initializer {\\n tellerV2 = ITellerV2(_tellerV2);\\n }\\n\\n function getDelinquentLoanIds(address _account)\\n public\\n override\\n returns (uint256[] memory)\\n {\\n updateAccountReputation(_account);\\n return _delinquencies[_account].values();\\n }\\n\\n function getDefaultedLoanIds(address _account)\\n public\\n override\\n returns (uint256[] memory)\\n {\\n updateAccountReputation(_account);\\n return _defaults[_account].values();\\n }\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n public\\n override\\n returns (uint256[] memory)\\n {\\n updateAccountReputation(_account);\\n return _currentDelinquencies[_account].values();\\n }\\n\\n function getCurrentDefaultLoanIds(address _account)\\n public\\n override\\n returns (uint256[] memory)\\n {\\n updateAccountReputation(_account);\\n return _currentDefaults[_account].values();\\n }\\n\\n function updateAccountReputation(address _account) public override {\\n uint256[] memory activeBidIds = tellerV2.getBorrowerActiveLoanIds(\\n _account\\n );\\n for (uint256 i; i < activeBidIds.length; i++) {\\n _applyReputation(_account, activeBidIds[i]);\\n }\\n }\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n public\\n override\\n returns (RepMark)\\n {\\n return _applyReputation(_account, _bidId);\\n }\\n\\n function _applyReputation(address _account, uint256 _bidId)\\n internal\\n returns (RepMark mark_)\\n {\\n mark_ = RepMark.Good;\\n\\n if (tellerV2.isLoanDefaulted(_bidId)) {\\n mark_ = RepMark.Default;\\n\\n // Remove delinquent status\\n _removeMark(_account, _bidId, RepMark.Delinquent);\\n } else if (tellerV2.isPaymentLate(_bidId)) {\\n mark_ = RepMark.Delinquent;\\n }\\n\\n // Mark status if not \\\"Good\\\"\\n if (mark_ != RepMark.Good) {\\n _addMark(_account, _bidId, mark_);\\n }\\n }\\n\\n function _addMark(address _account, uint256 _bidId, RepMark _mark)\\n internal\\n {\\n if (_mark == RepMark.Delinquent) {\\n _delinquencies[_account].add(_bidId);\\n _currentDelinquencies[_account].add(_bidId);\\n } else if (_mark == RepMark.Default) {\\n _defaults[_account].add(_bidId);\\n _currentDefaults[_account].add(_bidId);\\n }\\n\\n emit MarkAdded(_account, _mark, _bidId);\\n }\\n\\n function _removeMark(address _account, uint256 _bidId, RepMark _mark)\\n internal\\n {\\n if (_mark == RepMark.Delinquent) {\\n _currentDelinquencies[_account].remove(_bidId);\\n } else if (_mark == RepMark.Default) {\\n _currentDefaults[_account].remove(_bidId);\\n }\\n\\n emit MarkRemoved(_account, _mark, _bidId);\\n }\\n}\\n\",\"keccak256\":\"0xad9c8a70f7f3caf1e3d2875f166a8a85ca8524ff0ae0168a96c85291c459d8d5\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\\n external\\n view\\n returns (uint256 _amount);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x27778a3446cdbfed6356d5047f9926231261b37def2712a3cc63e3779350e5e4\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanLiquidateable(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n\\n function getLoanSummary(uint256 _bidId)\\n external\\n view\\n returns (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n );\\n}\\n\",\"keccak256\":\"0x2750d9717451e34323ef523810ff2a3a6285f146009955220d3860a7c4326077\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610beb806100206000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063941675db11610066578063941675db146100fc578063c4d66de81461012d578063c7312e4714610140578063e0d5343d14610160578063ee0fc1211461017357600080fd5b806303c04b2814610098578063287b498a146100c15780637076185c146100d457806376604b37146100e9575b600080fd5b6100ab6100a6366004610984565b6101a8565b6040516100b8919061099f565b60405180910390f35b6100ab6100cf366004610984565b6101da565b6100e76100e2366004610984565b610206565b005b6100ab6100f7366004610984565b6102d8565b600054610115906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100e761013b366004610984565b610304565b61015361014e3660046109e3565b610434565b6040516100b89190610a23565b6100ab61016e366004610984565b610447565b61019a7f70546d1c92f8c2132ae23a23f5177aa8526356051c7510df99f50e012d22152981565b6040519081526020016100b8565b60606101b382610206565b6001600160a01b03821660009081526002602052604090206101d49061046f565b92915050565b60606101e582610206565b6001600160a01b03821660009081526004602052604090206101d49061046f565b6000805460405163054de0ff60e01b81526001600160a01b038481166004830152620100009092049091169063054de0ff9060240160006040518083038186803b15801561025357600080fd5b505afa158015610267573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261028f9190810190610a61565b905060005b81518110156102d3576102c0838383815181106102b3576102b3610b1f565b602002602001015161047c565b50806102cb81610b4b565b915050610294565b505050565b60606102e382610206565b6001600160a01b03821660009081526001602052604090206101d49061046f565b600054610100900460ff16158080156103245750600054600160ff909116105b8061033e5750303b15801561033e575060005460ff166001145b6103a55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff1916600117905580156103c8576000805461ff0019166101001790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015610430576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6000610440838361047c565b9392505050565b606061045282610206565b6001600160a01b03821660009081526003602052604090206101d4905b60606000610440836105c5565b6000805460405163e8cbab0960e01b815260048101849052620100009091046001600160a01b03169063e8cbab099060240160206040518083038186803b1580156104c657600080fd5b505afa1580156104da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104fe9190610b66565b156105175750600261051283836001610621565b6105a1565b60005460405163093f561760e01b815260048101849052620100009091046001600160a01b03169063093f56179060240160206040518083038186803b15801561056057600080fd5b505afa158015610574573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105989190610b66565b156105a1575060015b60008160028111156105b5576105b5610a0d565b146101d4576101d48383836106fb565b60608160000180548060200260200160405190810160405280929190818152602001828054801561061557602002820191906000526020600020905b815481526020019060010190808311610601575b50505050509050919050565b600181600281111561063557610635610a0d565b1415610663576001600160a01b038316600090815260036020526040902061065d908361080e565b506106a1565b600281600281111561067757610677610a0d565b14156106a1576001600160a01b038316600090815260046020526040902061069f908361080e565b505b8060028111156106b3576106b3610a0d565b836001600160a01b03167f3b90fa143863a45908a7b69d67a369f6e401bfc21b1f1873b2c18f7dfdf0dd27846040516106ee91815260200190565b60405180910390a3505050565b600181600281111561070f5761070f610a0d565b1415610760576001600160a01b0383166000908152600160205260409020610737908361081a565b506001600160a01b038316600090815260036020526040902061075a908361081a565b506107c1565b600281600281111561077457610774610a0d565b14156107c1576001600160a01b038316600090815260026020526040902061079c908361081a565b506001600160a01b03831660009081526004602052604090206107bf908361081a565b505b8060028111156107d3576107d3610a0d565b836001600160a01b03167f07ffa1c77b3c4d3bf16ff59253da47ed8e8a4367376d6caf4bf66469977bc5db846040516106ee91815260200190565b60006104408383610826565b60006104408383610919565b6000818152600183016020526040812054801561090f57600061084a600183610b88565b855490915060009061085e90600190610b88565b90508181146108c357600086600001828154811061087e5761087e610b1f565b90600052602060002001549050808760000184815481106108a1576108a1610b1f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806108d4576108d4610b9f565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506101d4565b60009150506101d4565b6000818152600183016020526040812054610960575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556101d4565b5060006101d4565b80356001600160a01b038116811461097f57600080fd5b919050565b60006020828403121561099657600080fd5b61044082610968565b6020808252825182820181905260009190848201906040850190845b818110156109d7578351835292840192918401916001016109bb565b50909695505050505050565b600080604083850312156109f657600080fd5b6109ff83610968565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6020810160038310610a4557634e487b7160e01b600052602160045260246000fd5b91905290565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215610a7457600080fd5b825167ffffffffffffffff80821115610a8c57600080fd5b818501915085601f830112610aa057600080fd5b815181811115610ab257610ab2610a4b565b8060051b604051601f19603f83011681018181108582111715610ad757610ad7610a4b565b604052918252848201925083810185019188831115610af557600080fd5b938501935b82851015610b1357845184529385019392850192610afa565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415610b5f57610b5f610b35565b5060010190565b600060208284031215610b7857600080fd5b8151801515811461044057600080fd5b600082821015610b9a57610b9a610b35565b500390565b634e487b7160e01b600052603160045260246000fdfea264697066735822122027fefc4516a3916bb30805371791f0a8d63b48d21c0d5dab2747d8eb796efb3264736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063941675db11610066578063941675db146100fc578063c4d66de81461012d578063c7312e4714610140578063e0d5343d14610160578063ee0fc1211461017357600080fd5b806303c04b2814610098578063287b498a146100c15780637076185c146100d457806376604b37146100e9575b600080fd5b6100ab6100a6366004610984565b6101a8565b6040516100b8919061099f565b60405180910390f35b6100ab6100cf366004610984565b6101da565b6100e76100e2366004610984565b610206565b005b6100ab6100f7366004610984565b6102d8565b600054610115906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100e761013b366004610984565b610304565b61015361014e3660046109e3565b610434565b6040516100b89190610a23565b6100ab61016e366004610984565b610447565b61019a7f70546d1c92f8c2132ae23a23f5177aa8526356051c7510df99f50e012d22152981565b6040519081526020016100b8565b60606101b382610206565b6001600160a01b03821660009081526002602052604090206101d49061046f565b92915050565b60606101e582610206565b6001600160a01b03821660009081526004602052604090206101d49061046f565b6000805460405163054de0ff60e01b81526001600160a01b038481166004830152620100009092049091169063054de0ff9060240160006040518083038186803b15801561025357600080fd5b505afa158015610267573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261028f9190810190610a61565b905060005b81518110156102d3576102c0838383815181106102b3576102b3610b1f565b602002602001015161047c565b50806102cb81610b4b565b915050610294565b505050565b60606102e382610206565b6001600160a01b03821660009081526001602052604090206101d49061046f565b600054610100900460ff16158080156103245750600054600160ff909116105b8061033e5750303b15801561033e575060005460ff166001145b6103a55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff1916600117905580156103c8576000805461ff0019166101001790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015610430576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6000610440838361047c565b9392505050565b606061045282610206565b6001600160a01b03821660009081526003602052604090206101d4905b60606000610440836105c5565b6000805460405163e8cbab0960e01b815260048101849052620100009091046001600160a01b03169063e8cbab099060240160206040518083038186803b1580156104c657600080fd5b505afa1580156104da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104fe9190610b66565b156105175750600261051283836001610621565b6105a1565b60005460405163093f561760e01b815260048101849052620100009091046001600160a01b03169063093f56179060240160206040518083038186803b15801561056057600080fd5b505afa158015610574573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105989190610b66565b156105a1575060015b60008160028111156105b5576105b5610a0d565b146101d4576101d48383836106fb565b60608160000180548060200260200160405190810160405280929190818152602001828054801561061557602002820191906000526020600020905b815481526020019060010190808311610601575b50505050509050919050565b600181600281111561063557610635610a0d565b1415610663576001600160a01b038316600090815260036020526040902061065d908361080e565b506106a1565b600281600281111561067757610677610a0d565b14156106a1576001600160a01b038316600090815260046020526040902061069f908361080e565b505b8060028111156106b3576106b3610a0d565b836001600160a01b03167f3b90fa143863a45908a7b69d67a369f6e401bfc21b1f1873b2c18f7dfdf0dd27846040516106ee91815260200190565b60405180910390a3505050565b600181600281111561070f5761070f610a0d565b1415610760576001600160a01b0383166000908152600160205260409020610737908361081a565b506001600160a01b038316600090815260036020526040902061075a908361081a565b506107c1565b600281600281111561077457610774610a0d565b14156107c1576001600160a01b038316600090815260026020526040902061079c908361081a565b506001600160a01b03831660009081526004602052604090206107bf908361081a565b505b8060028111156107d3576107d3610a0d565b836001600160a01b03167f07ffa1c77b3c4d3bf16ff59253da47ed8e8a4367376d6caf4bf66469977bc5db846040516106ee91815260200190565b60006104408383610826565b60006104408383610919565b6000818152600183016020526040812054801561090f57600061084a600183610b88565b855490915060009061085e90600190610b88565b90508181146108c357600086600001828154811061087e5761087e610b1f565b90600052602060002001549050808760000184815481106108a1576108a1610b1f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806108d4576108d4610b9f565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506101d4565b60009150506101d4565b6000818152600183016020526040812054610960575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556101d4565b5060006101d4565b80356001600160a01b038116811461097f57600080fd5b919050565b60006020828403121561099657600080fd5b61044082610968565b6020808252825182820181905260009190848201906040850190845b818110156109d7578351835292840192918401916001016109bb565b50909695505050505050565b600080604083850312156109f657600080fd5b6109ff83610968565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6020810160038310610a4557634e487b7160e01b600052602160045260246000fd5b91905290565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215610a7457600080fd5b825167ffffffffffffffff80821115610a8c57600080fd5b818501915085601f830112610aa057600080fd5b815181811115610ab257610ab2610a4b565b8060051b604051601f19603f83011681018181108582111715610ad757610ad7610a4b565b604052918252848201925083810185019188831115610af557600080fd5b938501935b82851015610b1357845184529385019392850192610afa565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415610b5f57610b5f610b35565b5060010190565b600060208284031215610b7857600080fd5b8151801515811461044057600080fd5b600082821015610b9a57610b9a610b35565b500390565b634e487b7160e01b600052603160045260246000fdfea264697066735822122027fefc4516a3916bb30805371791f0a8d63b48d21c0d5dab2747d8eb796efb3264736f6c63430008090033", "devdoc": { "kind": "dev", "methods": {}, @@ -256,7 +256,7 @@ "storageLayout": { "storage": [ { - "astId": 6784, + "astId": 6027, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_initialized", "offset": 0, @@ -264,7 +264,7 @@ "type": "t_uint8" }, { - "astId": 6787, + "astId": 6030, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_initializing", "offset": 1, @@ -272,44 +272,44 @@ "type": "t_bool" }, { - "astId": 17243, + "astId": 19342, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "tellerV2", "offset": 2, "slot": "0", - "type": "t_contract(ITellerV2)22126" + "type": "t_contract(ITellerV2)24720" }, { - "astId": 17248, + "astId": 19347, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_delinquencies", "offset": 0, "slot": "1", - "type": "t_mapping(t_address,t_struct(UintSet)11850_storage)" + "type": "t_mapping(t_address,t_struct(UintSet)12804_storage)" }, { - "astId": 17253, + "astId": 19352, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_defaults", "offset": 0, "slot": "2", - "type": "t_mapping(t_address,t_struct(UintSet)11850_storage)" + "type": "t_mapping(t_address,t_struct(UintSet)12804_storage)" }, { - "astId": 17258, + "astId": 19357, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_currentDelinquencies", "offset": 0, "slot": "3", - "type": "t_mapping(t_address,t_struct(UintSet)11850_storage)" + "type": "t_mapping(t_address,t_struct(UintSet)12804_storage)" }, { - "astId": 17263, + "astId": 19362, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_currentDefaults", "offset": 0, "slot": "4", - "type": "t_mapping(t_address,t_struct(UintSet)11850_storage)" + "type": "t_mapping(t_address,t_struct(UintSet)12804_storage)" } ], "types": { @@ -334,17 +334,17 @@ "label": "bytes32", "numberOfBytes": "32" }, - "t_contract(ITellerV2)22126": { + "t_contract(ITellerV2)24720": { "encoding": "inplace", "label": "contract ITellerV2", "numberOfBytes": "20" }, - "t_mapping(t_address,t_struct(UintSet)11850_storage)": { + "t_mapping(t_address,t_struct(UintSet)12804_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct EnumerableSet.UintSet)", "numberOfBytes": "32", - "value": "t_struct(UintSet)11850_storage" + "value": "t_struct(UintSet)12804_storage" }, "t_mapping(t_bytes32,t_uint256)": { "encoding": "mapping", @@ -353,12 +353,12 @@ "numberOfBytes": "32", "value": "t_uint256" }, - "t_struct(Set)11378_storage": { + "t_struct(Set)12332_storage": { "encoding": "inplace", "label": "struct EnumerableSet.Set", "members": [ { - "astId": 11373, + "astId": 12327, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_values", "offset": 0, @@ -366,7 +366,7 @@ "type": "t_array(t_bytes32)dyn_storage" }, { - "astId": 11377, + "astId": 12331, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_indexes", "offset": 0, @@ -376,17 +376,17 @@ ], "numberOfBytes": "64" }, - "t_struct(UintSet)11850_storage": { + "t_struct(UintSet)12804_storage": { "encoding": "inplace", "label": "struct EnumerableSet.UintSet", "members": [ { - "astId": 11849, + "astId": 12803, "contract": "contracts/ReputationManager.sol:ReputationManager", "label": "_inner", "offset": 0, "slot": "0", - "type": "t_struct(Set)11378_storage" + "type": "t_struct(Set)12332_storage" } ], "numberOfBytes": "64" diff --git a/packages/contracts/deployments/goerli/ReputationManager_Proxy.json b/packages/contracts/deployments/goerli/ReputationManager_Proxy.json index 282bc1f22..6e12d25f2 100644 --- a/packages/contracts/deployments/goerli/ReputationManager_Proxy.json +++ b/packages/contracts/deployments/goerli/ReputationManager_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0x8cDb56283A26684D6020B3589615df2eDEDc3C8C", + "address": "0x01B14a902BCfa11005e4251fa1aA302C04c438B7", "abi": [ { "inputs": [ @@ -146,51 +146,51 @@ "type": "receive" } ], - "transactionHash": "0x0f16959e169ca35e6f2cb648a3e55da3977ce712a7f0b171659a45edd06d535f", + "transactionHash": "0x0a591e52970f2f4af5b9e2abe7add03db51ac6a2000cd5b976d5ef3ed5b319ac", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x8cDb56283A26684D6020B3589615df2eDEDc3C8C", - "transactionIndex": 6, - "gasUsed": "720430", - "logsBloom": "0x00000000000000004000000004000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800800000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000008000000000000000000000000000080000000000000000000002000000020000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x7762a3a2786f7bb0a879fa1d24922c64554764d2c7b0520327260b1ccb21e34d", - "transactionHash": "0x0f16959e169ca35e6f2cb648a3e55da3977ce712a7f0b171659a45edd06d535f", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x01B14a902BCfa11005e4251fa1aA302C04c438B7", + "transactionIndex": 2, + "gasUsed": "720722", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000002000000000000000000000000000000000002000000000000000000000000000000000000800000000000000000000000000000000000000000000000080000000000000010000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000004000000000000400000000000000000000008000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xcb7f45fa96a63c78a2f8e1254b2bdf20541e383805cf04d63a54d63f69acddad", + "transactionHash": "0x0a591e52970f2f4af5b9e2abe7add03db51ac6a2000cd5b976d5ef3ed5b319ac", "logs": [ { - "transactionIndex": 6, - "blockNumber": 8538449, - "transactionHash": "0x0f16959e169ca35e6f2cb648a3e55da3977ce712a7f0b171659a45edd06d535f", - "address": "0x8cDb56283A26684D6020B3589615df2eDEDc3C8C", + "transactionIndex": 2, + "blockNumber": 8688906, + "transactionHash": "0x0a591e52970f2f4af5b9e2abe7add03db51ac6a2000cd5b976d5ef3ed5b319ac", + "address": "0x01B14a902BCfa11005e4251fa1aA302C04c438B7", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000002db50ef7f702fb335ee7abb915a28aead2cb3ee8" + "0x000000000000000000000000453f4520ccbe1c973af373bd7b1193f7b7b55948" ], "data": "0x", "logIndex": 0, - "blockHash": "0x7762a3a2786f7bb0a879fa1d24922c64554764d2c7b0520327260b1ccb21e34d" + "blockHash": "0xcb7f45fa96a63c78a2f8e1254b2bdf20541e383805cf04d63a54d63f69acddad" }, { - "transactionIndex": 6, - "blockNumber": 8538449, - "transactionHash": "0x0f16959e169ca35e6f2cb648a3e55da3977ce712a7f0b171659a45edd06d535f", - "address": "0x8cDb56283A26684D6020B3589615df2eDEDc3C8C", + "transactionIndex": 2, + "blockNumber": 8688906, + "transactionHash": "0x0a591e52970f2f4af5b9e2abe7add03db51ac6a2000cd5b976d5ef3ed5b319ac", + "address": "0x01B14a902BCfa11005e4251fa1aA302C04c438B7", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 1, - "blockHash": "0x7762a3a2786f7bb0a879fa1d24922c64554764d2c7b0520327260b1ccb21e34d" + "blockHash": "0xcb7f45fa96a63c78a2f8e1254b2bdf20541e383805cf04d63a54d63f69acddad" } ], - "blockNumber": 8538449, - "cumulativeGasUsed": "846430", + "blockNumber": 8688906, + "cumulativeGasUsed": "762722", "status": 1, "byzantium": true }, "args": [ - "0x2Db50eF7F702fB335ee7AbB915a28AeAD2cb3eE8", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0x453F4520CCBE1c973Af373bd7B1193f7b7b55948", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x" ], "numDeployments": 1, diff --git a/packages/contracts/deployments/goerli/TLR.json b/packages/contracts/deployments/goerli/TLR.json index 859031783..8ec77f7bd 100644 --- a/packages/contracts/deployments/goerli/TLR.json +++ b/packages/contracts/deployments/goerli/TLR.json @@ -1,5 +1,5 @@ { - "address": "0x15BF96b00b0cCba940c56c54289167544180f7F9", + "address": "0x27F4436224b38a6e6D9C8137EFD6B80F52E6a030", "abi": [ { "inputs": [ @@ -688,57 +688,57 @@ "type": "function" } ], - "transactionHash": "0xacf1530afccdcba8cc7fbbbba641722487ea5c760ecd208aee57963a963806b6", + "transactionHash": "0x4f204e81c3a11c5c1e3f9a6ac8fe817b9fa99d2850486aff4d6353b460361939", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x15BF96b00b0cCba940c56c54289167544180f7F9", - "transactionIndex": 4, - "gasUsed": "1918336", - "logsBloom": "0x00000000000000000000000000008000000000000000000000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000040000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xd838982aec5ae1b7331e974b503afce15d75b62ef764cd9741e41e85821aed70", - "transactionHash": "0xacf1530afccdcba8cc7fbbbba641722487ea5c760ecd208aee57963a963806b6", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x27F4436224b38a6e6D9C8137EFD6B80F52E6a030", + "transactionIndex": 28, + "gasUsed": "1918906", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000010000200000002000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000008000000000000000000000000000000000008000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xe5aaba4fd6704be34dafdb0438a8fd96e19b889af26fc6cb830a4ecfdb740345", + "transactionHash": "0x4f204e81c3a11c5c1e3f9a6ac8fe817b9fa99d2850486aff4d6353b460361939", "logs": [ { - "transactionIndex": 4, - "blockNumber": 8538504, - "transactionHash": "0xacf1530afccdcba8cc7fbbbba641722487ea5c760ecd208aee57963a963806b6", - "address": "0x15BF96b00b0cCba940c56c54289167544180f7F9", + "transactionIndex": 28, + "blockNumber": 8689045, + "transactionHash": "0x4f204e81c3a11c5c1e3f9a6ac8fe817b9fa99d2850486aff4d6353b460361939", + "address": "0x27F4436224b38a6e6D9C8137EFD6B80F52E6a030", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", - "logIndex": 0, - "blockHash": "0xd838982aec5ae1b7331e974b503afce15d75b62ef764cd9741e41e85821aed70" + "logIndex": 29, + "blockHash": "0xe5aaba4fd6704be34dafdb0438a8fd96e19b889af26fc6cb830a4ecfdb740345" }, { - "transactionIndex": 4, - "blockNumber": 8538504, - "transactionHash": "0xacf1530afccdcba8cc7fbbbba641722487ea5c760ecd208aee57963a963806b6", - "address": "0x15BF96b00b0cCba940c56c54289167544180f7F9", + "transactionIndex": 28, + "blockNumber": 8689045, + "transactionHash": "0x4f204e81c3a11c5c1e3f9a6ac8fe817b9fa99d2850486aff4d6353b460361939", + "address": "0x27F4436224b38a6e6D9C8137EFD6B80F52E6a030", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700", + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", - "logIndex": 1, - "blockHash": "0xd838982aec5ae1b7331e974b503afce15d75b62ef764cd9741e41e85821aed70" + "logIndex": 30, + "blockHash": "0xe5aaba4fd6704be34dafdb0438a8fd96e19b889af26fc6cb830a4ecfdb740345" } ], - "blockNumber": 8538504, - "cumulativeGasUsed": "2002336", + "blockNumber": 8689045, + "cumulativeGasUsed": "3233839", "status": 1, "byzantium": true }, "args": [ "100000000000000000000000000", - "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5" + "0x5a5B978142C8F08Dd013901b50892baC49f3b700" ], "numDeployments": 1, - "solcInputHash": "556fedad003f0c0b44fba88774cf2ef3", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint224\",\"name\":\"_supplyCap\",\"type\":\"uint224\"},{\"internalType\":\"address\",\"name\":\"tokenOwner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"fromDelegate\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"toDelegate\",\"type\":\"address\"}],\"name\":\"DelegateChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"DelegateVotesChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"pos\",\"type\":\"uint32\"}],\"name\":\"checkpoints\",\"outputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fromBlock\",\"type\":\"uint32\"},{\"internalType\":\"uint224\",\"name\":\"votes\",\"type\":\"uint224\"}],\"internalType\":\"struct ERC20Votes.Checkpoint\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"delegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"delegateBySig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"delegates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastTotalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"numCheckpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"DOMAIN_SEPARATOR()\":{\"details\":\"See {IERC20Permit-DOMAIN_SEPARATOR}.\"},\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"burn(address,uint256)\":{\"details\":\"Destroys `amount` tokens from `account`, reducing the total supply. Emits a {Transfer} event with `to` set to the zero address. Requirements: - `account` cannot be the zero address. - `account` must have at least `amount` tokens.\"},\"checkpoints(address,uint32)\":{\"details\":\"Get the `pos`-th checkpoint for `account`.\"},\"constructor\":{\"details\":\"Sets the value of the `cap`. This value is immutable, it can only be set once during construction.\"},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"delegate(address)\":{\"details\":\"Delegate votes from the sender to `delegatee`.\"},\"delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)\":{\"details\":\"Delegates votes from signer to `delegatee`\"},\"delegates(address)\":{\"details\":\"Get the address `account` is currently delegating to.\"},\"getPastTotalSupply(uint256)\":{\"details\":\"Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances. It is but NOT the sum of all the delegated votes! Requirements: - `blockNumber` must have been already mined\"},\"getPastVotes(address,uint256)\":{\"details\":\"Retrieve the number of votes for `account` at the end of `blockNumber`. Requirements: - `blockNumber` must have been already mined\"},\"getVotes(address)\":{\"details\":\"Gets the current votes balance for `account`\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"mint(address,uint256)\":{\"details\":\"Creates `amount` tokens and assigns them to `account` Emits a {Transfer} event with `from` set to the zero address. Requirements: - `account` cannot be the zero address.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"nonces(address)\":{\"details\":\"See {IERC20Permit-nonces}.\"},\"numCheckpoints(address)\":{\"details\":\"Get number of checkpoints for `account`.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"details\":\"See {IERC20Permit-permit}.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TLR.sol\":\"TLR\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/governance/utils/IVotes.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\\n *\\n * _Available since v4.5._\\n */\\ninterface IVotes {\\n /**\\n * @dev Emitted when an account changes their delegate.\\n */\\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\\n\\n /**\\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\\n */\\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\\n\\n /**\\n * @dev Returns the current amount of votes that `account` has.\\n */\\n function getVotes(address account) external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\\n */\\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\\n\\n /**\\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\\n *\\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\\n * vote.\\n */\\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\\n\\n /**\\n * @dev Returns the delegate that `account` has chosen.\\n */\\n function delegates(address account) external view returns (address);\\n\\n /**\\n * @dev Delegates votes from the sender to `delegatee`.\\n */\\n function delegate(address delegatee) external;\\n\\n /**\\n * @dev Delegates votes from signer to `delegatee`.\\n */\\n function delegateBySig(\\n address delegatee,\\n uint256 nonce,\\n uint256 expiry,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xf5324a55ee9c0b4a840ea57c055ac9d046f88986ceef567e1cf68113e46a79c0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (token/ERC20/extensions/ERC20Votes.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./draft-ERC20Permit.sol\\\";\\nimport \\\"../../../utils/math/Math.sol\\\";\\nimport \\\"../../../governance/utils/IVotes.sol\\\";\\nimport \\\"../../../utils/math/SafeCast.sol\\\";\\nimport \\\"../../../utils/cryptography/ECDSA.sol\\\";\\n\\n/**\\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\\n *\\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\\n *\\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\\n *\\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\\n *\\n * _Available since v4.2._\\n */\\nabstract contract ERC20Votes is IVotes, ERC20Permit {\\n struct Checkpoint {\\n uint32 fromBlock;\\n uint224 votes;\\n }\\n\\n bytes32 private constant _DELEGATION_TYPEHASH =\\n keccak256(\\\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\\\");\\n\\n mapping(address => address) private _delegates;\\n mapping(address => Checkpoint[]) private _checkpoints;\\n Checkpoint[] private _totalSupplyCheckpoints;\\n\\n /**\\n * @dev Get the `pos`-th checkpoint for `account`.\\n */\\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\\n return _checkpoints[account][pos];\\n }\\n\\n /**\\n * @dev Get number of checkpoints for `account`.\\n */\\n function numCheckpoints(address account) public view virtual returns (uint32) {\\n return SafeCast.toUint32(_checkpoints[account].length);\\n }\\n\\n /**\\n * @dev Get the address `account` is currently delegating to.\\n */\\n function delegates(address account) public view virtual override returns (address) {\\n return _delegates[account];\\n }\\n\\n /**\\n * @dev Gets the current votes balance for `account`\\n */\\n function getVotes(address account) public view virtual override returns (uint256) {\\n uint256 pos = _checkpoints[account].length;\\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\\n }\\n\\n /**\\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\\n *\\n * Requirements:\\n *\\n * - `blockNumber` must have been already mined\\n */\\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\\n require(blockNumber < block.number, \\\"ERC20Votes: block not yet mined\\\");\\n return _checkpointsLookup(_checkpoints[account], blockNumber);\\n }\\n\\n /**\\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\\n * It is but NOT the sum of all the delegated votes!\\n *\\n * Requirements:\\n *\\n * - `blockNumber` must have been already mined\\n */\\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\\n require(blockNumber < block.number, \\\"ERC20Votes: block not yet mined\\\");\\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\\n }\\n\\n /**\\n * @dev Lookup a value in a list of (sorted) checkpoints.\\n */\\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\\n //\\n // Initially we check if the block is recent to narrow the search range.\\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\\n // out of bounds (in which case we're looking too far in the past and the result is 0).\\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\\n // the same.\\n uint256 length = ckpts.length;\\n\\n uint256 low = 0;\\n uint256 high = length;\\n\\n if (length > 5) {\\n uint256 mid = length - Math.sqrt(length);\\n if (_unsafeAccess(ckpts, mid).fromBlock > blockNumber) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n\\n while (low < high) {\\n uint256 mid = Math.average(low, high);\\n if (_unsafeAccess(ckpts, mid).fromBlock > blockNumber) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n\\n return high == 0 ? 0 : _unsafeAccess(ckpts, high - 1).votes;\\n }\\n\\n /**\\n * @dev Delegate votes from the sender to `delegatee`.\\n */\\n function delegate(address delegatee) public virtual override {\\n _delegate(_msgSender(), delegatee);\\n }\\n\\n /**\\n * @dev Delegates votes from signer to `delegatee`\\n */\\n function delegateBySig(\\n address delegatee,\\n uint256 nonce,\\n uint256 expiry,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n require(block.timestamp <= expiry, \\\"ERC20Votes: signature expired\\\");\\n address signer = ECDSA.recover(\\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\\n v,\\n r,\\n s\\n );\\n require(nonce == _useNonce(signer), \\\"ERC20Votes: invalid nonce\\\");\\n _delegate(signer, delegatee);\\n }\\n\\n /**\\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\\n */\\n function _maxSupply() internal view virtual returns (uint224) {\\n return type(uint224).max;\\n }\\n\\n /**\\n * @dev Snapshots the totalSupply after it has been increased.\\n */\\n function _mint(address account, uint256 amount) internal virtual override {\\n super._mint(account, amount);\\n require(totalSupply() <= _maxSupply(), \\\"ERC20Votes: total supply risks overflowing votes\\\");\\n\\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\\n }\\n\\n /**\\n * @dev Snapshots the totalSupply after it has been decreased.\\n */\\n function _burn(address account, uint256 amount) internal virtual override {\\n super._burn(account, amount);\\n\\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\\n }\\n\\n /**\\n * @dev Move voting power when tokens are transferred.\\n *\\n * Emits a {IVotes-DelegateVotesChanged} event.\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override {\\n super._afterTokenTransfer(from, to, amount);\\n\\n _moveVotingPower(delegates(from), delegates(to), amount);\\n }\\n\\n /**\\n * @dev Change delegation for `delegator` to `delegatee`.\\n *\\n * Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.\\n */\\n function _delegate(address delegator, address delegatee) internal virtual {\\n address currentDelegate = delegates(delegator);\\n uint256 delegatorBalance = balanceOf(delegator);\\n _delegates[delegator] = delegatee;\\n\\n emit DelegateChanged(delegator, currentDelegate, delegatee);\\n\\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\\n }\\n\\n function _moveVotingPower(\\n address src,\\n address dst,\\n uint256 amount\\n ) private {\\n if (src != dst && amount > 0) {\\n if (src != address(0)) {\\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\\n emit DelegateVotesChanged(src, oldWeight, newWeight);\\n }\\n\\n if (dst != address(0)) {\\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\\n }\\n }\\n }\\n\\n function _writeCheckpoint(\\n Checkpoint[] storage ckpts,\\n function(uint256, uint256) view returns (uint256) op,\\n uint256 delta\\n ) private returns (uint256 oldWeight, uint256 newWeight) {\\n uint256 pos = ckpts.length;\\n\\n Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);\\n\\n oldWeight = oldCkpt.votes;\\n newWeight = op(oldWeight, delta);\\n\\n if (pos > 0 && oldCkpt.fromBlock == block.number) {\\n _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);\\n } else {\\n ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));\\n }\\n }\\n\\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\\n return a + b;\\n }\\n\\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\\n return a - b;\\n }\\n\\n /**\\n * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.\\n */\\n function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result) {\\n assembly {\\n mstore(0, ckpts.slot)\\n result.slot := add(keccak256(0, 0x20), pos)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2f67d32babbb1619ed0cdd9c3833d76151316d6e1e7f2f30e67e15a1ed1fafc9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./draft-IERC20Permit.sol\\\";\\nimport \\\"../ERC20.sol\\\";\\nimport \\\"../../../utils/cryptography/ECDSA.sol\\\";\\nimport \\\"../../../utils/cryptography/EIP712.sol\\\";\\nimport \\\"../../../utils/Counters.sol\\\";\\n\\n/**\\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * _Available since v3.4._\\n */\\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\\n using Counters for Counters.Counter;\\n\\n mapping(address => Counters.Counter) private _nonces;\\n\\n // solhint-disable-next-line var-name-mixedcase\\n bytes32 private constant _PERMIT_TYPEHASH =\\n keccak256(\\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\");\\n /**\\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\\n * However, to ensure consistency with the upgradeable transpiler, we will continue\\n * to reserve a slot.\\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\\n */\\n // solhint-disable-next-line var-name-mixedcase\\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\\n\\n /**\\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\\\"1\\\"`.\\n *\\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\\n */\\n constructor(string memory name) EIP712(name, \\\"1\\\") {}\\n\\n /**\\n * @dev See {IERC20Permit-permit}.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n require(block.timestamp <= deadline, \\\"ERC20Permit: expired deadline\\\");\\n\\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\\n\\n bytes32 hash = _hashTypedDataV4(structHash);\\n\\n address signer = ECDSA.recover(hash, v, r, s);\\n require(signer == owner, \\\"ERC20Permit: invalid signature\\\");\\n\\n _approve(owner, spender, value);\\n }\\n\\n /**\\n * @dev See {IERC20Permit-nonces}.\\n */\\n function nonces(address owner) public view virtual override returns (uint256) {\\n return _nonces[owner].current();\\n }\\n\\n /**\\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\\n return _domainSeparatorV4();\\n }\\n\\n /**\\n * @dev \\\"Consume a nonce\\\": return the current value and increment.\\n *\\n * _Available since v4.1._\\n */\\n function _useNonce(address owner) internal virtual returns (uint256 current) {\\n Counters.Counter storage nonce = _nonces[owner];\\n current = nonce.current();\\n nonce.increment();\\n }\\n}\\n\",\"keccak256\":\"0xd2dd6003a2dc02ab905fd405938322e510429d19ae6c07c2c683d70f13ab2f36\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Counters.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Counters\\n * @author Matt Condon (@shrugs)\\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\\n *\\n * Include with `using Counters for Counters.Counter;`\\n */\\nlibrary Counters {\\n struct Counter {\\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\\n // this feature: see https://github.com/ethereum/solidity/issues/4637\\n uint256 _value; // default: 0\\n }\\n\\n function current(Counter storage counter) internal view returns (uint256) {\\n return counter._value;\\n }\\n\\n function increment(Counter storage counter) internal {\\n unchecked {\\n counter._value += 1;\\n }\\n }\\n\\n function decrement(Counter storage counter) internal {\\n uint256 value = counter._value;\\n require(value > 0, \\\"Counter: decrement overflow\\\");\\n unchecked {\\n counter._value = value - 1;\\n }\\n }\\n\\n function reset(Counter storage counter) internal {\\n counter._value = 0;\\n }\\n}\\n\",\"keccak256\":\"0xf0018c2440fbe238dd3a8732fa8e17a0f9dce84d31451dc8a32f6d62b349c9f1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/Math.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = Math.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, Math.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0xa4d1d62251f8574deb032a35fc948386a9b4de74b812d4f545a1ac120486b48a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV // Deprecated in v4.8\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0xda898fa084aa1ddfdb346e6a40459e00a59d87071cce7c315a46d648dd71d0ba\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/EIP712.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./ECDSA.sol\\\";\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\\n *\\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\\n *\\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\\n * ({_hashTypedDataV4}).\\n *\\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\\n * the chain id to protect against replay attacks on an eventual fork of the chain.\\n *\\n * NOTE: This contract implements the version of the encoding known as \\\"v4\\\", as implemented by the JSON RPC method\\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\\n *\\n * _Available since v3.4._\\n */\\nabstract contract EIP712 {\\n /* solhint-disable var-name-mixedcase */\\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\\n // invalidate the cached domain separator if the chain id changes.\\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\\n uint256 private immutable _CACHED_CHAIN_ID;\\n address private immutable _CACHED_THIS;\\n\\n bytes32 private immutable _HASHED_NAME;\\n bytes32 private immutable _HASHED_VERSION;\\n bytes32 private immutable _TYPE_HASH;\\n\\n /* solhint-enable var-name-mixedcase */\\n\\n /**\\n * @dev Initializes the domain separator and parameter caches.\\n *\\n * The meaning of `name` and `version` is specified in\\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\\n *\\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\\n * - `version`: the current major version of the signing domain.\\n *\\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\\n * contract upgrade].\\n */\\n constructor(string memory name, string memory version) {\\n bytes32 hashedName = keccak256(bytes(name));\\n bytes32 hashedVersion = keccak256(bytes(version));\\n bytes32 typeHash = keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n );\\n _HASHED_NAME = hashedName;\\n _HASHED_VERSION = hashedVersion;\\n _CACHED_CHAIN_ID = block.chainid;\\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\\n _CACHED_THIS = address(this);\\n _TYPE_HASH = typeHash;\\n }\\n\\n /**\\n * @dev Returns the domain separator for the current chain.\\n */\\n function _domainSeparatorV4() internal view returns (bytes32) {\\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\\n return _CACHED_DOMAIN_SEPARATOR;\\n } else {\\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\\n }\\n }\\n\\n function _buildDomainSeparator(\\n bytes32 typeHash,\\n bytes32 nameHash,\\n bytes32 versionHash\\n ) private view returns (bytes32) {\\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\\n }\\n\\n /**\\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\\n * function returns the hash of the fully encoded EIP712 message for this domain.\\n *\\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\\n *\\n * ```solidity\\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\\n * keccak256(\\\"Mail(address to,string contents)\\\"),\\n * mailTo,\\n * keccak256(bytes(mailContents))\\n * )));\\n * address signer = ECDSA.recover(digest, signature);\\n * ```\\n */\\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\\n }\\n}\\n\",\"keccak256\":\"0x948d8b2d18f38141ec78c5229d770d950ebc781ed3f44cc9e3ccbb9fded5846a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"contracts/TLR.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\ncontract TLR is ERC20Votes, Ownable {\\n uint224 private immutable MAX_SUPPLY;\\n\\n /**\\n * @dev Sets the value of the `cap`. This value is immutable, it can only be\\n * set once during construction.\\n */\\n constructor(uint224 _supplyCap, address tokenOwner)\\n ERC20(\\\"Teller\\\", \\\"TLR\\\")\\n ERC20Permit(\\\"Teller\\\")\\n {\\n require(_supplyCap > 0, \\\"ERC20Capped: cap is 0\\\");\\n MAX_SUPPLY = _supplyCap;\\n _transferOwnership(tokenOwner);\\n }\\n\\n /**\\n * @dev Max supply has been overridden to cap the token supply upon initialization of the contract\\n * @dev See OpenZeppelin's implementation of ERC20Votes _mint() function\\n */\\n function _maxSupply() internal view override returns (uint224) {\\n return MAX_SUPPLY;\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function mint(address account, uint256 amount) external onlyOwner {\\n _mint(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) external onlyOwner {\\n _burn(account, amount);\\n }\\n}\\n\",\"keccak256\":\"0x076a89954d6ba677024af4598a4cf81692361b04167433fb0cdee978725ee2cf\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x6101606040523480156200001257600080fd5b5060405162002416380380620024168339810160408190526200003591620002f2565b604051806040016040528060068152602001652a32b63632b960d11b81525080604051806040016040528060018152602001603160f81b815250604051806040016040528060068152602001652a32b63632b960d11b815250604051806040016040528060038152602001622a262960e91b8152508160039080519060200190620000c29291906200024c565b508051620000d89060049060208401906200024c565b5050825160209384012082519284019290922060e08390526101008190524660a0818152604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818901819052818301979097526060810194909452608080850193909352308483018190528151808603909301835260c094850190915281519190960120905292909252610120525062000177905033620001fa565b6000826001600160e01b031611620001d55760405162461bcd60e51b815260206004820152601560248201527f45524332304361707065643a2063617020697320300000000000000000000000604482015260640160405180910390fd5b6001600160e01b0380831661014052620001f2908290620001fa16565b505062000384565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8280546200025a9062000347565b90600052602060002090601f0160209004810192826200027e5760008555620002c9565b82601f106200029957805160ff1916838001178555620002c9565b82800160010185558215620002c9579182015b82811115620002c9578251825591602001919060010190620002ac565b50620002d7929150620002db565b5090565b5b80821115620002d75760008155600101620002dc565b600080604083850312156200030657600080fd5b82516001600160e01b03811681146200031e57600080fd5b60208401519092506001600160a01b03811681146200033c57600080fd5b809150509250929050565b600181811c908216806200035c57607f821691505b602082108114156200037e57634e487b7160e01b600052602260045260246000fd5b50919050565b60805160a05160c05160e051610100516101205161014051612037620003df600039600061113d01526000610f4301526000610f9201526000610f6d01526000610ec601526000610ef001526000610f1a01526120376000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c8063715018a6116100f9578063a457c2d711610097578063d505accf11610071578063d505accf146103b4578063dd62ed3e146103c7578063f1127ed8146103da578063f2fde38b1461041757600080fd5b8063a457c2d71461037b578063a9059cbb1461038e578063c3cda520146103a157600080fd5b80638e539e8c116100d35780638e539e8c1461033a57806395d89b411461034d5780639ab24eb0146103555780639dc29fac1461036857600080fd5b8063715018a61461030e5780637ecebe00146103165780638da5cb5b1461032957600080fd5b80633950935111610166578063587cde1e11610140578063587cde1e146102665780635c19a95c146102aa5780636fcfff45146102bd57806370a08231146102e557600080fd5b8063395093511461022b5780633a46b1a81461023e57806340c10f191461025157600080fd5b806306fdde03146101ae578063095ea7b3146101cc57806318160ddd146101ef57806323b872dd14610201578063313ce567146102145780633644e51514610223575b600080fd5b6101b661042a565b6040516101c39190611cd2565b60405180910390f35b6101df6101da366004611d43565b6104bc565b60405190151581526020016101c3565b6002545b6040519081526020016101c3565b6101df61020f366004611d6d565b6104d4565b604051601281526020016101c3565b6101f36104f8565b6101df610239366004611d43565b610507565b6101f361024c366004611d43565b610529565b61026461025f366004611d43565b6105a8565b005b610292610274366004611da9565b6001600160a01b039081166000908152600760205260409020541690565b6040516001600160a01b0390911681526020016101c3565b6102646102b8366004611da9565b6105be565b6102d06102cb366004611da9565b6105cb565b60405163ffffffff90911681526020016101c3565b6101f36102f3366004611da9565b6001600160a01b031660009081526020819052604090205490565b6102646105f3565b6101f3610324366004611da9565b610607565b600a546001600160a01b0316610292565b6101f3610348366004611dc4565b610625565b6101b6610681565b6101f3610363366004611da9565b610690565b610264610376366004611d43565b610717565b6101df610389366004611d43565b610729565b6101df61039c366004611d43565b6107a4565b6102646103af366004611dee565b6107b2565b6102646103c2366004611e46565b6108e8565b6101f36103d5366004611eb0565b610a4c565b6103ed6103e8366004611ee3565b610a77565b60408051825163ffffffff1681526020928301516001600160e01b031692810192909252016101c3565b610264610425366004611da9565b610afb565b60606003805461043990611f23565b80601f016020809104026020016040519081016040528092919081815260200182805461046590611f23565b80156104b25780601f10610487576101008083540402835291602001916104b2565b820191906000526020600020905b81548152906001019060200180831161049557829003601f168201915b5050505050905090565b6000336104ca818585610b71565b5060019392505050565b6000336104e2858285610c95565b6104ed858585610d0f565b506001949350505050565b6000610502610eb9565b905090565b6000336104ca81858561051a8383610a4c565b6105249190611f6e565b610b71565b600043821061057f5760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e65640060448201526064015b60405180910390fd5b6001600160a01b03831660009081526008602052604090206105a19083610fe0565b9392505050565b6105b06110d7565b6105ba8282611131565b5050565b6105c833826111e3565b50565b6001600160a01b0381166000908152600860205260408120546105ed9061125c565b92915050565b6105fb6110d7565b61060560006112c5565b565b6001600160a01b0381166000908152600560205260408120546105ed565b60004382106106765760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e6564006044820152606401610576565b6105ed600983610fe0565b60606004805461043990611f23565b6001600160a01b0381166000908152600860205260408120548015610704576001600160a01b03831660009081526008602052604090206106d2600183611f86565b815481106106e2576106e2611f9d565b60009182526020909120015464010000000090046001600160e01b0316610707565b60005b6001600160e01b03169392505050565b61071f6110d7565b6105ba8282611317565b600033816107378286610a4c565b9050838110156107975760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610576565b6104ed8286868403610b71565b6000336104ca818585610d0f565b834211156108025760405162461bcd60e51b815260206004820152601d60248201527f4552433230566f7465733a207369676e617475726520657870697265640000006044820152606401610576565b604080517fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60208201526001600160a01b03881691810191909152606081018690526080810185905260009061087c906108749060a0016040516020818303038152906040528051906020012061132f565b85858561137d565b9050610887816113a5565b86146108d55760405162461bcd60e51b815260206004820152601960248201527f4552433230566f7465733a20696e76616c6964206e6f6e6365000000000000006044820152606401610576565b6108df81886111e3565b50505050505050565b834211156109385760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610576565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886109678c6113a5565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060006109c28261132f565b905060006109d28287878761137d565b9050896001600160a01b0316816001600160a01b031614610a355760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610576565b610a408a8a8a610b71565b50505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60408051808201909152600080825260208201526001600160a01b0383166000908152600860205260409020805463ffffffff8416908110610abb57610abb611f9d565b60009182526020918290206040805180820190915291015463ffffffff8116825264010000000090046001600160e01b0316918101919091529392505050565b610b036110d7565b6001600160a01b038116610b685760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610576565b6105c8816112c5565b6001600160a01b038316610bd35760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610576565b6001600160a01b038216610c345760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610576565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000610ca18484610a4c565b90506000198114610d095781811015610cfc5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610576565b610d098484848403610b71565b50505050565b6001600160a01b038316610d735760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610576565b6001600160a01b038216610dd55760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610576565b6001600160a01b03831660009081526020819052604090205481811015610e4d5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610576565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610d098484846113d2565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015610f1257507f000000000000000000000000000000000000000000000000000000000000000046145b15610f3c57507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b81546000908181600581111561103a576000610ffb84611404565b6110059085611f86565b600088815260209020909150869082015463ffffffff16111561102a57809150611038565b611035816001611f6e565b92505b505b8082101561108757600061104e83836114e9565b600088815260209020909150869082015463ffffffff16111561107357809150611081565b61107e816001611f6e565b92505b5061103a565b80156110c1576110aa8661109c600184611f86565b600091825260209091200190565b5464010000000090046001600160e01b03166110c4565b60005b6001600160e01b03169695505050505050565b600a546001600160a01b031633146106055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610576565b61113b8282611504565b7f00000000000000000000000000000000000000000000000000000000000000006001600160e01b031661116e60025490565b11156111d55760405162461bcd60e51b815260206004820152603060248201527f4552433230566f7465733a20746f74616c20737570706c79207269736b73206f60448201526f766572666c6f77696e6720766f74657360801b6064820152608401610576565b610d0960096115cb836115d7565b6001600160a01b038281166000818152600760208181526040808420805485845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a4610d0982848361172b565b600063ffffffff8211156112c15760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b6064820152608401610576565b5090565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6113218282611868565b610d0960096119a1836115d7565b60006105ed61133c610eb9565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061138e878787876119ad565b9150915061139b81611a71565b5095945050505050565b6001600160a01b03811660009081526005602052604090208054600181018255905b50919050565b505050565b6001600160a01b038381166000908152600760205260408082205485841683529120546113cd9291821691168361172b565b60008161141357506000919050565b6000600161142084611bbf565b901c6001901b9050600181848161143957611439611fb3565b048201901c9050600181848161145157611451611fb3565b048201901c9050600181848161146957611469611fb3565b048201901c9050600181848161148157611481611fb3565b048201901c9050600181848161149957611499611fb3565b048201901c905060018184816114b1576114b1611fb3565b048201901c905060018184816114c9576114c9611fb3565b048201901c90506105a1818285816114e3576114e3611fb3565b04611c53565b60006114f86002848418611fc9565b6105a190848416611f6e565b6001600160a01b03821661155a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610576565b806002600082825461156c9190611f6e565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36105ba600083836113d2565b60006105a18284611f6e565b82546000908190818115611624576115f48761109c600185611f86565b60408051808201909152905463ffffffff8116825264010000000090046001600160e01b03166020820152611639565b60408051808201909152600080825260208201525b905080602001516001600160e01b0316935061165984868863ffffffff16565b92506000821180156116715750805163ffffffff1643145b156116b65761167f83611c69565b61168e8861109c600186611f86565b80546001600160e01b03929092166401000000000263ffffffff909216919091179055611721565b8660405180604001604052806116cb4361125c565b63ffffffff1681526020016116df86611c69565b6001600160e01b0390811690915282546001810184556000938452602093849020835194909301519091166401000000000263ffffffff909316929092179101555b5050935093915050565b816001600160a01b0316836001600160a01b03161415801561174d5750600081115b156113cd576001600160a01b038316156117db576001600160a01b03831660009081526008602052604081208190611788906119a1856115d7565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a72483836040516117d0929190918252602082015260400190565b60405180910390a250505b6001600160a01b038216156113cd576001600160a01b03821660009081526008602052604081208190611811906115cb856115d7565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611859929190918252602082015260400190565b60405180910390a25050505050565b6001600160a01b0382166118c85760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610576565b6001600160a01b0382166000908152602081905260409020548181101561193c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610576565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36113cd836000846113d2565b60006105a18284611f86565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156119e45750600090506003611a68565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611a38573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611a6157600060019250925050611a68565b9150600090505b94509492505050565b6000816004811115611a8557611a85611feb565b1415611a8e5750565b6001816004811115611aa257611aa2611feb565b1415611af05760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610576565b6002816004811115611b0457611b04611feb565b1415611b525760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610576565b6003816004811115611b6657611b66611feb565b14156105c85760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610576565b600080608083901c15611bd457608092831c92015b604083901c15611be657604092831c92015b602083901c15611bf857602092831c92015b601083901c15611c0a57601092831c92015b600883901c15611c1c57600892831c92015b600483901c15611c2e57600492831c92015b600283901c15611c4057600292831c92015b600183901c156105ed5760010192915050565b6000818310611c6257816105a1565b5090919050565b60006001600160e01b038211156112c15760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b6064820152608401610576565b600060208083528351808285015260005b81811015611cff57858101830151858201604001528201611ce3565b81811115611d11576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114611d3e57600080fd5b919050565b60008060408385031215611d5657600080fd5b611d5f83611d27565b946020939093013593505050565b600080600060608486031215611d8257600080fd5b611d8b84611d27565b9250611d9960208501611d27565b9150604084013590509250925092565b600060208284031215611dbb57600080fd5b6105a182611d27565b600060208284031215611dd657600080fd5b5035919050565b803560ff81168114611d3e57600080fd5b60008060008060008060c08789031215611e0757600080fd5b611e1087611d27565b95506020870135945060408701359350611e2c60608801611ddd565b92506080870135915060a087013590509295509295509295565b600080600080600080600060e0888a031215611e6157600080fd5b611e6a88611d27565b9650611e7860208901611d27565b95506040880135945060608801359350611e9460808901611ddd565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215611ec357600080fd5b611ecc83611d27565b9150611eda60208401611d27565b90509250929050565b60008060408385031215611ef657600080fd5b611eff83611d27565b9150602083013563ffffffff81168114611f1857600080fd5b809150509250929050565b600181811c90821680611f3757607f821691505b602082108114156113c757634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115611f8157611f81611f58565b500190565b600082821015611f9857611f98611f58565b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082611fe657634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fdfea264697066735822122068414b12f443f6aa912d44d07bc63acd91d410f0f944a887c8e87b71700c69df64736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101a95760003560e01c8063715018a6116100f9578063a457c2d711610097578063d505accf11610071578063d505accf146103b4578063dd62ed3e146103c7578063f1127ed8146103da578063f2fde38b1461041757600080fd5b8063a457c2d71461037b578063a9059cbb1461038e578063c3cda520146103a157600080fd5b80638e539e8c116100d35780638e539e8c1461033a57806395d89b411461034d5780639ab24eb0146103555780639dc29fac1461036857600080fd5b8063715018a61461030e5780637ecebe00146103165780638da5cb5b1461032957600080fd5b80633950935111610166578063587cde1e11610140578063587cde1e146102665780635c19a95c146102aa5780636fcfff45146102bd57806370a08231146102e557600080fd5b8063395093511461022b5780633a46b1a81461023e57806340c10f191461025157600080fd5b806306fdde03146101ae578063095ea7b3146101cc57806318160ddd146101ef57806323b872dd14610201578063313ce567146102145780633644e51514610223575b600080fd5b6101b661042a565b6040516101c39190611cd2565b60405180910390f35b6101df6101da366004611d43565b6104bc565b60405190151581526020016101c3565b6002545b6040519081526020016101c3565b6101df61020f366004611d6d565b6104d4565b604051601281526020016101c3565b6101f36104f8565b6101df610239366004611d43565b610507565b6101f361024c366004611d43565b610529565b61026461025f366004611d43565b6105a8565b005b610292610274366004611da9565b6001600160a01b039081166000908152600760205260409020541690565b6040516001600160a01b0390911681526020016101c3565b6102646102b8366004611da9565b6105be565b6102d06102cb366004611da9565b6105cb565b60405163ffffffff90911681526020016101c3565b6101f36102f3366004611da9565b6001600160a01b031660009081526020819052604090205490565b6102646105f3565b6101f3610324366004611da9565b610607565b600a546001600160a01b0316610292565b6101f3610348366004611dc4565b610625565b6101b6610681565b6101f3610363366004611da9565b610690565b610264610376366004611d43565b610717565b6101df610389366004611d43565b610729565b6101df61039c366004611d43565b6107a4565b6102646103af366004611dee565b6107b2565b6102646103c2366004611e46565b6108e8565b6101f36103d5366004611eb0565b610a4c565b6103ed6103e8366004611ee3565b610a77565b60408051825163ffffffff1681526020928301516001600160e01b031692810192909252016101c3565b610264610425366004611da9565b610afb565b60606003805461043990611f23565b80601f016020809104026020016040519081016040528092919081815260200182805461046590611f23565b80156104b25780601f10610487576101008083540402835291602001916104b2565b820191906000526020600020905b81548152906001019060200180831161049557829003601f168201915b5050505050905090565b6000336104ca818585610b71565b5060019392505050565b6000336104e2858285610c95565b6104ed858585610d0f565b506001949350505050565b6000610502610eb9565b905090565b6000336104ca81858561051a8383610a4c565b6105249190611f6e565b610b71565b600043821061057f5760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e65640060448201526064015b60405180910390fd5b6001600160a01b03831660009081526008602052604090206105a19083610fe0565b9392505050565b6105b06110d7565b6105ba8282611131565b5050565b6105c833826111e3565b50565b6001600160a01b0381166000908152600860205260408120546105ed9061125c565b92915050565b6105fb6110d7565b61060560006112c5565b565b6001600160a01b0381166000908152600560205260408120546105ed565b60004382106106765760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e6564006044820152606401610576565b6105ed600983610fe0565b60606004805461043990611f23565b6001600160a01b0381166000908152600860205260408120548015610704576001600160a01b03831660009081526008602052604090206106d2600183611f86565b815481106106e2576106e2611f9d565b60009182526020909120015464010000000090046001600160e01b0316610707565b60005b6001600160e01b03169392505050565b61071f6110d7565b6105ba8282611317565b600033816107378286610a4c565b9050838110156107975760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610576565b6104ed8286868403610b71565b6000336104ca818585610d0f565b834211156108025760405162461bcd60e51b815260206004820152601d60248201527f4552433230566f7465733a207369676e617475726520657870697265640000006044820152606401610576565b604080517fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60208201526001600160a01b03881691810191909152606081018690526080810185905260009061087c906108749060a0016040516020818303038152906040528051906020012061132f565b85858561137d565b9050610887816113a5565b86146108d55760405162461bcd60e51b815260206004820152601960248201527f4552433230566f7465733a20696e76616c6964206e6f6e6365000000000000006044820152606401610576565b6108df81886111e3565b50505050505050565b834211156109385760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610576565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886109678c6113a5565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060006109c28261132f565b905060006109d28287878761137d565b9050896001600160a01b0316816001600160a01b031614610a355760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610576565b610a408a8a8a610b71565b50505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60408051808201909152600080825260208201526001600160a01b0383166000908152600860205260409020805463ffffffff8416908110610abb57610abb611f9d565b60009182526020918290206040805180820190915291015463ffffffff8116825264010000000090046001600160e01b0316918101919091529392505050565b610b036110d7565b6001600160a01b038116610b685760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610576565b6105c8816112c5565b6001600160a01b038316610bd35760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610576565b6001600160a01b038216610c345760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610576565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000610ca18484610a4c565b90506000198114610d095781811015610cfc5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610576565b610d098484848403610b71565b50505050565b6001600160a01b038316610d735760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610576565b6001600160a01b038216610dd55760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610576565b6001600160a01b03831660009081526020819052604090205481811015610e4d5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610576565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610d098484846113d2565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015610f1257507f000000000000000000000000000000000000000000000000000000000000000046145b15610f3c57507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b81546000908181600581111561103a576000610ffb84611404565b6110059085611f86565b600088815260209020909150869082015463ffffffff16111561102a57809150611038565b611035816001611f6e565b92505b505b8082101561108757600061104e83836114e9565b600088815260209020909150869082015463ffffffff16111561107357809150611081565b61107e816001611f6e565b92505b5061103a565b80156110c1576110aa8661109c600184611f86565b600091825260209091200190565b5464010000000090046001600160e01b03166110c4565b60005b6001600160e01b03169695505050505050565b600a546001600160a01b031633146106055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610576565b61113b8282611504565b7f00000000000000000000000000000000000000000000000000000000000000006001600160e01b031661116e60025490565b11156111d55760405162461bcd60e51b815260206004820152603060248201527f4552433230566f7465733a20746f74616c20737570706c79207269736b73206f60448201526f766572666c6f77696e6720766f74657360801b6064820152608401610576565b610d0960096115cb836115d7565b6001600160a01b038281166000818152600760208181526040808420805485845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a4610d0982848361172b565b600063ffffffff8211156112c15760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b6064820152608401610576565b5090565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6113218282611868565b610d0960096119a1836115d7565b60006105ed61133c610eb9565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061138e878787876119ad565b9150915061139b81611a71565b5095945050505050565b6001600160a01b03811660009081526005602052604090208054600181018255905b50919050565b505050565b6001600160a01b038381166000908152600760205260408082205485841683529120546113cd9291821691168361172b565b60008161141357506000919050565b6000600161142084611bbf565b901c6001901b9050600181848161143957611439611fb3565b048201901c9050600181848161145157611451611fb3565b048201901c9050600181848161146957611469611fb3565b048201901c9050600181848161148157611481611fb3565b048201901c9050600181848161149957611499611fb3565b048201901c905060018184816114b1576114b1611fb3565b048201901c905060018184816114c9576114c9611fb3565b048201901c90506105a1818285816114e3576114e3611fb3565b04611c53565b60006114f86002848418611fc9565b6105a190848416611f6e565b6001600160a01b03821661155a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610576565b806002600082825461156c9190611f6e565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36105ba600083836113d2565b60006105a18284611f6e565b82546000908190818115611624576115f48761109c600185611f86565b60408051808201909152905463ffffffff8116825264010000000090046001600160e01b03166020820152611639565b60408051808201909152600080825260208201525b905080602001516001600160e01b0316935061165984868863ffffffff16565b92506000821180156116715750805163ffffffff1643145b156116b65761167f83611c69565b61168e8861109c600186611f86565b80546001600160e01b03929092166401000000000263ffffffff909216919091179055611721565b8660405180604001604052806116cb4361125c565b63ffffffff1681526020016116df86611c69565b6001600160e01b0390811690915282546001810184556000938452602093849020835194909301519091166401000000000263ffffffff909316929092179101555b5050935093915050565b816001600160a01b0316836001600160a01b03161415801561174d5750600081115b156113cd576001600160a01b038316156117db576001600160a01b03831660009081526008602052604081208190611788906119a1856115d7565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a72483836040516117d0929190918252602082015260400190565b60405180910390a250505b6001600160a01b038216156113cd576001600160a01b03821660009081526008602052604081208190611811906115cb856115d7565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611859929190918252602082015260400190565b60405180910390a25050505050565b6001600160a01b0382166118c85760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610576565b6001600160a01b0382166000908152602081905260409020548181101561193c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610576565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36113cd836000846113d2565b60006105a18284611f86565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156119e45750600090506003611a68565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611a38573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611a6157600060019250925050611a68565b9150600090505b94509492505050565b6000816004811115611a8557611a85611feb565b1415611a8e5750565b6001816004811115611aa257611aa2611feb565b1415611af05760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610576565b6002816004811115611b0457611b04611feb565b1415611b525760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610576565b6003816004811115611b6657611b66611feb565b14156105c85760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610576565b600080608083901c15611bd457608092831c92015b604083901c15611be657604092831c92015b602083901c15611bf857602092831c92015b601083901c15611c0a57601092831c92015b600883901c15611c1c57600892831c92015b600483901c15611c2e57600492831c92015b600283901c15611c4057600292831c92015b600183901c156105ed5760010192915050565b6000818310611c6257816105a1565b5090919050565b60006001600160e01b038211156112c15760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b6064820152608401610576565b600060208083528351808285015260005b81811015611cff57858101830151858201604001528201611ce3565b81811115611d11576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114611d3e57600080fd5b919050565b60008060408385031215611d5657600080fd5b611d5f83611d27565b946020939093013593505050565b600080600060608486031215611d8257600080fd5b611d8b84611d27565b9250611d9960208501611d27565b9150604084013590509250925092565b600060208284031215611dbb57600080fd5b6105a182611d27565b600060208284031215611dd657600080fd5b5035919050565b803560ff81168114611d3e57600080fd5b60008060008060008060c08789031215611e0757600080fd5b611e1087611d27565b95506020870135945060408701359350611e2c60608801611ddd565b92506080870135915060a087013590509295509295509295565b600080600080600080600060e0888a031215611e6157600080fd5b611e6a88611d27565b9650611e7860208901611d27565b95506040880135945060608801359350611e9460808901611ddd565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215611ec357600080fd5b611ecc83611d27565b9150611eda60208401611d27565b90509250929050565b60008060408385031215611ef657600080fd5b611eff83611d27565b9150602083013563ffffffff81168114611f1857600080fd5b809150509250929050565b600181811c90821680611f3757607f821691505b602082108114156113c757634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115611f8157611f81611f58565b500190565b600082821015611f9857611f98611f58565b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082611fe657634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fdfea264697066735822122068414b12f443f6aa912d44d07bc63acd91d410f0f944a887c8e87b71700c69df64736f6c63430008090033", @@ -840,7 +840,7 @@ "storageLayout": { "storage": [ { - "astId": 7687, + "astId": 6313, "contract": "contracts/TLR.sol:TLR", "label": "_balances", "offset": 0, @@ -848,7 +848,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 7693, + "astId": 6319, "contract": "contracts/TLR.sol:TLR", "label": "_allowances", "offset": 0, @@ -856,7 +856,7 @@ "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" }, { - "astId": 7695, + "astId": 6321, "contract": "contracts/TLR.sol:TLR", "label": "_totalSupply", "offset": 0, @@ -864,7 +864,7 @@ "type": "t_uint256" }, { - "astId": 7697, + "astId": 6323, "contract": "contracts/TLR.sol:TLR", "label": "_name", "offset": 0, @@ -872,7 +872,7 @@ "type": "t_string_storage" }, { - "astId": 7699, + "astId": 6325, "contract": "contracts/TLR.sol:TLR", "label": "_symbol", "offset": 0, @@ -880,15 +880,15 @@ "type": "t_string_storage" }, { - "astId": 9163, + "astId": 7789, "contract": "contracts/TLR.sol:TLR", "label": "_nonces", "offset": 0, "slot": "5", - "type": "t_mapping(t_address,t_struct(Counter)10395_storage)" + "type": "t_mapping(t_address,t_struct(Counter)8749_storage)" }, { - "astId": 9171, + "astId": 7797, "contract": "contracts/TLR.sol:TLR", "label": "_PERMIT_TYPEHASH_DEPRECATED_SLOT", "offset": 0, @@ -896,7 +896,7 @@ "type": "t_bytes32" }, { - "astId": 8443, + "astId": 7069, "contract": "contracts/TLR.sol:TLR", "label": "_delegates", "offset": 0, @@ -904,23 +904,23 @@ "type": "t_mapping(t_address,t_address)" }, { - "astId": 8449, + "astId": 7075, "contract": "contracts/TLR.sol:TLR", "label": "_checkpoints", "offset": 0, "slot": "8", - "type": "t_mapping(t_address,t_array(t_struct(Checkpoint)8434_storage)dyn_storage)" + "type": "t_mapping(t_address,t_array(t_struct(Checkpoint)7060_storage)dyn_storage)" }, { - "astId": 8453, + "astId": 7079, "contract": "contracts/TLR.sol:TLR", "label": "_totalSupplyCheckpoints", "offset": 0, "slot": "9", - "type": "t_array(t_struct(Checkpoint)8434_storage)dyn_storage" + "type": "t_array(t_struct(Checkpoint)7060_storage)dyn_storage" }, { - "astId": 6680, + "astId": 5381, "contract": "contracts/TLR.sol:TLR", "label": "_owner", "offset": 0, @@ -934,8 +934,8 @@ "label": "address", "numberOfBytes": "20" }, - "t_array(t_struct(Checkpoint)8434_storage)dyn_storage": { - "base": "t_struct(Checkpoint)8434_storage", + "t_array(t_struct(Checkpoint)7060_storage)dyn_storage": { + "base": "t_struct(Checkpoint)7060_storage", "encoding": "dynamic_array", "label": "struct ERC20Votes.Checkpoint[]", "numberOfBytes": "32" @@ -952,12 +952,12 @@ "numberOfBytes": "32", "value": "t_address" }, - "t_mapping(t_address,t_array(t_struct(Checkpoint)8434_storage)dyn_storage)": { + "t_mapping(t_address,t_array(t_struct(Checkpoint)7060_storage)dyn_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct ERC20Votes.Checkpoint[])", "numberOfBytes": "32", - "value": "t_array(t_struct(Checkpoint)8434_storage)dyn_storage" + "value": "t_array(t_struct(Checkpoint)7060_storage)dyn_storage" }, "t_mapping(t_address,t_mapping(t_address,t_uint256))": { "encoding": "mapping", @@ -966,12 +966,12 @@ "numberOfBytes": "32", "value": "t_mapping(t_address,t_uint256)" }, - "t_mapping(t_address,t_struct(Counter)10395_storage)": { + "t_mapping(t_address,t_struct(Counter)8749_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct Counters.Counter)", "numberOfBytes": "32", - "value": "t_struct(Counter)10395_storage" + "value": "t_struct(Counter)8749_storage" }, "t_mapping(t_address,t_uint256)": { "encoding": "mapping", @@ -985,12 +985,12 @@ "label": "string", "numberOfBytes": "32" }, - "t_struct(Checkpoint)8434_storage": { + "t_struct(Checkpoint)7060_storage": { "encoding": "inplace", "label": "struct ERC20Votes.Checkpoint", "members": [ { - "astId": 8431, + "astId": 7057, "contract": "contracts/TLR.sol:TLR", "label": "fromBlock", "offset": 0, @@ -998,7 +998,7 @@ "type": "t_uint32" }, { - "astId": 8433, + "astId": 7059, "contract": "contracts/TLR.sol:TLR", "label": "votes", "offset": 4, @@ -1008,12 +1008,12 @@ ], "numberOfBytes": "32" }, - "t_struct(Counter)10395_storage": { + "t_struct(Counter)8749_storage": { "encoding": "inplace", "label": "struct Counters.Counter", "members": [ { - "astId": 10394, + "astId": 8748, "contract": "contracts/TLR.sol:TLR", "label": "_value", "offset": 0, diff --git a/packages/contracts/deployments/goerli/TellerAS.json b/packages/contracts/deployments/goerli/TellerAS.json index d911583c5..97d5d9a02 100644 --- a/packages/contracts/deployments/goerli/TellerAS.json +++ b/packages/contracts/deployments/goerli/TellerAS.json @@ -1,5 +1,5 @@ { - "address": "0x2858023076c86347CDd7DEa4F38aa215cbbCa91b", + "address": "0x2B6e11Aeb39Af806794bA2Edc975632084A375b2", "abi": [ { "inputs": [ @@ -675,28 +675,28 @@ "type": "function" } ], - "transactionHash": "0x2cf686c4792dea47d7714dab1bfe56576757f31346c7c17354540daec0f8b4de", + "transactionHash": "0x6e2f27b5e2ff881c4bef50b5ed12eb6e8e84547a5baee27eee7b94c70252df5b", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x2858023076c86347CDd7DEa4F38aa215cbbCa91b", - "transactionIndex": 1, - "gasUsed": "1485622", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x2B6e11Aeb39Af806794bA2Edc975632084A375b2", + "transactionIndex": 14, + "gasUsed": "1486060", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x4bbec84eac93241d2c025ad9c5320117460487a36f11264e8bb3fc95b8aeb592", - "transactionHash": "0x2cf686c4792dea47d7714dab1bfe56576757f31346c7c17354540daec0f8b4de", + "blockHash": "0xf8bf683a1c83e8a2cb086dbd579f68613b647ae6557a8236d8082819298d8860", + "transactionHash": "0x6e2f27b5e2ff881c4bef50b5ed12eb6e8e84547a5baee27eee7b94c70252df5b", "logs": [], - "blockNumber": 8538437, - "cumulativeGasUsed": "1506622", + "blockNumber": 8688909, + "cumulativeGasUsed": "1780060", "status": 1, "byzantium": true }, "args": [ - "0x66ed2c7123FE6e95EE5Dfd27EaCD30cedb5F9cD2", - "0xe7168c514A022345ed07E4Fad73eC3921C2b7bDb" + "0x16Ba53DDE085132b6cEb93334335f4236f6B58d4", + "0x42BBB41A67F9966ca180ef2A869c652daC81ede0" ], "numDeployments": 1, - "solcInputHash": "556fedad003f0c0b44fba88774cf2ef3", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IASRegistry\",\"name\":\"registry\",\"type\":\"address\"},{\"internalType\":\"contract IEASEIP712Verifier\",\"name\":\"verifier\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessDenied\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"AlreadyRevoked\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidAttestation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidExpirationTime\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidOffset\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidRegistry\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSchema\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidVerifier\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotPayable\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"}],\"name\":\"Attested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"}],\"name\":\"Revoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"expirationTime\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"refUUID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"attest\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"expirationTime\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"refUUID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"attestByDelegation\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getASRegistry\",\"outputs\":[{\"internalType\":\"contract IASRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"}],\"name\":\"getAttestation\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expirationTime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"revocationTime\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"refUUID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct IEAS.Attestation\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAttestationsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEIP712Verifier\",\"outputs\":[{\"internalType\":\"contract IEASEIP712Verifier\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLastUUID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"reverseOrder\",\"type\":\"bool\"}],\"name\":\"getReceivedAttestationUUIDs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"}],\"name\":\"getReceivedAttestationUUIDsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"reverseOrder\",\"type\":\"bool\"}],\"name\":\"getRelatedAttestationUUIDs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"}],\"name\":\"getRelatedAttestationUUIDsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"reverseOrder\",\"type\":\"bool\"}],\"name\":\"getSchemaAttestationUUIDs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"}],\"name\":\"getSchemaAttestationUUIDsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"reverseOrder\",\"type\":\"bool\"}],\"name\":\"getSentAttestationUUIDs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"}],\"name\":\"getSentAttestationUUIDsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"}],\"name\":\"isAttestationActive\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"}],\"name\":\"isAttestationValid\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"}],\"name\":\"revoke\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"revokeByDelegation\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"attest(address,bytes32,uint256,bytes32,bytes)\":{\"details\":\"Attests to a specific AS.\",\"params\":{\"data\":\"Additional custom data.\",\"expirationTime\":\"The expiration time of the attestation.\",\"recipient\":\"The recipient of the attestation.\",\"refUUID\":\"An optional related attestation's UUID.\",\"schema\":\"The UUID of the AS.\"},\"returns\":{\"_0\":\"The UUID of the new attestation.\"}},\"attestByDelegation(address,bytes32,uint256,bytes32,bytes,address,uint8,bytes32,bytes32)\":{\"details\":\"Attests to a specific AS using a provided EIP712 signature.\",\"params\":{\"attester\":\"The attesting account.\",\"data\":\"Additional custom data.\",\"expirationTime\":\"The expiration time of the attestation.\",\"r\":\"The x-coordinate of the nonce R.\",\"recipient\":\"The recipient of the attestation.\",\"refUUID\":\"An optional related attestation's UUID.\",\"s\":\"The signature data.\",\"schema\":\"The UUID of the AS.\",\"v\":\"The recovery ID.\"},\"returns\":{\"_0\":\"The UUID of the new attestation.\"}},\"constructor\":{\"details\":\"Creates a new EAS instance.\",\"params\":{\"registry\":\"The address of the global AS registry.\",\"verifier\":\"The address of the EIP712 verifier.\"}},\"getASRegistry()\":{\"details\":\"Returns the address of the AS global registry.\",\"returns\":{\"_0\":\"The address of the AS global registry.\"}},\"getAttestation(bytes32)\":{\"details\":\"Returns an existing attestation by UUID.\",\"params\":{\"uuid\":\"The UUID of the attestation to retrieve.\"},\"returns\":{\"_0\":\"The attestation data members.\"}},\"getAttestationsCount()\":{\"details\":\"Returns the global counter for the total number of attestations.\",\"returns\":{\"_0\":\"The global counter for the total number of attestations.\"}},\"getEIP712Verifier()\":{\"details\":\"Returns the address of the EIP712 verifier used to verify signed attestations.\",\"returns\":{\"_0\":\"The address of the EIP712 verifier used to verify signed attestations.\"}},\"getReceivedAttestationUUIDs(address,bytes32,uint256,uint256,bool)\":{\"details\":\"Returns all received attestation UUIDs.\",\"params\":{\"length\":\"The number of total members to retrieve.\",\"recipient\":\"The recipient of the attestation.\",\"reverseOrder\":\"Whether the offset starts from the end and the data is returned in reverse.\",\"schema\":\"The UUID of the AS.\",\"start\":\"The offset to start from.\"},\"returns\":{\"_0\":\"An array of attestation UUIDs.\"}},\"getReceivedAttestationUUIDsCount(address,bytes32)\":{\"details\":\"Returns the number of received attestation UUIDs.\",\"params\":{\"recipient\":\"The recipient of the attestation.\",\"schema\":\"The UUID of the AS.\"},\"returns\":{\"_0\":\"The number of attestations.\"}},\"getRelatedAttestationUUIDs(bytes32,uint256,uint256,bool)\":{\"details\":\"Returns all attestations related to a specific attestation.\",\"params\":{\"length\":\"The number of total members to retrieve.\",\"reverseOrder\":\"Whether the offset starts from the end and the data is returned in reverse.\",\"start\":\"The offset to start from.\",\"uuid\":\"The UUID of the attestation to retrieve.\"},\"returns\":{\"_0\":\"An array of attestation UUIDs.\"}},\"getRelatedAttestationUUIDsCount(bytes32)\":{\"details\":\"Returns the number of related attestation UUIDs.\",\"params\":{\"uuid\":\"The UUID of the attestation to retrieve.\"},\"returns\":{\"_0\":\"The number of related attestations.\"}},\"getSchemaAttestationUUIDs(bytes32,uint256,uint256,bool)\":{\"details\":\"Returns all per-schema attestation UUIDs.\",\"params\":{\"length\":\"The number of total members to retrieve.\",\"reverseOrder\":\"Whether the offset starts from the end and the data is returned in reverse.\",\"schema\":\"The UUID of the AS.\",\"start\":\"The offset to start from.\"},\"returns\":{\"_0\":\"An array of attestation UUIDs.\"}},\"getSchemaAttestationUUIDsCount(bytes32)\":{\"details\":\"Returns the number of per-schema attestation UUIDs.\",\"params\":{\"schema\":\"The UUID of the AS.\"},\"returns\":{\"_0\":\"The number of attestations.\"}},\"getSentAttestationUUIDs(address,bytes32,uint256,uint256,bool)\":{\"details\":\"Returns all sent attestation UUIDs.\",\"params\":{\"attester\":\"The attesting account.\",\"length\":\"The number of total members to retrieve.\",\"reverseOrder\":\"Whether the offset starts from the end and the data is returned in reverse.\",\"schema\":\"The UUID of the AS.\",\"start\":\"The offset to start from.\"},\"returns\":{\"_0\":\"An array of attestation UUIDs.\"}},\"getSentAttestationUUIDsCount(address,bytes32)\":{\"details\":\"Returns the number of sent attestation UUIDs.\",\"params\":{\"recipient\":\"The recipient of the attestation.\",\"schema\":\"The UUID of the AS.\"},\"returns\":{\"_0\":\"The number of attestations.\"}},\"isAttestationActive(bytes32)\":{\"details\":\"Checks whether an attestation is active.\",\"params\":{\"uuid\":\"The UUID of the attestation to retrieve.\"},\"returns\":{\"_0\":\"Whether an attestation is active.\"}},\"isAttestationValid(bytes32)\":{\"details\":\"Checks whether an attestation exists.\",\"params\":{\"uuid\":\"The UUID of the attestation to retrieve.\"},\"returns\":{\"_0\":\"Whether an attestation exists.\"}},\"revoke(bytes32)\":{\"details\":\"Revokes an existing attestation to a specific AS.\",\"params\":{\"uuid\":\"The UUID of the attestation to revoke.\"}},\"revokeByDelegation(bytes32,address,uint8,bytes32,bytes32)\":{\"details\":\"Attests to a specific AS using a provided EIP712 signature.\",\"params\":{\"attester\":\"The attesting account.\",\"r\":\"The x-coordinate of the nonce R.\",\"s\":\"The signature data.\",\"uuid\":\"The UUID of the attestation to revoke.\",\"v\":\"The recovery ID.\"}}},\"title\":\"TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/EAS/TellerAS.sol\":\"TellerAS\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x60c06040523480156200001157600080fd5b5060405162001b0b38038062001b0b8339810160408190526200003491620000b5565b6001600160a01b0382166200005c576040516311a1e69760e01b815260040160405180910390fd5b6001600160a01b038116620000845760405163baa3de5f60e01b815260040160405180910390fd5b6001600160a01b039182166080521660a052620000f4565b6001600160a01b0381168114620000b257600080fd5b50565b60008060408385031215620000c957600080fd5b8251620000d6816200009c565b6020840151909250620000e9816200009c565b809150509250929050565b60805160a0516119dc6200012f600039600081816101b301528181610692015261092501526000818161028701526109cd01526119dc6000f3fe60806040526004361061011f5760003560e01c8063a3112a64116100a0578063d8c5ebd411610064578063d8c5ebd4146103a0578063e30bb563146103e3578063ef0a309814610412578063f96e501314610427578063ffa1ad741461043c57600080fd5b8063a3112a64146102be578063b75c7dc6146102eb578063c042d88f1461030d578063c334947c14610350578063d87647b21461038057600080fd5b806362196643116100e7578063621966431461020b57806363583538146102385780637f04f2841461025857806381fa6cd314610278578063930ed013146102ab57600080fd5b80630560f90f1461012457806309a954cd14610164578063105152981461017757806315cd31a1146101a45780631bc9a07a146101eb575b600080fd5b34801561013057600080fd5b5061015161013f366004611215565b60009081526020819052604090205490565b6040519081526020015b60405180910390f35b61015161017236600461128c565b610478565b34801561018357600080fd5b5061019761019236600461130d565b610494565b60405161015b9190611363565b3480156101b057600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b03909116815260200161015b565b3480156101f757600080fd5b5061019761020636600461130d565b61051a565b34801561021757600080fd5b50610151610226366004611215565b60009081526003602052604090205490565b34801561024457600080fd5b506101976102533660046113a7565b610594565b34801561026457600080fd5b506101976102733660046113a7565b61060c565b34801561028457600080fd5b507f00000000000000000000000000000000000000000000000000000000000000006101d3565b6101516102b93660046113fe565b610678565b3480156102ca57600080fd5b506102de6102d9366004611215565b610729565b60405161015b9190611504565b3480156102f757600080fd5b5061030b610306366004611215565b61088c565b005b34801561031957600080fd5b50610151610328366004611594565b6001600160a01b03919091166000908152600260209081526040808320938352929052205490565b34801561035c57600080fd5b5061037061036b366004611215565b610899565b604051901515815260200161015b565b34801561038c57600080fd5b5061030b61039b3660046115c0565b6108e8565b3480156103ac57600080fd5b506101516103bb366004611594565b6001600160a01b03919091166000908152600160209081526040808320938352929052205490565b3480156103ef57600080fd5b506103706103fe366004611215565b600090815260046020526040902054151590565b34801561041e57600080fd5b50600654610151565b34801561043357600080fd5b50600554610151565b34801561044857600080fd5b5061046b604051806040016040528060038152602001620605c760eb1b81525081565b60405161015b9190611610565b600061048987878787878733610992565b979650505050505050565b6001600160a01b03851660009081526001602090815260408083208784528252918290208054835181840281018401909452808452606093610510939092919083018282801561050357602002820191906000526020600020905b8154815260200190600101908083116104ef575b5050505050858585610f0b565b9695505050505050565b6001600160a01b03851660009081526002602090815260408083208784528252918290208054835181840281018401909452808452606093610510939092919083018282801561050357602002820191906000526020600020908154815260200190600101908083116104ef575050505050858585610f0b565b60606106016003600087815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561050357602002820191906000526020600020908154815260200190600101908083116104ef575050505050858585610f0b565b90505b949350505050565b606061060160008087815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561050357602002820191906000526020600020908154815260200190600101908083116104ef575050505050858585610f0b565b604051636aeb49a560e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636aeb49a5906106d9908e908e908e908e908e908e908e908e908e908e90600401611653565b600060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b5050505061071a8b8b8b8b8b8b8b610992565b9b9a5050505050505050505050565b604080516101208101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e08201929092526101008101919091526000828152600460208181526040928390208351610120810185528154815260018201549281019290925260028101546001600160a01b039081169483019490945260038101549093166060820152908201546080820152600582015460a0820152600682015460c0820152600782015460e082015260088201805491929161010084019190610803906116b6565b80601f016020809104026020016040519081016040528092919081815260200182805461082f906116b6565b801561087c5780601f106108515761010080835404028352916020019161087c565b820191906000526020600020905b81548152906001019060200180831161085f57829003601f168201915b5050505050815250509050919050565b6108968133611040565b50565b600081815260046020526040812054151580156108c757506000828152600460205260409020600501544211155b80156108e25750600082815260046020526040902060060154155b92915050565b604051631863f01d60e01b8152600481018690526001600160a01b03858116602483015260ff8516604483015260648201849052608482018390527f00000000000000000000000000000000000000000000000000000000000000001690631863f01d9060a401600060405180830381600087803b15801561096957600080fd5b505af115801561097d573d6000803e3d6000fd5b5050505061098b8585611040565b5050505050565b60004286116109b4576040516308e8b93760e01b815260040160405180910390fd5b6040516339243ea960e11b8152600481018890526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906372487d529060240160006040518083038186803b158015610a1757600080fd5b505afa158015610a2b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a539190810190611761565b8051909150610a7557604051635f9bd90760e11b815260040160405180910390fd5b60208101516001600160a01b03811615610bce573415801590610b065750806001600160a01b031663ce46e0466040518163ffffffff1660e01b815260040160206040518083038186803b158015610acc57600080fd5b505afa158015610ae0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b049190611849565b155b15610b2457604051631574f9f360e01b815260040160405180910390fd5b806001600160a01b031663947a75b4348c85606001518a8a8e8b6040518863ffffffff1660e01b8152600401610b5f96959493929190611866565b6020604051808303818588803b158015610b7857600080fd5b505af1158015610b8c573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610bb19190611849565b610bce5760405163bd8ba84d60e01b815260040160405180910390fd5b60006040518061012001604052806000801b81526020018b81526020018c6001600160a01b03168152602001866001600160a01b031681526020014281526020018a81526020016000815260200189815260200188888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152509050610c6581611116565b600681905550600654816000018181525050600160008c6001600160a01b03166001600160a01b0316815260200190815260200160002060008b8152602001908152602001600020600654908060018154018082558091505060019003906000526020600020016000909190919091505560026000866001600160a01b03166001600160a01b0316815260200190815260200160002060008b81526020019081526020016000206006549080600181540180825580915050600190039060005260206000200160009091909190915055600360008b8152602001908152602001600020600654908060018154018082558091505060019003906000526020600020016000909190919091505580600460006006548152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506080820151816004015560a0820151816005015560c0820151816006015560e08201518160070155610100820151816008019080519060200190610e3a92919061117c565b50506005805491506000610e4d836118cd565b90915550508715610ea957600088815260046020526040902054610e845760405163c5723b5160e01b815260040160405180910390fd5b6000888152602081815260408220600654815460018101835591845291909220909101555b89856001600160a01b03168c6001600160a01b03167f8bf46bf4cfd674fa735a3d63ec1c9ad4153f033c290341f3a588b75685141b35600654604051610ef191815260200190565b60405180910390a450506006549998505050505050505050565b835160609080610f2b575050604080516000815260208101909152610604565b808510610f4a5760405162ed0ab960e11b815260040160405180910390fd5b83610f5581876118e8565b821015610f6957610f668683611900565b90505b60008167ffffffffffffffff811115610f8457610f846116f1565b604051908082528060200260200182016040528015610fad578160200160208202803683370190505b50905060005b82811015611034578886610fd057610fcb828a6118e8565b610fef565b610fda828a6118e8565b610fe59060016118e8565b610fef9086611900565b81518110610fff57610fff611917565b602002602001015182828151811061101957611019611917565b602090810291909101015261102d816118cd565b9050610fb3565b50979650505050505050565b6000828152600460205260409020805461106d5760405163c5723b5160e01b815260040160405180910390fd5b60038101546001600160a01b0383811691161461109d57604051634ca8886760e01b815260040160405180910390fd5b6006810154156110c05760405163905e710760e01b815260040160405180910390fd5b426006820155600181015460028201546040518581526001600160a01b038581169216907ff930a6e2523c9cc298691873087a740550b8fc85a0680830414c148ed927f6159060200160405180910390a4505050565b6020808201516040808401516060850151608086015160a08701516101008801518551808701875260018152600160fe1b818a0152600554965160009961115f9998910161192d565b604051602081830303815290604052805190602001209050919050565b828054611188906116b6565b90600052602060002090601f0160209004810192826111aa57600085556111f0565b82601f106111c357805160ff19168380011785556111f0565b828001600101855582156111f0579182015b828111156111f05782518255916020019190600101906111d5565b506111fc929150611200565b5090565b5b808211156111fc5760008155600101611201565b60006020828403121561122757600080fd5b5035919050565b6001600160a01b038116811461089657600080fd5b60008083601f84011261125557600080fd5b50813567ffffffffffffffff81111561126d57600080fd5b60208301915083602082850101111561128557600080fd5b9250929050565b60008060008060008060a087890312156112a557600080fd5b86356112b08161122e565b9550602087013594506040870135935060608701359250608087013567ffffffffffffffff8111156112e157600080fd5b6112ed89828a01611243565b979a9699509497509295939492505050565b801515811461089657600080fd5b600080600080600060a0868803121561132557600080fd5b85356113308161122e565b94506020860135935060408601359250606086013591506080860135611355816112ff565b809150509295509295909350565b6020808252825182820181905260009190848201906040850190845b8181101561139b5783518352928401929184019160010161137f565b50909695505050505050565b600080600080608085870312156113bd57600080fd5b84359350602085013592506040850135915060608501356113dd816112ff565b939692955090935050565b803560ff811681146113f957600080fd5b919050565b6000806000806000806000806000806101208b8d03121561141e57600080fd5b8a356114298161122e565b995060208b0135985060408b0135975060608b0135965060808b013567ffffffffffffffff81111561145a57600080fd5b6114668d828e01611243565b90975095505060a08b013561147a8161122e565b935061148860c08c016113e8565b925060e08b013591506101008b013590509295989b9194979a5092959850565b60005b838110156114c35781810151838201526020016114ab565b838111156114d2576000848401525b50505050565b600081518084526114f08160208601602086016114a8565b601f01601f19169290920160200192915050565b6020815281516020820152602082015160408201526000604083015161153560608401826001600160a01b03169052565b5060608301516001600160a01b038116608084015250608083015160a083015260a083015160c083015260c083015160e083015260e08301516101008181850152808501519150506101208081850152506106046101408401826114d8565b600080604083850312156115a757600080fd5b82356115b28161122e565b946020939093013593505050565b600080600080600060a086880312156115d857600080fd5b8535945060208601356115ea8161122e565b93506115f8604087016113e8565b94979396509394606081013594506080013592915050565b60208152600061162360208301846114d8565b9392505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600061012060018060a01b03808e1684528c60208501528b60408501528a60608501528160808501526116898285018a8c61162a565b971660a0840152505060ff9390931660c084015260e0830191909152610100909101529695505050505050565b600181811c908216806116ca57607f821691505b602082108114156116eb57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff8111828210171561172a5761172a6116f1565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611759576117596116f1565b604052919050565b6000602080838503121561177457600080fd5b825167ffffffffffffffff8082111561178c57600080fd5b90840190608082870312156117a057600080fd5b6117a8611707565b82518152838301516117b98161122e565b81850152604083810151908201526060830151828111156117d957600080fd5b80840193505086601f8401126117ee57600080fd5b825182811115611800576118006116f1565b611812601f8201601f19168601611730565b9250808352878582860101111561182857600080fd5b611837818685018787016114a8565b50606081019190915295945050505050565b60006020828403121561185b57600080fd5b8151611623816112ff565b600060018060a01b03808916835260a0602084015261188860a08401896114d8565b838103604085015261189b81888a61162a565b6060850196909652509290921660809091015250949350505050565b634e487b7160e01b600052601160045260246000fd5b60006000198214156118e1576118e16118b7565b5060010190565b600082198211156118fb576118fb6118b7565b500190565b600082821015611912576119126118b7565b500390565b634e487b7160e01b600052603260045260246000fd5b88815260006bffffffffffffffffffffffff19808a60601b166020840152808960601b1660348401525086604883015285606883015284516119768160888501602089016114a8565b84519083019061198d8160888401602089016114a8565b016088810193909352505060a80197965050505050505056fea2646970667358221220ce2e1359976d29e848bbadc08f07b475114fb5554ab030d76d1b618c8489879c64736f6c63430008090033", "deployedBytecode": "0x60806040526004361061011f5760003560e01c8063a3112a64116100a0578063d8c5ebd411610064578063d8c5ebd4146103a0578063e30bb563146103e3578063ef0a309814610412578063f96e501314610427578063ffa1ad741461043c57600080fd5b8063a3112a64146102be578063b75c7dc6146102eb578063c042d88f1461030d578063c334947c14610350578063d87647b21461038057600080fd5b806362196643116100e7578063621966431461020b57806363583538146102385780637f04f2841461025857806381fa6cd314610278578063930ed013146102ab57600080fd5b80630560f90f1461012457806309a954cd14610164578063105152981461017757806315cd31a1146101a45780631bc9a07a146101eb575b600080fd5b34801561013057600080fd5b5061015161013f366004611215565b60009081526020819052604090205490565b6040519081526020015b60405180910390f35b61015161017236600461128c565b610478565b34801561018357600080fd5b5061019761019236600461130d565b610494565b60405161015b9190611363565b3480156101b057600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b03909116815260200161015b565b3480156101f757600080fd5b5061019761020636600461130d565b61051a565b34801561021757600080fd5b50610151610226366004611215565b60009081526003602052604090205490565b34801561024457600080fd5b506101976102533660046113a7565b610594565b34801561026457600080fd5b506101976102733660046113a7565b61060c565b34801561028457600080fd5b507f00000000000000000000000000000000000000000000000000000000000000006101d3565b6101516102b93660046113fe565b610678565b3480156102ca57600080fd5b506102de6102d9366004611215565b610729565b60405161015b9190611504565b3480156102f757600080fd5b5061030b610306366004611215565b61088c565b005b34801561031957600080fd5b50610151610328366004611594565b6001600160a01b03919091166000908152600260209081526040808320938352929052205490565b34801561035c57600080fd5b5061037061036b366004611215565b610899565b604051901515815260200161015b565b34801561038c57600080fd5b5061030b61039b3660046115c0565b6108e8565b3480156103ac57600080fd5b506101516103bb366004611594565b6001600160a01b03919091166000908152600160209081526040808320938352929052205490565b3480156103ef57600080fd5b506103706103fe366004611215565b600090815260046020526040902054151590565b34801561041e57600080fd5b50600654610151565b34801561043357600080fd5b50600554610151565b34801561044857600080fd5b5061046b604051806040016040528060038152602001620605c760eb1b81525081565b60405161015b9190611610565b600061048987878787878733610992565b979650505050505050565b6001600160a01b03851660009081526001602090815260408083208784528252918290208054835181840281018401909452808452606093610510939092919083018282801561050357602002820191906000526020600020905b8154815260200190600101908083116104ef575b5050505050858585610f0b565b9695505050505050565b6001600160a01b03851660009081526002602090815260408083208784528252918290208054835181840281018401909452808452606093610510939092919083018282801561050357602002820191906000526020600020908154815260200190600101908083116104ef575050505050858585610f0b565b60606106016003600087815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561050357602002820191906000526020600020908154815260200190600101908083116104ef575050505050858585610f0b565b90505b949350505050565b606061060160008087815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561050357602002820191906000526020600020908154815260200190600101908083116104ef575050505050858585610f0b565b604051636aeb49a560e01b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636aeb49a5906106d9908e908e908e908e908e908e908e908e908e908e90600401611653565b600060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b5050505061071a8b8b8b8b8b8b8b610992565b9b9a5050505050505050505050565b604080516101208101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e08201929092526101008101919091526000828152600460208181526040928390208351610120810185528154815260018201549281019290925260028101546001600160a01b039081169483019490945260038101549093166060820152908201546080820152600582015460a0820152600682015460c0820152600782015460e082015260088201805491929161010084019190610803906116b6565b80601f016020809104026020016040519081016040528092919081815260200182805461082f906116b6565b801561087c5780601f106108515761010080835404028352916020019161087c565b820191906000526020600020905b81548152906001019060200180831161085f57829003601f168201915b5050505050815250509050919050565b6108968133611040565b50565b600081815260046020526040812054151580156108c757506000828152600460205260409020600501544211155b80156108e25750600082815260046020526040902060060154155b92915050565b604051631863f01d60e01b8152600481018690526001600160a01b03858116602483015260ff8516604483015260648201849052608482018390527f00000000000000000000000000000000000000000000000000000000000000001690631863f01d9060a401600060405180830381600087803b15801561096957600080fd5b505af115801561097d573d6000803e3d6000fd5b5050505061098b8585611040565b5050505050565b60004286116109b4576040516308e8b93760e01b815260040160405180910390fd5b6040516339243ea960e11b8152600481018890526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906372487d529060240160006040518083038186803b158015610a1757600080fd5b505afa158015610a2b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a539190810190611761565b8051909150610a7557604051635f9bd90760e11b815260040160405180910390fd5b60208101516001600160a01b03811615610bce573415801590610b065750806001600160a01b031663ce46e0466040518163ffffffff1660e01b815260040160206040518083038186803b158015610acc57600080fd5b505afa158015610ae0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b049190611849565b155b15610b2457604051631574f9f360e01b815260040160405180910390fd5b806001600160a01b031663947a75b4348c85606001518a8a8e8b6040518863ffffffff1660e01b8152600401610b5f96959493929190611866565b6020604051808303818588803b158015610b7857600080fd5b505af1158015610b8c573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610bb19190611849565b610bce5760405163bd8ba84d60e01b815260040160405180910390fd5b60006040518061012001604052806000801b81526020018b81526020018c6001600160a01b03168152602001866001600160a01b031681526020014281526020018a81526020016000815260200189815260200188888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152509050610c6581611116565b600681905550600654816000018181525050600160008c6001600160a01b03166001600160a01b0316815260200190815260200160002060008b8152602001908152602001600020600654908060018154018082558091505060019003906000526020600020016000909190919091505560026000866001600160a01b03166001600160a01b0316815260200190815260200160002060008b81526020019081526020016000206006549080600181540180825580915050600190039060005260206000200160009091909190915055600360008b8152602001908152602001600020600654908060018154018082558091505060019003906000526020600020016000909190919091505580600460006006548152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506080820151816004015560a0820151816005015560c0820151816006015560e08201518160070155610100820151816008019080519060200190610e3a92919061117c565b50506005805491506000610e4d836118cd565b90915550508715610ea957600088815260046020526040902054610e845760405163c5723b5160e01b815260040160405180910390fd5b6000888152602081815260408220600654815460018101835591845291909220909101555b89856001600160a01b03168c6001600160a01b03167f8bf46bf4cfd674fa735a3d63ec1c9ad4153f033c290341f3a588b75685141b35600654604051610ef191815260200190565b60405180910390a450506006549998505050505050505050565b835160609080610f2b575050604080516000815260208101909152610604565b808510610f4a5760405162ed0ab960e11b815260040160405180910390fd5b83610f5581876118e8565b821015610f6957610f668683611900565b90505b60008167ffffffffffffffff811115610f8457610f846116f1565b604051908082528060200260200182016040528015610fad578160200160208202803683370190505b50905060005b82811015611034578886610fd057610fcb828a6118e8565b610fef565b610fda828a6118e8565b610fe59060016118e8565b610fef9086611900565b81518110610fff57610fff611917565b602002602001015182828151811061101957611019611917565b602090810291909101015261102d816118cd565b9050610fb3565b50979650505050505050565b6000828152600460205260409020805461106d5760405163c5723b5160e01b815260040160405180910390fd5b60038101546001600160a01b0383811691161461109d57604051634ca8886760e01b815260040160405180910390fd5b6006810154156110c05760405163905e710760e01b815260040160405180910390fd5b426006820155600181015460028201546040518581526001600160a01b038581169216907ff930a6e2523c9cc298691873087a740550b8fc85a0680830414c148ed927f6159060200160405180910390a4505050565b6020808201516040808401516060850151608086015160a08701516101008801518551808701875260018152600160fe1b818a0152600554965160009961115f9998910161192d565b604051602081830303815290604052805190602001209050919050565b828054611188906116b6565b90600052602060002090601f0160209004810192826111aa57600085556111f0565b82601f106111c357805160ff19168380011785556111f0565b828001600101855582156111f0579182015b828111156111f05782518255916020019190600101906111d5565b506111fc929150611200565b5090565b5b808211156111fc5760008155600101611201565b60006020828403121561122757600080fd5b5035919050565b6001600160a01b038116811461089657600080fd5b60008083601f84011261125557600080fd5b50813567ffffffffffffffff81111561126d57600080fd5b60208301915083602082850101111561128557600080fd5b9250929050565b60008060008060008060a087890312156112a557600080fd5b86356112b08161122e565b9550602087013594506040870135935060608701359250608087013567ffffffffffffffff8111156112e157600080fd5b6112ed89828a01611243565b979a9699509497509295939492505050565b801515811461089657600080fd5b600080600080600060a0868803121561132557600080fd5b85356113308161122e565b94506020860135935060408601359250606086013591506080860135611355816112ff565b809150509295509295909350565b6020808252825182820181905260009190848201906040850190845b8181101561139b5783518352928401929184019160010161137f565b50909695505050505050565b600080600080608085870312156113bd57600080fd5b84359350602085013592506040850135915060608501356113dd816112ff565b939692955090935050565b803560ff811681146113f957600080fd5b919050565b6000806000806000806000806000806101208b8d03121561141e57600080fd5b8a356114298161122e565b995060208b0135985060408b0135975060608b0135965060808b013567ffffffffffffffff81111561145a57600080fd5b6114668d828e01611243565b90975095505060a08b013561147a8161122e565b935061148860c08c016113e8565b925060e08b013591506101008b013590509295989b9194979a5092959850565b60005b838110156114c35781810151838201526020016114ab565b838111156114d2576000848401525b50505050565b600081518084526114f08160208601602086016114a8565b601f01601f19169290920160200192915050565b6020815281516020820152602082015160408201526000604083015161153560608401826001600160a01b03169052565b5060608301516001600160a01b038116608084015250608083015160a083015260a083015160c083015260c083015160e083015260e08301516101008181850152808501519150506101208081850152506106046101408401826114d8565b600080604083850312156115a757600080fd5b82356115b28161122e565b946020939093013593505050565b600080600080600060a086880312156115d857600080fd5b8535945060208601356115ea8161122e565b93506115f8604087016113e8565b94979396509394606081013594506080013592915050565b60208152600061162360208301846114d8565b9392505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600061012060018060a01b03808e1684528c60208501528b60408501528a60608501528160808501526116898285018a8c61162a565b971660a0840152505060ff9390931660c084015260e0830191909152610100909101529695505050505050565b600181811c908216806116ca57607f821691505b602082108114156116eb57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff8111828210171561172a5761172a6116f1565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611759576117596116f1565b604052919050565b6000602080838503121561177457600080fd5b825167ffffffffffffffff8082111561178c57600080fd5b90840190608082870312156117a057600080fd5b6117a8611707565b82518152838301516117b98161122e565b81850152604083810151908201526060830151828111156117d957600080fd5b80840193505086601f8401126117ee57600080fd5b825182811115611800576118006116f1565b611812601f8201601f19168601611730565b9250808352878582860101111561182857600080fd5b611837818685018787016114a8565b50606081019190915295945050505050565b60006020828403121561185b57600080fd5b8151611623816112ff565b600060018060a01b03808916835260a0602084015261188860a08401896114d8565b838103604085015261189b81888a61162a565b6060850196909652509290921660809091015250949350505050565b634e487b7160e01b600052601160045260246000fd5b60006000198214156118e1576118e16118b7565b5060010190565b600082198211156118fb576118fb6118b7565b500190565b600082821015611912576119126118b7565b500390565b634e487b7160e01b600052603260045260246000fd5b88815260006bffffffffffffffffffffffff19808a60601b166020840152808960601b1660348401525086604883015285606883015284516119768160888501602089016114a8565b84519083019061198d8160888401602089016114a8565b016088810193909352505060a80197965050505050505056fea2646970667358221220ce2e1359976d29e848bbadc08f07b475114fb5554ab030d76d1b618c8489879c64736f6c63430008090033", @@ -901,7 +901,7 @@ "storageLayout": { "storage": [ { - "astId": 15744, + "astId": 14119, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "_relatedAttestations", "offset": 0, @@ -909,7 +909,7 @@ "type": "t_mapping(t_bytes32,t_array(t_bytes32)dyn_storage)" }, { - "astId": 15751, + "astId": 14126, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "_receivedAttestations", "offset": 0, @@ -917,7 +917,7 @@ "type": "t_mapping(t_address,t_mapping(t_bytes32,t_array(t_bytes32)dyn_storage))" }, { - "astId": 15758, + "astId": 14133, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "_sentAttestations", "offset": 0, @@ -925,7 +925,7 @@ "type": "t_mapping(t_address,t_mapping(t_bytes32,t_array(t_bytes32)dyn_storage))" }, { - "astId": 15763, + "astId": 14138, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "_schemaAttestations", "offset": 0, @@ -933,15 +933,15 @@ "type": "t_mapping(t_bytes32,t_array(t_bytes32)dyn_storage)" }, { - "astId": 15768, + "astId": 14143, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "_db", "offset": 0, "slot": "4", - "type": "t_mapping(t_bytes32,t_struct(Attestation)24641_storage)" + "type": "t_mapping(t_bytes32,t_struct(Attestation)23958_storage)" }, { - "astId": 15770, + "astId": 14145, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "_attestationsCount", "offset": 0, @@ -949,7 +949,7 @@ "type": "t_uint256" }, { - "astId": 15772, + "astId": 14147, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "_lastUUID", "offset": 0, @@ -993,19 +993,19 @@ "numberOfBytes": "32", "value": "t_array(t_bytes32)dyn_storage" }, - "t_mapping(t_bytes32,t_struct(Attestation)24641_storage)": { + "t_mapping(t_bytes32,t_struct(Attestation)23958_storage)": { "encoding": "mapping", "key": "t_bytes32", "label": "mapping(bytes32 => struct IEAS.Attestation)", "numberOfBytes": "32", - "value": "t_struct(Attestation)24641_storage" + "value": "t_struct(Attestation)23958_storage" }, - "t_struct(Attestation)24641_storage": { + "t_struct(Attestation)23958_storage": { "encoding": "inplace", "label": "struct IEAS.Attestation", "members": [ { - "astId": 24624, + "astId": 23941, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "uuid", "offset": 0, @@ -1013,7 +1013,7 @@ "type": "t_bytes32" }, { - "astId": 24626, + "astId": 23943, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "schema", "offset": 0, @@ -1021,7 +1021,7 @@ "type": "t_bytes32" }, { - "astId": 24628, + "astId": 23945, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "recipient", "offset": 0, @@ -1029,7 +1029,7 @@ "type": "t_address" }, { - "astId": 24630, + "astId": 23947, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "attester", "offset": 0, @@ -1037,7 +1037,7 @@ "type": "t_address" }, { - "astId": 24632, + "astId": 23949, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "time", "offset": 0, @@ -1045,7 +1045,7 @@ "type": "t_uint256" }, { - "astId": 24634, + "astId": 23951, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "expirationTime", "offset": 0, @@ -1053,7 +1053,7 @@ "type": "t_uint256" }, { - "astId": 24636, + "astId": 23953, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "revocationTime", "offset": 0, @@ -1061,7 +1061,7 @@ "type": "t_uint256" }, { - "astId": 24638, + "astId": 23955, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "refUUID", "offset": 0, @@ -1069,7 +1069,7 @@ "type": "t_bytes32" }, { - "astId": 24640, + "astId": 23957, "contract": "contracts/EAS/TellerAS.sol:TellerAS", "label": "data", "offset": 0, diff --git a/packages/contracts/deployments/goerli/TellerASEIP712Verifier.json b/packages/contracts/deployments/goerli/TellerASEIP712Verifier.json index 3f4292f72..cd6758306 100644 --- a/packages/contracts/deployments/goerli/TellerASEIP712Verifier.json +++ b/packages/contracts/deployments/goerli/TellerASEIP712Verifier.json @@ -1,5 +1,5 @@ { - "address": "0xe7168c514A022345ed07E4Fad73eC3921C2b7bDb", + "address": "0x42BBB41A67F9966ca180ef2A869c652daC81ede0", "abi": [ { "inputs": [], @@ -169,25 +169,25 @@ "type": "function" } ], - "transactionHash": "0xf90c702af723fc90a7aee1a9515dfd5903eb83313adc9dfa49e0db9a5baf70cf", + "transactionHash": "0x10b48a5495610585a8c2b2ddcaa0908b22c8a6f51763217a6c0b78172aad887e", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xe7168c514A022345ed07E4Fad73eC3921C2b7bDb", - "transactionIndex": 1, - "gasUsed": "451100", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x42BBB41A67F9966ca180ef2A869c652daC81ede0", + "transactionIndex": 7, + "gasUsed": "451232", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x68903492fff327e677d3c60b69cb365fd235c844cb002ad3b44194b702183550", - "transactionHash": "0xf90c702af723fc90a7aee1a9515dfd5903eb83313adc9dfa49e0db9a5baf70cf", + "blockHash": "0xf2bebccef341b1969a3a524a03cb25ea74a0420511dc51f059bf469a38b6bd13", + "transactionHash": "0x10b48a5495610585a8c2b2ddcaa0908b22c8a6f51763217a6c0b78172aad887e", "logs": [], - "blockNumber": 8538436, - "cumulativeGasUsed": "472100", + "blockNumber": 8688908, + "cumulativeGasUsed": "598232", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "556fedad003f0c0b44fba88774cf2ef3", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSignature\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ATTEST_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REVOKE_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"schema\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"expirationTime\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"refUUID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"attest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"revoke\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"attest(address,bytes32,uint256,bytes32,bytes,address,uint8,bytes32,bytes32)\":{\"details\":\"Verifies signed attestation.\",\"params\":{\"attester\":\"The attesting account.\",\"data\":\"Additional custom data.\",\"expirationTime\":\"The expiration time of the attestation.\",\"r\":\"The x-coordinate of the nonce R.\",\"recipient\":\"The recipient of the attestation.\",\"refUUID\":\"An optional related attestation's UUID.\",\"s\":\"The signature data.\",\"schema\":\"The UUID of the AS.\",\"v\":\"The recovery ID.\"}},\"constructor\":{\"details\":\"Creates a new EIP712Verifier instance.\"},\"getNonce(address)\":{\"details\":\"Returns the current nonce per-account.\",\"params\":{\"account\":\"The requested accunt.\"},\"returns\":{\"_0\":\"The current nonce.\"}},\"revoke(bytes32,address,uint8,bytes32,bytes32)\":{\"details\":\"Verifies signed revocations.\",\"params\":{\"attester\":\"The attesting account.\",\"r\":\"The x-coordinate of the nonce R.\",\"s\":\"The signature data.\",\"uuid\":\"The UUID of the attestation to revoke.\",\"v\":\"The recovery ID.\"}}},\"title\":\"EIP712 typed signatures verifier for EAS delegated attestations.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/EAS/TellerASEIP712Verifier.sol\":\"TellerASEIP712Verifier\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/EAS/TellerASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../interfaces/IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations.\\n */\\ncontract TellerASEIP712Verifier is IEASEIP712Verifier {\\n error InvalidSignature();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // EIP712 domain separator, making signatures from different domains incompatible.\\n bytes32 public immutable DOMAIN_SEPARATOR; // solhint-disable-line var-name-mixedcase\\n\\n // The hash of the data type used to relay calls to the attest function. It's the value of\\n // keccak256(\\\"Attest(address recipient,bytes32 schema,uint256 expirationTime,bytes32 refUUID,bytes data,uint256 nonce)\\\").\\n bytes32 public constant ATTEST_TYPEHASH =\\n 0x39c0608dd995a3a25bfecb0fffe6801a81bae611d94438af988caa522d9d1476;\\n\\n // The hash of the data type used to relay calls to the revoke function. It's the value of\\n // keccak256(\\\"Revoke(bytes32 uuid,uint256 nonce)\\\").\\n bytes32 public constant REVOKE_TYPEHASH =\\n 0xbae0931f3a99efd1b97c2f5b6b6e79d16418246b5055d64757e16de5ad11a8ab;\\n\\n // Replay protection nonces.\\n mapping(address => uint256) private _nonces;\\n\\n /**\\n * @dev Creates a new EIP712Verifier instance.\\n */\\n constructor() {\\n uint256 chainId;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n chainId := chainid()\\n }\\n\\n DOMAIN_SEPARATOR = keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(\\\"EAS\\\")),\\n keccak256(bytes(VERSION)),\\n chainId,\\n address(this)\\n )\\n );\\n }\\n\\n /**\\n * @inheritdoc IEASEIP712Verifier\\n */\\n function getNonce(address account)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _nonces[account];\\n }\\n\\n /**\\n * @inheritdoc IEASEIP712Verifier\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR,\\n keccak256(\\n abi.encode(\\n ATTEST_TYPEHASH,\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n keccak256(data),\\n _nonces[attester]++\\n )\\n )\\n )\\n );\\n\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n if (recoveredAddress == address(0) || recoveredAddress != attester) {\\n revert InvalidSignature();\\n }\\n }\\n\\n /**\\n * @inheritdoc IEASEIP712Verifier\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR,\\n keccak256(\\n abi.encode(REVOKE_TYPEHASH, uuid, _nonces[attester]++)\\n )\\n )\\n );\\n\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n if (recoveredAddress == address(0) || recoveredAddress != attester) {\\n revert InvalidSignature();\\n }\\n }\\n}\\n\",\"keccak256\":\"0x893f7174a3f30019e37a01b0bfd903caf18125259d13aedbad9212d402c4a4a1\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x60a060405234801561001057600080fd5b5060408051808201825260038082526245415360e81b60209283015282518084018452908152620605c760eb1b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527f9fed719e0073f95229e6f4f6b6f28f260c524ab08aa40b11f9c28cb710d7c72a818401527f15e7a716d821b9602c70f6d0f574efbb8147fb465215d43354c7b3e69d03ed926060820152466080808301919091523060a0808401919091528451808403909101815260c09092019093528051910120908190526107256101076000396000818160d8015281816101a6015261031a01526107256000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80636aeb49a51161005b5780636aeb49a5146100fa5780637e4a7d8f1461010d5780638a73222714610134578063ffa1ad741461015b57600080fd5b80631863f01d146100825780632d0335ab146100975780633644e515146100d3575b600080fd5b61009561009036600461051b565b61018a565b005b6100c06100a5366004610569565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b6100c07f000000000000000000000000000000000000000000000000000000000000000081565b61009561010836600461058b565b610316565b6100c07f39c0608dd995a3a25bfecb0fffe6801a81bae611d94438af988caa522d9d147681565b6100c07fbae0931f3a99efd1b97c2f5b6b6e79d16418246b5055d64757e16de5ad11a8ab81565b61017d604051806040016040528060038152602001620605c760eb1b81525081565b6040516100ca9190610661565b6001600160a01b038416600090815260208190526040812080547f0000000000000000000000000000000000000000000000000000000000000000917fbae0931f3a99efd1b97c2f5b6b6e79d16418246b5055d64757e16de5ad11a8ab918991856101f4836106b6565b9091555060408051602081019490945283019190915260608201526080016040516020818303038152906040528051906020012060405160200161024f92919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa1580156102ba573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806102ef5750856001600160a01b0316816001600160a01b031614155b1561030d57604051638baa579f60e01b815260040160405180910390fd5b50505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000007f39c0608dd995a3a25bfecb0fffe6801a81bae611d94438af988caa522d9d147660001b8c8c8c8c8c8c6040516103719291906106df565b60408051918290039091206001600160a01b038d1660009081526020819052918220805491926103a0836106b6565b909155506040805160208101989098526001600160a01b03909616958701959095526060860193909352608085019190915260a084015260c083015260e0820152610100016040516020818303038152906040528051906020012060405160200161042292919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa15801561048d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806104c25750856001600160a01b0316816001600160a01b031614155b156104e057604051638baa579f60e01b815260040160405180910390fd5b505050505050505050505050565b80356001600160a01b038116811461050557600080fd5b919050565b803560ff8116811461050557600080fd5b600080600080600060a0868803121561053357600080fd5b85359450610543602087016104ee565b93506105516040870161050a565b94979396509394606081013594506080013592915050565b60006020828403121561057b57600080fd5b610584826104ee565b9392505050565b6000806000806000806000806000806101208b8d0312156105ab57600080fd5b6105b48b6104ee565b995060208b0135985060408b0135975060608b0135965060808b013567ffffffffffffffff808211156105e657600080fd5b818d0191508d601f8301126105fa57600080fd5b81358181111561060957600080fd5b8e602082850101111561061b57600080fd5b60208301985080975050505061063360a08c016104ee565b935061064160c08c0161050a565b925060e08b013591506101008b013590509295989b9194979a5092959850565b600060208083528351808285015260005b8181101561068e57858101830151858201604001528201610672565b818111156106a0576000604083870101525b50601f01601f1916929092016040019392505050565b60006000198214156106d857634e487b7160e01b600052601160045260246000fd5b5060010190565b818382376000910190815291905056fea26469706673582212206c3bd4e080d58d8688accd1dcd85cf77b7866874b6f356edf06a2440f918a39664736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80636aeb49a51161005b5780636aeb49a5146100fa5780637e4a7d8f1461010d5780638a73222714610134578063ffa1ad741461015b57600080fd5b80631863f01d146100825780632d0335ab146100975780633644e515146100d3575b600080fd5b61009561009036600461051b565b61018a565b005b6100c06100a5366004610569565b6001600160a01b031660009081526020819052604090205490565b6040519081526020015b60405180910390f35b6100c07f000000000000000000000000000000000000000000000000000000000000000081565b61009561010836600461058b565b610316565b6100c07f39c0608dd995a3a25bfecb0fffe6801a81bae611d94438af988caa522d9d147681565b6100c07fbae0931f3a99efd1b97c2f5b6b6e79d16418246b5055d64757e16de5ad11a8ab81565b61017d604051806040016040528060038152602001620605c760eb1b81525081565b6040516100ca9190610661565b6001600160a01b038416600090815260208190526040812080547f0000000000000000000000000000000000000000000000000000000000000000917fbae0931f3a99efd1b97c2f5b6b6e79d16418246b5055d64757e16de5ad11a8ab918991856101f4836106b6565b9091555060408051602081019490945283019190915260608201526080016040516020818303038152906040528051906020012060405160200161024f92919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa1580156102ba573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806102ef5750856001600160a01b0316816001600160a01b031614155b1561030d57604051638baa579f60e01b815260040160405180910390fd5b50505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000007f39c0608dd995a3a25bfecb0fffe6801a81bae611d94438af988caa522d9d147660001b8c8c8c8c8c8c6040516103719291906106df565b60408051918290039091206001600160a01b038d1660009081526020819052918220805491926103a0836106b6565b909155506040805160208101989098526001600160a01b03909616958701959095526060860193909352608085019190915260a084015260c083015260e0820152610100016040516020818303038152906040528051906020012060405160200161042292919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa15801561048d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806104c25750856001600160a01b0316816001600160a01b031614155b156104e057604051638baa579f60e01b815260040160405180910390fd5b505050505050505050505050565b80356001600160a01b038116811461050557600080fd5b919050565b803560ff8116811461050557600080fd5b600080600080600060a0868803121561053357600080fd5b85359450610543602087016104ee565b93506105516040870161050a565b94979396509394606081013594506080013592915050565b60006020828403121561057b57600080fd5b610584826104ee565b9392505050565b6000806000806000806000806000806101208b8d0312156105ab57600080fd5b6105b48b6104ee565b995060208b0135985060408b0135975060608b0135965060808b013567ffffffffffffffff808211156105e657600080fd5b818d0191508d601f8301126105fa57600080fd5b81358181111561060957600080fd5b8e602082850101111561061b57600080fd5b60208301985080975050505061063360a08c016104ee565b935061064160c08c0161050a565b925060e08b013591506101008b013590509295989b9194979a5092959850565b600060208083528351808285015260005b8181101561068e57858101830151858201604001528201610672565b818111156106a0576000604083870101525b50601f01601f1916929092016040019392505050565b60006000198214156106d857634e487b7160e01b600052601160045260246000fd5b5060010190565b818382376000910190815291905056fea26469706673582212206c3bd4e080d58d8688accd1dcd85cf77b7866874b6f356edf06a2440f918a39664736f6c63430008090033", @@ -242,7 +242,7 @@ "storageLayout": { "storage": [ { - "astId": 16626, + "astId": 15001, "contract": "contracts/EAS/TellerASEIP712Verifier.sol:TellerASEIP712Verifier", "label": "_nonces", "offset": 0, diff --git a/packages/contracts/deployments/goerli/TellerASRegistry.json b/packages/contracts/deployments/goerli/TellerASRegistry.json index 8068b2574..a70776b0a 100644 --- a/packages/contracts/deployments/goerli/TellerASRegistry.json +++ b/packages/contracts/deployments/goerli/TellerASRegistry.json @@ -1,5 +1,5 @@ { - "address": "0x66ed2c7123FE6e95EE5Dfd27EaCD30cedb5F9cD2", + "address": "0x16Ba53DDE085132b6cEb93334335f4236f6B58d4", "abi": [ { "inputs": [], @@ -135,25 +135,25 @@ "type": "function" } ], - "transactionHash": "0xeeb074b8539a946fd68dbb637f6183c3776522a5645d2c821f92a5613e07afee", + "transactionHash": "0xa12e010630f05f0cb40c843d7ff80ddb40dfa3010736e2a8641663f916b3ff72", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x66ed2c7123FE6e95EE5Dfd27EaCD30cedb5F9cD2", - "transactionIndex": 1, - "gasUsed": "415542", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x16Ba53DDE085132b6cEb93334335f4236f6B58d4", + "transactionIndex": 9, + "gasUsed": "415650", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x0819c1e180815824b6d4a53e968f05e1e9e2555f9bc113a19887fbabf63991dc", - "transactionHash": "0xeeb074b8539a946fd68dbb637f6183c3776522a5645d2c821f92a5613e07afee", + "blockHash": "0xaeea6e3b2f073b9cea3fb9713453bad3adba2f258a768a3e2481d548aa266f18", + "transactionHash": "0xa12e010630f05f0cb40c843d7ff80ddb40dfa3010736e2a8641663f916b3ff72", "logs": [], - "blockNumber": 8538435, - "cumulativeGasUsed": "436542", + "blockNumber": 8688907, + "cumulativeGasUsed": "604650", "status": 1, "byzantium": true }, "args": [], "numDeployments": 1, - "solcInputHash": "556fedad003f0c0b44fba88774cf2ef3", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AlreadyExists\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"schema\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"contract IASResolver\",\"name\":\"resolver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"attester\",\"type\":\"address\"}],\"name\":\"Registered\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"}],\"name\":\"getAS\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"uuid\",\"type\":\"bytes32\"},{\"internalType\":\"contract IASResolver\",\"name\":\"resolver\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"schema\",\"type\":\"bytes\"}],\"internalType\":\"struct IASRegistry.ASRecord\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getASCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"schema\",\"type\":\"bytes\"},{\"internalType\":\"contract IASResolver\",\"name\":\"resolver\",\"type\":\"address\"}],\"name\":\"register\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getAS(bytes32)\":{\"details\":\"Returns an existing AS by UUID\",\"params\":{\"uuid\":\"The UUID of the AS to retrieve.\"},\"returns\":{\"_0\":\"The AS data members.\"}},\"getASCount()\":{\"details\":\"Returns the global counter for the total number of attestations\",\"returns\":{\"_0\":\"The global counter for the total number of attestations.\"}},\"register(bytes,address)\":{\"details\":\"Submits and reserve a new AS\",\"params\":{\"resolver\":\"An optional AS schema resolver.\",\"schema\":\"The AS data schema.\"},\"returns\":{\"_0\":\"The UUID of the new AS.\"}}},\"title\":\"The global AS registry.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/EAS/TellerASRegistry.sol\":\"TellerASRegistry\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/EAS/TellerASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\nimport \\\"../interfaces/IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry.\\n */\\ncontract TellerASRegistry is IASRegistry {\\n error AlreadyExists();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // The global mapping between AS records and their IDs.\\n mapping(bytes32 => ASRecord) private _registry;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _asCount;\\n\\n /**\\n * @inheritdoc IASRegistry\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n override\\n returns (bytes32)\\n {\\n uint256 index = ++_asCount;\\n\\n ASRecord memory asRecord = ASRecord({\\n uuid: EMPTY_UUID,\\n index: index,\\n schema: schema,\\n resolver: resolver\\n });\\n\\n bytes32 uuid = _getUUID(asRecord);\\n if (_registry[uuid].uuid != EMPTY_UUID) {\\n revert AlreadyExists();\\n }\\n\\n asRecord.uuid = uuid;\\n _registry[uuid] = asRecord;\\n\\n emit Registered(uuid, index, schema, resolver, msg.sender);\\n\\n return uuid;\\n }\\n\\n /**\\n * @inheritdoc IASRegistry\\n */\\n function getAS(bytes32 uuid)\\n external\\n view\\n override\\n returns (ASRecord memory)\\n {\\n return _registry[uuid];\\n }\\n\\n /**\\n * @inheritdoc IASRegistry\\n */\\n function getASCount() external view override returns (uint256) {\\n return _asCount;\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given AS.\\n *\\n * @param asRecord The input AS.\\n *\\n * @return AS UUID.\\n */\\n function _getUUID(ASRecord memory asRecord) private pure returns (bytes32) {\\n return keccak256(abi.encodePacked(asRecord.schema, asRecord.resolver));\\n }\\n}\\n\",\"keccak256\":\"0x1d5782c3bb5ea52db95c8ce6d7ff6d20382bae8ca574614cfbaa45c05f93f13c\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b5061068e806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806372487d5214610051578063a99e7e291461007a578063d96250641461009b578063ffa1ad74146100a3575b600080fd5b61006461005f36600461040f565b6100d2565b6040516100719190610484565b60405180910390f35b61008d6100883660046104cd565b6101d3565b604051908152602001610071565b60015461008d565b6100c5604051806040016040528060038152602001620605c760eb1b81525081565b604051610071919061055c565b60408051608081018252600080825260208201819052918101919091526060808201526000828152602081815260409182902082516080810184528154815260018201546001600160a01b03169281019290925260028101549282019290925260038201805491929160608401919061014a90610576565b80601f016020809104026020016040519081016040528092919081815260200182805461017690610576565b80156101c35780601f10610198576101008083540402835291602001916101c3565b820191906000526020600020905b8154815290600101906020018083116101a657829003601f168201915b5050505050815250509050919050565b6000806001600081546101e5906105b1565b9190508190559050600060405180608001604052806000801b8152602001856001600160a01b0316815260200183815260200187878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250929350915061025f90508261033c565b6000818152602081905260409020549091501561028f5760405163119b4fd360e11b815260040160405180910390fd5b8082526000818152602081815260409182902084518155818501516001820180546001600160a01b0319166001600160a01b03909216919091179055918401516002830155606084015180518593926102ef926003850192910190610376565b5090505082817f51a1a037ef8a642f8b5528429785b5a54e6ee54fb2d2db4b4a44480b5302d55b8989893360405161032a94939291906105da565b60405180910390a39695505050505050565b600081606001518260200151604051602001610359929190610621565b604051602081830303815290604052805190602001209050919050565b82805461038290610576565b90600052602060002090601f0160209004810192826103a457600085556103ea565b82601f106103bd57805160ff19168380011785556103ea565b828001600101855582156103ea579182015b828111156103ea5782518255916020019190600101906103cf565b506103f69291506103fa565b5090565b5b808211156103f657600081556001016103fb565b60006020828403121561042157600080fd5b5035919050565b60005b8381101561044357818101518382015260200161042b565b83811115610452576000848401525b50505050565b60008151808452610470816020860160208601610428565b601f01601f19169290920160200192915050565b602081528151602082015260018060a01b03602083015116604082015260408201516060820152600060608301516080808401526104c560a0840182610458565b949350505050565b6000806000604084860312156104e257600080fd5b833567ffffffffffffffff808211156104fa57600080fd5b818601915086601f83011261050e57600080fd5b81358181111561051d57600080fd5b87602082850101111561052f57600080fd5b602092830195509350508401356001600160a01b038116811461055157600080fd5b809150509250925092565b60208152600061056f6020830184610458565b9392505050565b600181811c9082168061058a57607f821691505b602082108114156105ab57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156105d357634e487b7160e01b600052601160045260246000fd5b5060010190565b6060815283606082015283856080830137600060808583018101919091526001600160a01b039384166020830152919092166040830152601f909201601f19160101919050565b60008351610633818460208801610428565b60609390931b6bffffffffffffffffffffffff1916919092019081526014019291505056fea2646970667358221220d5a2ae236065d696cf08baaf5b64dfba64bb8bb07876f47a25a1a47906a5074864736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806372487d5214610051578063a99e7e291461007a578063d96250641461009b578063ffa1ad74146100a3575b600080fd5b61006461005f36600461040f565b6100d2565b6040516100719190610484565b60405180910390f35b61008d6100883660046104cd565b6101d3565b604051908152602001610071565b60015461008d565b6100c5604051806040016040528060038152602001620605c760eb1b81525081565b604051610071919061055c565b60408051608081018252600080825260208201819052918101919091526060808201526000828152602081815260409182902082516080810184528154815260018201546001600160a01b03169281019290925260028101549282019290925260038201805491929160608401919061014a90610576565b80601f016020809104026020016040519081016040528092919081815260200182805461017690610576565b80156101c35780601f10610198576101008083540402835291602001916101c3565b820191906000526020600020905b8154815290600101906020018083116101a657829003601f168201915b5050505050815250509050919050565b6000806001600081546101e5906105b1565b9190508190559050600060405180608001604052806000801b8152602001856001600160a01b0316815260200183815260200187878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250929350915061025f90508261033c565b6000818152602081905260409020549091501561028f5760405163119b4fd360e11b815260040160405180910390fd5b8082526000818152602081815260409182902084518155818501516001820180546001600160a01b0319166001600160a01b03909216919091179055918401516002830155606084015180518593926102ef926003850192910190610376565b5090505082817f51a1a037ef8a642f8b5528429785b5a54e6ee54fb2d2db4b4a44480b5302d55b8989893360405161032a94939291906105da565b60405180910390a39695505050505050565b600081606001518260200151604051602001610359929190610621565b604051602081830303815290604052805190602001209050919050565b82805461038290610576565b90600052602060002090601f0160209004810192826103a457600085556103ea565b82601f106103bd57805160ff19168380011785556103ea565b828001600101855582156103ea579182015b828111156103ea5782518255916020019190600101906103cf565b506103f69291506103fa565b5090565b5b808211156103f657600081556001016103fb565b60006020828403121561042157600080fd5b5035919050565b60005b8381101561044357818101518382015260200161042b565b83811115610452576000848401525b50505050565b60008151808452610470816020860160208601610428565b601f01601f19169290920160200192915050565b602081528151602082015260018060a01b03602083015116604082015260408201516060820152600060608301516080808401526104c560a0840182610458565b949350505050565b6000806000604084860312156104e257600080fd5b833567ffffffffffffffff808211156104fa57600080fd5b818601915086601f83011261050e57600080fd5b81358181111561051d57600080fd5b87602082850101111561052f57600080fd5b602092830195509350508401356001600160a01b038116811461055157600080fd5b809150509250925092565b60208152600061056f6020830184610458565b9392505050565b600181811c9082168061058a57607f821691505b602082108114156105ab57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156105d357634e487b7160e01b600052601160045260246000fd5b5060010190565b6060815283606082015283856080830137600060808583018101919091526001600160a01b039384166020830152919092166040830152601f909201601f19160101919050565b60008351610633818460208801610428565b60609390931b6bffffffffffffffffffffffff1916919092019081526014019291505056fea2646970667358221220d5a2ae236065d696cf08baaf5b64dfba64bb8bb07876f47a25a1a47906a5074864736f6c63430008090033", @@ -197,15 +197,15 @@ "storageLayout": { "storage": [ { - "astId": 16832, + "astId": 15207, "contract": "contracts/EAS/TellerASRegistry.sol:TellerASRegistry", "label": "_registry", "offset": 0, "slot": "0", - "type": "t_mapping(t_bytes32,t_struct(ASRecord)24462_storage)" + "type": "t_mapping(t_bytes32,t_struct(ASRecord)23770_storage)" }, { - "astId": 16834, + "astId": 15209, "contract": "contracts/EAS/TellerASRegistry.sol:TellerASRegistry", "label": "_asCount", "offset": 0, @@ -224,24 +224,24 @@ "label": "bytes", "numberOfBytes": "32" }, - "t_contract(IASResolver)24529": { + "t_contract(IASResolver)23837": { "encoding": "inplace", "label": "contract IASResolver", "numberOfBytes": "20" }, - "t_mapping(t_bytes32,t_struct(ASRecord)24462_storage)": { + "t_mapping(t_bytes32,t_struct(ASRecord)23770_storage)": { "encoding": "mapping", "key": "t_bytes32", "label": "mapping(bytes32 => struct IASRegistry.ASRecord)", "numberOfBytes": "32", - "value": "t_struct(ASRecord)24462_storage" + "value": "t_struct(ASRecord)23770_storage" }, - "t_struct(ASRecord)24462_storage": { + "t_struct(ASRecord)23770_storage": { "encoding": "inplace", "label": "struct IASRegistry.ASRecord", "members": [ { - "astId": 24454, + "astId": 23762, "contract": "contracts/EAS/TellerASRegistry.sol:TellerASRegistry", "label": "uuid", "offset": 0, @@ -249,15 +249,15 @@ "type": "t_bytes32" }, { - "astId": 24457, + "astId": 23765, "contract": "contracts/EAS/TellerASRegistry.sol:TellerASRegistry", "label": "resolver", "offset": 0, "slot": "1", - "type": "t_contract(IASResolver)24529" + "type": "t_contract(IASResolver)23837" }, { - "astId": 24459, + "astId": 23767, "contract": "contracts/EAS/TellerASRegistry.sol:TellerASRegistry", "label": "index", "offset": 0, @@ -265,7 +265,7 @@ "type": "t_uint256" }, { - "astId": 24461, + "astId": 23769, "contract": "contracts/EAS/TellerASRegistry.sol:TellerASRegistry", "label": "schema", "offset": 0, diff --git a/packages/contracts/deployments/goerli/TellerV2.json b/packages/contracts/deployments/goerli/TellerV2.json index 4a1f7c793..dba00d71e 100644 --- a/packages/contracts/deployments/goerli/TellerV2.json +++ b/packages/contracts/deployments/goerli/TellerV2.json @@ -1,5 +1,5 @@ { - "address": "0x195c6608705546725DF0629dd60690Cf2b367734", + "address": "0x3a8C417a743A60ECfF3988C34783D65362b62915", "abi": [ { "anonymous": false, @@ -1835,59 +1835,59 @@ "type": "constructor" } ], - "transactionHash": "0xd41be29c0f527a0634980e9213d5f3aed9933a3ea7f9d1a228126bb9c88ce247", + "transactionHash": "0xdf1feb299ed55e26ff48be18210ad2466797877462fc58cf754ca4836b4321d8", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x195c6608705546725DF0629dd60690Cf2b367734", - "transactionIndex": 2, - "gasUsed": "720430", - "logsBloom": "0x00000000000000000000000000000000400000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000080000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000010000000000000000000000000000020000000020000000000000000000008000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc20069c2a1a975c8617087e9007fedc7776971dd561b25fa1f583cee1dd70b02", - "transactionHash": "0xd41be29c0f527a0634980e9213d5f3aed9933a3ea7f9d1a228126bb9c88ce247", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x3a8C417a743A60ECfF3988C34783D65362b62915", + "transactionIndex": 11, + "gasUsed": "720722", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000002000000000000000000000000000000200000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000010000000000000000000000000000000000000000000820000000000040000000000000000000000400000000000000000000000000010000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xfc8618a13778c40afe3c1a511bccda6b52f71eede2f1b8488c3c45f1155a84ee", + "transactionHash": "0xdf1feb299ed55e26ff48be18210ad2466797877462fc58cf754ca4836b4321d8", "logs": [ { - "transactionIndex": 2, - "blockNumber": 8538452, - "transactionHash": "0xd41be29c0f527a0634980e9213d5f3aed9933a3ea7f9d1a228126bb9c88ce247", - "address": "0x195c6608705546725DF0629dd60690Cf2b367734", + "transactionIndex": 11, + "blockNumber": 8688915, + "transactionHash": "0xdf1feb299ed55e26ff48be18210ad2466797877462fc58cf754ca4836b4321d8", + "address": "0x3a8C417a743A60ECfF3988C34783D65362b62915", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000d6c3196e29ba5a267ca242e4c2b16cb65361c1f2" + "0x000000000000000000000000f67b9f261853393d2791d151159d3e2c575c1574" ], "data": "0x", "logIndex": 0, - "blockHash": "0xc20069c2a1a975c8617087e9007fedc7776971dd561b25fa1f583cee1dd70b02" + "blockHash": "0xfc8618a13778c40afe3c1a511bccda6b52f71eede2f1b8488c3c45f1155a84ee" }, { - "transactionIndex": 2, - "blockNumber": 8538452, - "transactionHash": "0xd41be29c0f527a0634980e9213d5f3aed9933a3ea7f9d1a228126bb9c88ce247", - "address": "0x195c6608705546725DF0629dd60690Cf2b367734", + "transactionIndex": 11, + "blockNumber": 8688915, + "transactionHash": "0xdf1feb299ed55e26ff48be18210ad2466797877462fc58cf754ca4836b4321d8", + "address": "0x3a8C417a743A60ECfF3988C34783D65362b62915", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 1, - "blockHash": "0xc20069c2a1a975c8617087e9007fedc7776971dd561b25fa1f583cee1dd70b02" + "blockHash": "0xfc8618a13778c40afe3c1a511bccda6b52f71eede2f1b8488c3c45f1155a84ee" } ], - "blockNumber": 8538452, - "cumulativeGasUsed": "762430", + "blockNumber": 8688915, + "cumulativeGasUsed": "951722", "status": 1, "byzantium": true }, "args": [ - "0xd6C3196E29ba5a267CA242E4C2B16cb65361c1f2", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0xf67B9F261853393d2791d151159D3e2C575C1574", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x" ], - "numDeployments": 3, + "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", "metadata": "{\"compiler\":{\"version\":\"0.8.10+commit.fc410830\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.8/openzeppelin/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x93b4e21c931252739a1ec13ea31d3d35a5c068be3163ccab83e4d70c40355f03\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0x6309f9f39dc6f4f45a24f296543867aa358e32946cd6b2874627a996d606b3a0\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view virtual returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(Address.isContract(IBeacon(newBeacon).implementation()), \\\"ERC1967: beacon implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x17668652127feebed0ce8d9431ef95ccc8c4292f03e3b8cf06c6ca16af396633\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xd5d1fd16e9faff7fcb3a52e02a8d49156f42a38a03f07b5f1810c21c2149a8ab\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x140055a64cf579d622e04f5a198595832bf2cb193cd0005f4f2d4d61ca906253\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0-rc.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3777e696b62134e6177440dbe6e6601c0c156a443f57167194b67e75527439de\",\"license\":\"MIT\"},\"solc_0.8/openzeppelin/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe1b7a9aa2a530a9e705b220e26cd584e2fbdc9602a3a1066032b12816b46aca\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x6080604052604051620011b2380380620011b2833981016040819052620000269162000519565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd620005f9565b6000805160206200116b833981519152146200007557620000756200061f565b6200008382826000620000e7565b50620000b3905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005f9565b6000805160206200114b83398151915214620000d357620000d36200061f565b620000de8262000124565b50505062000688565b620000f2836200017f565b600082511180620001005750805b156200011f576200011d8383620001c160201b620002ff1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200014f620001f0565b604080516001600160a01b03928316815291841660208301520160405180910390a16200017c8162000229565b50565b6200018a81620002de565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060620001e983836040518060600160405280602781526020016200118b6027913962000381565b9392505050565b60006200021a6000805160206200114b83398151915260001b6200046760201b620002731760201c565b546001600160a01b0316919050565b6001600160a01b038116620002945760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002bd6000805160206200114b83398151915260001b6200046760201b620002731760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002f4816200046a60201b6200032b1760201c565b620003585760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016200028b565b80620002bd6000805160206200116b83398151915260001b6200046760201b620002731760201c565b60606001600160a01b0384163b620003eb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016200028b565b600080856001600160a01b03168560405162000408919062000635565b600060405180830381855af49150503d806000811462000445576040519150601f19603f3d011682016040523d82523d6000602084013e6200044a565b606091505b5090925090506200045d82828662000479565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200048a575081620001e9565b8251156200049b5782518084602001fd5b8160405162461bcd60e51b81526004016200028b919062000653565b80516001600160a01b0381168114620004cf57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101562000507578181015183820152602001620004ed565b838111156200011d5750506000910152565b6000806000606084860312156200052f57600080fd5b6200053a84620004b7565b92506200054a60208501620004b7565b60408501519092506001600160401b03808211156200056857600080fd5b818601915086601f8301126200057d57600080fd5b815181811115620005925762000592620004d4565b604051601f8201601f19908116603f01168101908382118183101715620005bd57620005bd620004d4565b81604052828152896020848701011115620005d757600080fd5b620005ea836020830160208801620004ea565b80955050505050509250925092565b6000828210156200061a57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052600160045260246000fd5b6000825162000649818460208701620004ea565b9190910192915050565b602081526000825180602084015262000674816040850160208701620004ea565b601f01601f19169190910160400192915050565b610ab380620006986000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461091f565b610135565b61006b6100a336600461093a565b610196565b3480156100b457600080fd5b506100bd610221565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461091f565b610276565b34801561011257600080fd5b506100bd6102ba565b610123610347565b61013361012e610435565b61043f565b565b61013d610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816040518060200160405280600081525060006104a3565b50565b61018b61011b565b61019e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610219576102148383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506104a3915050565b505050565b61021461011b565b600061022b610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610435565b905090565b61027361011b565b90565b61027e610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018e5761018b816104ce565b60006102c4610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561026b57610266610463565b60606103248383604051806060016040528060278152602001610a576027913961052f565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61034f610463565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b6000610266610657565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6104ac8361067f565b6000825111806104b95750805b15610214576104c883836102ff565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6104f7610463565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161018b816106cc565b606073ffffffffffffffffffffffffffffffffffffffff84163b6105d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161042c565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105fd91906109e9565b600060405180830381855af49150503d8060008114610638576040519150601f19603f3d011682016040523d82523d6000602084013e61063d565b606091505b509150915061064d8282866107d8565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610487565b6106888161082b565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff811661076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161042c565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b606083156107e7575081610324565b8251156107f75782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042c9190610a05565b73ffffffffffffffffffffffffffffffffffffffff81163b6108cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161042c565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610792565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091a57600080fd5b919050565b60006020828403121561093157600080fd5b610324826108f6565b60008060006040848603121561094f57600080fd5b610958846108f6565b9250602084013567ffffffffffffffff8082111561097557600080fd5b818601915086601f83011261098957600080fd5b81358181111561099857600080fd5b8760208285010111156109aa57600080fd5b6020830194508093505050509250925092565b60005b838110156109d85781810151838201526020016109c0565b838111156104c85750506000910152565b600082516109fb8184602087016109bd565b9190910192915050565b6020815260008251806020840152610a248160408501602087016109bd565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b29caa54336b3ee836679675e9732ec5e526fb3f803cca2fe336cc3555aba62264736f6c634300080a0033", - "implementation": "0x2551A099129ad9b0b1FEc16f34D9CB73c237be8b", + "implementation": "0xf67B9F261853393d2791d151159D3e2C575C1574", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/TellerV2Autopay.json b/packages/contracts/deployments/goerli/TellerV2Autopay.json index fbde1ef92..d4a052b86 100644 --- a/packages/contracts/deployments/goerli/TellerV2Autopay.json +++ b/packages/contracts/deployments/goerli/TellerV2Autopay.json @@ -1,5 +1,5 @@ { - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "abi": [ { "anonymous": false, @@ -394,90 +394,90 @@ "type": "constructor" } ], - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", - "transactionIndex": 2, - "gasUsed": "794154", - "logsBloom": "0x000000000000000000000000000080004000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020001010000000000000000000000000000000000000200000000000200000008000000008080000010000000000000004002000000000000000000000000000000000000000000c0000000000000800000000000000000000000000000000400000000000000000000000000400000000000000020000110000000000000044000000000000400000000000000000020010000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1", - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", + "transactionIndex": 9, + "gasUsed": "794440", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000000000000000000000000000000000000010000000000000000000000000000000000000000000000200000002000000002000001800000000040000000000000000000000000020000000000020000000800000000800000001000002000000000400200000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400008000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000001000000000000000000000000000000000010000000000000", + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057", + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", "logs": [ { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000eaba36e88f3060fc9d613fb2bee64837df9cb46e" + "0x0000000000000000000000004590383ae832ebdfb262d750ee81361e690cfc9c" ], "data": "0x", "logIndex": 0, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" }, { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", "logIndex": 1, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" }, { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0x9ea45a732f370dc854e5140c35197eab50d654de8b22b87766b50cc29c7c9cb3" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000", "logIndex": 2, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" }, { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 3, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" }, { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 4, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" } ], - "blockNumber": 8538507, - "cumulativeGasUsed": "836154", + "blockNumber": 8689047, + "cumulativeGasUsed": "983440", "status": 1, "byzantium": true }, "args": [ - "0xeABA36E88f3060Fc9d613Fb2beE64837dF9cb46e", - "0x5956c8158bde236d8e3638362ff7555C329A839B", - "0xe0dbcde50000000000000000000000000000000000000000000000000000000000000005000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x4590383ae832eBDFB262d750eE81361E690cFC9c", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0xe0dbcde500000000000000000000000000000000000000000000000000000000000000050000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", @@ -488,10 +488,10 @@ "methodName": "initialize", "args": [ 5, - "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5" + "0x5a5B978142C8F08Dd013901b50892baC49f3b700" ] }, - "implementation": "0xeABA36E88f3060Fc9d613Fb2beE64837dF9cb46e", + "implementation": "0x4590383ae832eBDFB262d750eE81361E690cFC9c", "devdoc": { "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", "kind": "dev", diff --git a/packages/contracts/deployments/goerli/TellerV2Autopay_Implementation.json b/packages/contracts/deployments/goerli/TellerV2Autopay_Implementation.json index 24ea02f74..8a925a0a5 100644 --- a/packages/contracts/deployments/goerli/TellerV2Autopay_Implementation.json +++ b/packages/contracts/deployments/goerli/TellerV2Autopay_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0xeABA36E88f3060Fc9d613Fb2beE64837dF9cb46e", + "address": "0x4590383ae832eBDFB262d750eE81361E690cFC9c", "abi": [ { "inputs": [ @@ -261,30 +261,30 @@ "type": "function" } ], - "transactionHash": "0x15217bfc46a4d338954cd50374f4a8ee1b127fd1b8475d21178e984590e3eb8d", + "transactionHash": "0x0d0a639b918da6a9311c7dc9a50058f9507e687e26ed0384e2d9d80ce835621c", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xeABA36E88f3060Fc9d613Fb2beE64837dF9cb46e", - "transactionIndex": 1, - "gasUsed": "967959", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x4590383ae832eBDFB262d750eE81361E690cFC9c", + "transactionIndex": 29, + "gasUsed": "968237", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x9564af2ce9502811b1e23fdd38a8929264b59cf25c24639def977784289dfeae", - "transactionHash": "0x15217bfc46a4d338954cd50374f4a8ee1b127fd1b8475d21178e984590e3eb8d", + "blockHash": "0x6d22d7aa79a55d1a1ac8d77bc9b7495b6a381f1b91d089ccb5a931af5a114212", + "transactionHash": "0x0d0a639b918da6a9311c7dc9a50058f9507e687e26ed0384e2d9d80ce835621c", "logs": [], - "blockNumber": 8538506, - "cumulativeGasUsed": "988959", + "blockNumber": 8689046, + "cumulativeGasUsed": "2401773", "status": 1, "byzantium": true }, "args": [ - "0x195c6608705546725DF0629dd60690Cf2b367734" + "0x3a8C417a743A60ECfF3988C34783D65362b62915" ], "numDeployments": 1, - "solcInputHash": "060a0e06ef3f72cfc1caa979d18de7ca", - "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_protocolAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"msgsender\",\"type\":\"address\"}],\"name\":\"AutoPaidLoanMinimum\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"name\":\"AutoPayEnabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newFee\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"oldFee\",\"type\":\"uint16\"}],\"name\":\"AutopayFeeSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"autoPayLoanMinimum\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAutopayFee\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getEstimatedMinimumPayment\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_fee\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"loanAutoPayEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_autoPayEnabled\",\"type\":\"bool\"}],\"name\":\"setAutoPayEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_newFee\",\"type\":\"uint16\"}],\"name\":\"setAutopayFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tellerV2\",\"outputs\":[{\"internalType\":\"contract ITellerV2\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Helper contract to autopay loans\",\"events\":{\"AutoPaidLoanMinimum(uint256,address)\":{\"params\":{\"bidId\":\"The id of the bid/loan which was repaid.\",\"msgsender\":\"The account that called the method\"}},\"AutoPayEnabled(uint256,bool)\":{\"params\":{\"bidId\":\"The id of the bid/loan.\",\"enabled\":\"Whether the autopayments are enabled or disabled\"}},\"AutopayFeeSet(uint16,uint16)\":{\"params\":{\"newFee\":\"The new autopay fee set.\",\"oldFee\":\"The previously set autopay fee.\"}}},\"kind\":\"dev\",\"methods\":{\"autoPayLoanMinimum(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid to repay.\"}},\"initialize(uint16,address)\":{\"params\":{\"_fee\":\"The fee collected for automatic payment processing.\",\"_owner\":\"The address of the ownership to be transferred to.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"setAutoPayEnabled(uint256,bool)\":{\"params\":{\"_autoPayEnabled\":\"boolean for allowing autopay on a loan\",\"_bidId\":\"The id of the bid to cancel.\"}},\"setAutopayFee(uint16)\":{\"params\":{\"_newFee\":\"The new autopay fee to set.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"events\":{\"AutoPaidLoanMinimum(uint256,address)\":{\"notice\":\"This event is emitted when a loan is autopaid.\"},\"AutoPayEnabled(uint256,bool)\":{\"notice\":\"This event is emitted when loan autopayments are enabled or disabled.\"},\"AutopayFeeSet(uint16,uint16)\":{\"notice\":\"This event is emitted when the autopay fee has been updated.\"}},\"kind\":\"user\",\"methods\":{\"autoPayLoanMinimum(uint256)\":{\"notice\":\"Function for a minimum autopayment to be performed on a loan\"},\"getAutopayFee()\":{\"notice\":\"Returns the current autopay fee.\"},\"initialize(uint16,address)\":{\"notice\":\"Initialized the proxy.\"},\"setAutoPayEnabled(uint256,bool)\":{\"notice\":\"Function for a borrower to enable or disable autopayments\"},\"setAutopayFee(uint16)\":{\"notice\":\"Let the owner of the contract set a new autopay fee.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TellerV2Autopay.sol\":\"TellerV2Autopay\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/TellerV2Autopay.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\nimport \\\"./interfaces/ITellerV2Autopay.sol\\\";\\n\\nimport \\\"./libraries/NumbersLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport { Payment } from \\\"./TellerV2Storage.sol\\\";\\n\\n/**\\n * @dev Helper contract to autopay loans\\n */\\ncontract TellerV2Autopay is OwnableUpgradeable, ITellerV2Autopay {\\n using SafeERC20 for ERC20;\\n using NumbersLib for uint256;\\n\\n ITellerV2 public immutable tellerV2;\\n\\n //bidId => enabled\\n mapping(uint256 => bool) public loanAutoPayEnabled;\\n\\n // Autopay fee set for automatic loan payments\\n uint16 private _autopayFee;\\n\\n /**\\n * @notice This event is emitted when a loan is autopaid.\\n * @param bidId The id of the bid/loan which was repaid.\\n * @param msgsender The account that called the method\\n */\\n event AutoPaidLoanMinimum(uint256 indexed bidId, address indexed msgsender);\\n\\n /**\\n * @notice This event is emitted when loan autopayments are enabled or disabled.\\n * @param bidId The id of the bid/loan.\\n * @param enabled Whether the autopayments are enabled or disabled\\n */\\n event AutoPayEnabled(uint256 indexed bidId, bool enabled);\\n\\n /**\\n * @notice This event is emitted when the autopay fee has been updated.\\n * @param newFee The new autopay fee set.\\n * @param oldFee The previously set autopay fee.\\n */\\n event AutopayFeeSet(uint16 newFee, uint16 oldFee);\\n\\n constructor(address _protocolAddress) {\\n tellerV2 = ITellerV2(_protocolAddress);\\n }\\n\\n /**\\n * @notice Initialized the proxy.\\n * @param _fee The fee collected for automatic payment processing.\\n * @param _owner The address of the ownership to be transferred to.\\n */\\n function initialize(uint16 _fee, address _owner) external initializer {\\n _transferOwnership(_owner);\\n _setAutopayFee(_fee);\\n }\\n\\n /**\\n * @notice Let the owner of the contract set a new autopay fee.\\n * @param _newFee The new autopay fee to set.\\n */\\n function setAutopayFee(uint16 _newFee) public virtual onlyOwner {\\n _setAutopayFee(_newFee);\\n }\\n\\n function _setAutopayFee(uint16 _newFee) internal {\\n // Skip if the fee is the same\\n if (_newFee == _autopayFee) return;\\n uint16 oldFee = _autopayFee;\\n _autopayFee = _newFee;\\n emit AutopayFeeSet(_newFee, oldFee);\\n }\\n\\n /**\\n * @notice Returns the current autopay fee.\\n */\\n function getAutopayFee() public view virtual returns (uint16) {\\n return _autopayFee;\\n }\\n\\n /**\\n * @notice Function for a borrower to enable or disable autopayments\\n * @param _bidId The id of the bid to cancel.\\n * @param _autoPayEnabled boolean for allowing autopay on a loan\\n */\\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external {\\n require(\\n _msgSender() == tellerV2.getLoanBorrower(_bidId),\\n \\\"Only the borrower can set autopay\\\"\\n );\\n\\n loanAutoPayEnabled[_bidId] = _autoPayEnabled;\\n\\n emit AutoPayEnabled(_bidId, _autoPayEnabled);\\n }\\n\\n /**\\n * @notice Function for a minimum autopayment to be performed on a loan\\n * @param _bidId The id of the bid to repay.\\n */\\n function autoPayLoanMinimum(uint256 _bidId) external {\\n require(\\n loanAutoPayEnabled[_bidId],\\n \\\"Autopay is not enabled for that loan\\\"\\n );\\n\\n address lendingToken = ITellerV2(tellerV2).getLoanLendingToken(_bidId);\\n address borrower = ITellerV2(tellerV2).getLoanBorrower(_bidId);\\n\\n uint256 amountToRepayMinimum = getEstimatedMinimumPayment(_bidId);\\n uint256 autopayFeeAmount = amountToRepayMinimum.percent(\\n getAutopayFee()\\n );\\n\\n // Pull lendingToken in from the borrower to this smart contract\\n ERC20(lendingToken).safeTransferFrom(\\n borrower,\\n address(this),\\n amountToRepayMinimum + autopayFeeAmount\\n );\\n\\n // Transfer fee to msg sender\\n ERC20(lendingToken).safeTransfer(_msgSender(), autopayFeeAmount);\\n\\n // Approve the lendingToken to tellerV2\\n ERC20(lendingToken).approve(address(tellerV2), amountToRepayMinimum);\\n\\n // Use that lendingToken to repay the loan\\n tellerV2.repayLoan(_bidId, amountToRepayMinimum);\\n\\n emit AutoPaidLoanMinimum(_bidId, msg.sender);\\n }\\n\\n function getEstimatedMinimumPayment(uint256 _bidId)\\n public\\n virtual\\n returns (uint256 _amount)\\n {\\n Payment memory estimatedPayment = tellerV2.calculateAmountDue(_bidId);\\n\\n _amount = estimatedPayment.principal + estimatedPayment.interest;\\n }\\n}\\n\",\"keccak256\":\"0x56249765577690e76ce89ed51f1cfdc7a906ea38cec6d13eb132a46dd2b3f3f0\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public _lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public _totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal lendingTokensSet;\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x600fd24b7211e1883081b4389fbc715365afe563a56808f904a83235e6efbe2b\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x549d37cb1390adad543f2e7b1ad46104c4326c4af7dbccda35116833103a6465\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x62c61e6811becc51d0d644e54c342279565e9d8ff5a386cde5a784440a404da7\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2Autopay.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface ITellerV2Autopay {\\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external;\\n\\n function autoPayLoanMinimum(uint256 _bidId) external;\\n\\n function initialize(uint16 _newFee, address _newOwner) external;\\n\\n function setAutopayFee(uint16 _newFee) external;\\n}\\n\",\"keccak256\":\"0x375b493547dafd238f26ee323da88ae76fb38643fabc8cc57d9910b2969df21e\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60a060405234801561001057600080fd5b5060405161114038038061114083398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b60805161108b6100b560003960008181610156015281816101e8015281816103b30152818161045901528181610549015281816105f201526106c1015261108b6000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80638e648fbb116100715780638e648fbb1461013b578063941675db14610151578063a90f4b9b14610178578063b0b69ed414610199578063e0dbcde5146101ac578063f2fde38b146101bf57600080fd5b806310a34194146100ae5780631a1a4257146100c35780632fa7b9fd146100fb578063715018a61461010e5780638da5cb5b14610116575b600080fd5b6100c16100bc366004610d0b565b6101d2565b005b6100e66100d1366004610d3b565b60656020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6100c1610109366004610d3b565b610330565b6100c161068a565b6033546001600160a01b03165b6040516001600160a01b0390911681526020016100f2565b60665460405161ffff90911681526020016100f2565b6101237f000000000000000000000000000000000000000000000000000000000000000081565b61018b610186366004610d3b565b61069e565b6040519081526020016100f2565b6100c16101a7366004610d6b565b610754565b6100c16101ba366004610d9b565b610768565b6100c16101cd366004610dc7565b610885565b604051633ef0a2f760e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690633ef0a2f79060240160206040518083038186803b15801561023257600080fd5b505afa158015610246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026a9190610de4565b6001600160a01b0316336001600160a01b0316146102d95760405162461bcd60e51b815260206004820152602160248201527f4f6e6c792074686520626f72726f7765722063616e20736574206175746f70616044820152607960f81b60648201526084015b60405180910390fd5b600082815260656020908152604091829020805460ff1916841515908117909155915191825283917fd5509862e358cd409ee88c54179adfea59890ed720d2e0b2b4bfec845cb7e23e910160405180910390a25050565b60008181526065602052604090205460ff1661039a5760405162461bcd60e51b8152602060048201526024808201527f4175746f706179206973206e6f7420656e61626c656420666f722074686174206044820152633637b0b760e11b60648201526084016102d0565b604051631457303360e01b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063145730339060240160206040518083038186803b1580156103fd57600080fd5b505afa158015610411573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104359190610de4565b604051633ef0a2f760e01b8152600481018490529091506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633ef0a2f79060240160206040518083038186803b15801561049b57600080fd5b505afa1580156104af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d39190610de4565b905060006104e08461069e565b905060006104fb6104f460665461ffff1690565b83906108fb565b905061051e833061050c8486610e17565b6001600160a01b038816929190610916565b6105326001600160a01b0385163383610987565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820184905285169063095ea7b390604401602060405180830381600087803b15801561059c57600080fd5b505af11580156105b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d49190610e2f565b50604051638a700b5360e01b815260048101869052602481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638a700b5390604401600060405180830381600087803b15801561063e57600080fd5b505af1158015610652573d6000803e3d6000fd5b50506040513392508791507f19795cc98ca16b7ef5c8da6b881e6d974b70b5ac32e61432bae368f9511229aa90600090a35050505050565b6106926109b7565b61069c6000610a11565b565b60405163d974cc5760e01b81526004810182905260009081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d974cc5790602401604080518083038186803b15801561070257600080fd5b505afa158015610716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073a9190610e4c565b6020810151815191925061074d91610e17565b9392505050565b61075c6109b7565b61076581610a63565b50565b600054610100900460ff16158080156107885750600054600160ff909116105b806107a25750303b1580156107a2575060005460ff166001145b6108055760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016102d0565b6000805460ff191660011790558015610828576000805461ff0019166101001790555b61083182610a11565b61083a83610a63565b8015610880576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b61088d6109b7565b6001600160a01b0381166108f25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102d0565b61076581610a11565b600061090d838361ffff166002610acc565b90505b92915050565b6040516001600160a01b03808516602483015283166044820152606481018290526109819085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610af3565b50505050565b6040516001600160a01b03831660248201526044810182905261088090849063a9059cbb60e01b9060640161094a565b6033546001600160a01b0316331461069c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d0565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60665461ffff82811691161415610a775750565b6066805461ffff83811661ffff198316811790935560408051938452911660208301819052917f9ea45a732f370dc854e5140c35197eab50d654de8b22b87766b50cc29c7c9cb3910160405180910390a15050565b6000610ad782610bc5565b610ae18486610ea9565b610aeb9190610ec8565b949350505050565b6000610b48826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610bdd9092919063ffffffff16565b8051909150156108805780806020019051810190610b669190610e2f565b6108805760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102d0565b6000610bd282600a610fce565b610910906064610ea9565b6060610aeb848460008585600080866001600160a01b03168587604051610c049190611006565b60006040518083038185875af1925050503d8060008114610c41576040519150601f19603f3d011682016040523d82523d6000602084013e610c46565b606091505b5091509150610c5787838387610c62565b979650505050505050565b60608315610cce578251610cc7576001600160a01b0385163b610cc75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102d0565b5081610aeb565b610aeb8383815115610ce35781518083602001fd5b8060405162461bcd60e51b81526004016102d09190611022565b801515811461076557600080fd5b60008060408385031215610d1e57600080fd5b823591506020830135610d3081610cfd565b809150509250929050565b600060208284031215610d4d57600080fd5b5035919050565b803561ffff81168114610d6657600080fd5b919050565b600060208284031215610d7d57600080fd5b61090d82610d54565b6001600160a01b038116811461076557600080fd5b60008060408385031215610dae57600080fd5b610db783610d54565b91506020830135610d3081610d86565b600060208284031215610dd957600080fd5b813561074d81610d86565b600060208284031215610df657600080fd5b815161074d81610d86565b634e487b7160e01b600052601160045260246000fd5b60008219821115610e2a57610e2a610e01565b500190565b600060208284031215610e4157600080fd5b815161074d81610cfd565b600060408284031215610e5e57600080fd5b6040516040810181811067ffffffffffffffff82111715610e8f57634e487b7160e01b600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b6000816000190483118215151615610ec357610ec3610e01565b500290565b600082610ee557634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115610f25578160001904821115610f0b57610f0b610e01565b80851615610f1857918102915b93841c9390800290610eef565b509250929050565b600082610f3c57506001610910565b81610f4957506000610910565b8160018114610f5f5760028114610f6957610f85565b6001915050610910565b60ff841115610f7a57610f7a610e01565b50506001821b610910565b5060208310610133831016604e8410600b8410161715610fa8575081810a610910565b610fb28383610eea565b8060001904821115610fc657610fc6610e01565b029392505050565b600061090d8383610f2d565b60005b83811015610ff5578181015183820152602001610fdd565b838111156109815750506000910152565b60008251611018818460208701610fda565b9190910192915050565b6020815260008251806020840152611041816040850160208701610fda565b601f01601f1916919091016040019291505056fea2646970667358221220cd85b1ba28dedb90dcf4e015799879a2cde37490aa4dd413c17d3ac8d2e048cf64736f6c63430008090033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80638e648fbb116100715780638e648fbb1461013b578063941675db14610151578063a90f4b9b14610178578063b0b69ed414610199578063e0dbcde5146101ac578063f2fde38b146101bf57600080fd5b806310a34194146100ae5780631a1a4257146100c35780632fa7b9fd146100fb578063715018a61461010e5780638da5cb5b14610116575b600080fd5b6100c16100bc366004610d0b565b6101d2565b005b6100e66100d1366004610d3b565b60656020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6100c1610109366004610d3b565b610330565b6100c161068a565b6033546001600160a01b03165b6040516001600160a01b0390911681526020016100f2565b60665460405161ffff90911681526020016100f2565b6101237f000000000000000000000000000000000000000000000000000000000000000081565b61018b610186366004610d3b565b61069e565b6040519081526020016100f2565b6100c16101a7366004610d6b565b610754565b6100c16101ba366004610d9b565b610768565b6100c16101cd366004610dc7565b610885565b604051633ef0a2f760e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690633ef0a2f79060240160206040518083038186803b15801561023257600080fd5b505afa158015610246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026a9190610de4565b6001600160a01b0316336001600160a01b0316146102d95760405162461bcd60e51b815260206004820152602160248201527f4f6e6c792074686520626f72726f7765722063616e20736574206175746f70616044820152607960f81b60648201526084015b60405180910390fd5b600082815260656020908152604091829020805460ff1916841515908117909155915191825283917fd5509862e358cd409ee88c54179adfea59890ed720d2e0b2b4bfec845cb7e23e910160405180910390a25050565b60008181526065602052604090205460ff1661039a5760405162461bcd60e51b8152602060048201526024808201527f4175746f706179206973206e6f7420656e61626c656420666f722074686174206044820152633637b0b760e11b60648201526084016102d0565b604051631457303360e01b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063145730339060240160206040518083038186803b1580156103fd57600080fd5b505afa158015610411573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104359190610de4565b604051633ef0a2f760e01b8152600481018490529091506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633ef0a2f79060240160206040518083038186803b15801561049b57600080fd5b505afa1580156104af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d39190610de4565b905060006104e08461069e565b905060006104fb6104f460665461ffff1690565b83906108fb565b905061051e833061050c8486610e17565b6001600160a01b038816929190610916565b6105326001600160a01b0385163383610987565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820184905285169063095ea7b390604401602060405180830381600087803b15801561059c57600080fd5b505af11580156105b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d49190610e2f565b50604051638a700b5360e01b815260048101869052602481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638a700b5390604401600060405180830381600087803b15801561063e57600080fd5b505af1158015610652573d6000803e3d6000fd5b50506040513392508791507f19795cc98ca16b7ef5c8da6b881e6d974b70b5ac32e61432bae368f9511229aa90600090a35050505050565b6106926109b7565b61069c6000610a11565b565b60405163d974cc5760e01b81526004810182905260009081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d974cc5790602401604080518083038186803b15801561070257600080fd5b505afa158015610716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073a9190610e4c565b6020810151815191925061074d91610e17565b9392505050565b61075c6109b7565b61076581610a63565b50565b600054610100900460ff16158080156107885750600054600160ff909116105b806107a25750303b1580156107a2575060005460ff166001145b6108055760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016102d0565b6000805460ff191660011790558015610828576000805461ff0019166101001790555b61083182610a11565b61083a83610a63565b8015610880576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b61088d6109b7565b6001600160a01b0381166108f25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102d0565b61076581610a11565b600061090d838361ffff166002610acc565b90505b92915050565b6040516001600160a01b03808516602483015283166044820152606481018290526109819085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610af3565b50505050565b6040516001600160a01b03831660248201526044810182905261088090849063a9059cbb60e01b9060640161094a565b6033546001600160a01b0316331461069c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d0565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60665461ffff82811691161415610a775750565b6066805461ffff83811661ffff198316811790935560408051938452911660208301819052917f9ea45a732f370dc854e5140c35197eab50d654de8b22b87766b50cc29c7c9cb3910160405180910390a15050565b6000610ad782610bc5565b610ae18486610ea9565b610aeb9190610ec8565b949350505050565b6000610b48826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610bdd9092919063ffffffff16565b8051909150156108805780806020019051810190610b669190610e2f565b6108805760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102d0565b6000610bd282600a610fce565b610910906064610ea9565b6060610aeb848460008585600080866001600160a01b03168587604051610c049190611006565b60006040518083038185875af1925050503d8060008114610c41576040519150601f19603f3d011682016040523d82523d6000602084013e610c46565b606091505b5091509150610c5787838387610c62565b979650505050505050565b60608315610cce578251610cc7576001600160a01b0385163b610cc75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102d0565b5081610aeb565b610aeb8383815115610ce35781518083602001fd5b8060405162461bcd60e51b81526004016102d09190611022565b801515811461076557600080fd5b60008060408385031215610d1e57600080fd5b823591506020830135610d3081610cfd565b809150509250929050565b600060208284031215610d4d57600080fd5b5035919050565b803561ffff81168114610d6657600080fd5b919050565b600060208284031215610d7d57600080fd5b61090d82610d54565b6001600160a01b038116811461076557600080fd5b60008060408385031215610dae57600080fd5b610db783610d54565b91506020830135610d3081610d86565b600060208284031215610dd957600080fd5b813561074d81610d86565b600060208284031215610df657600080fd5b815161074d81610d86565b634e487b7160e01b600052601160045260246000fd5b60008219821115610e2a57610e2a610e01565b500190565b600060208284031215610e4157600080fd5b815161074d81610cfd565b600060408284031215610e5e57600080fd5b6040516040810181811067ffffffffffffffff82111715610e8f57634e487b7160e01b600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b6000816000190483118215151615610ec357610ec3610e01565b500290565b600082610ee557634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115610f25578160001904821115610f0b57610f0b610e01565b80851615610f1857918102915b93841c9390800290610eef565b509250929050565b600082610f3c57506001610910565b81610f4957506000610910565b8160018114610f5f5760028114610f6957610f85565b6001915050610910565b60ff841115610f7a57610f7a610e01565b50506001821b610910565b5060208310610133831016604e8410600b8410161715610fa8575081810a610910565b610fb28383610eea565b8060001904821115610fc657610fc6610e01565b029392505050565b600061090d8383610f2d565b60005b83811015610ff5578181015183820152602001610fdd565b838111156109815750506000910152565b60008251611018818460208701610fda565b9190910192915050565b6020815260008251806020840152611041816040850160208701610fda565b601f01601f1916919091016040019291505056fea2646970667358221220cd85b1ba28dedb90dcf4e015799879a2cde37490aa4dd413c17d3ac8d2e048cf64736f6c63430008090033", + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_protocolAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"msgsender\",\"type\":\"address\"}],\"name\":\"AutoPaidLoanMinimum\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"}],\"name\":\"AutoPayEnabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newFee\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"oldFee\",\"type\":\"uint16\"}],\"name\":\"AutopayFeeSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"autoPayLoanMinimum\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAutopayFee\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getEstimatedMinimumPayment\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_fee\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"loanAutoPayEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_autoPayEnabled\",\"type\":\"bool\"}],\"name\":\"setAutoPayEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_newFee\",\"type\":\"uint16\"}],\"name\":\"setAutopayFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tellerV2\",\"outputs\":[{\"internalType\":\"contract ITellerV2\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Helper contract to autopay loans\",\"events\":{\"AutoPaidLoanMinimum(uint256,address)\":{\"params\":{\"bidId\":\"The id of the bid/loan which was repaid.\",\"msgsender\":\"The account that called the method\"}},\"AutoPayEnabled(uint256,bool)\":{\"params\":{\"bidId\":\"The id of the bid/loan.\",\"enabled\":\"Whether the autopayments are enabled or disabled\"}},\"AutopayFeeSet(uint16,uint16)\":{\"params\":{\"newFee\":\"The new autopay fee set.\",\"oldFee\":\"The previously set autopay fee.\"}}},\"kind\":\"dev\",\"methods\":{\"autoPayLoanMinimum(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid to repay.\"}},\"initialize(uint16,address)\":{\"params\":{\"_fee\":\"The fee collected for automatic payment processing.\",\"_owner\":\"The address of the ownership to be transferred to.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"setAutoPayEnabled(uint256,bool)\":{\"params\":{\"_autoPayEnabled\":\"boolean for allowing autopay on a loan\",\"_bidId\":\"The id of the bid to cancel.\"}},\"setAutopayFee(uint16)\":{\"params\":{\"_newFee\":\"The new autopay fee to set.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"events\":{\"AutoPaidLoanMinimum(uint256,address)\":{\"notice\":\"This event is emitted when a loan is autopaid.\"},\"AutoPayEnabled(uint256,bool)\":{\"notice\":\"This event is emitted when loan autopayments are enabled or disabled.\"},\"AutopayFeeSet(uint16,uint16)\":{\"notice\":\"This event is emitted when the autopay fee has been updated.\"}},\"kind\":\"user\",\"methods\":{\"autoPayLoanMinimum(uint256)\":{\"notice\":\"Function for a minimum autopayment to be performed on a loan\"},\"getAutopayFee()\":{\"notice\":\"Returns the current autopay fee.\"},\"initialize(uint16,address)\":{\"notice\":\"Initialized the proxy.\"},\"setAutoPayEnabled(uint256,bool)\":{\"notice\":\"Function for a borrower to enable or disable autopayments\"},\"setAutopayFee(uint16)\":{\"notice\":\"Let the owner of the contract set a new autopay fee.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TellerV2Autopay.sol\":\"TellerV2Autopay\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/TellerV2Autopay.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\nimport \\\"./interfaces/ITellerV2Autopay.sol\\\";\\n\\nimport \\\"./libraries/NumbersLib.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport { Payment } from \\\"./TellerV2Storage.sol\\\";\\n\\n/**\\n * @dev Helper contract to autopay loans\\n */\\ncontract TellerV2Autopay is OwnableUpgradeable, ITellerV2Autopay {\\n using SafeERC20 for ERC20;\\n using NumbersLib for uint256;\\n\\n ITellerV2 public immutable tellerV2;\\n\\n //bidId => enabled\\n mapping(uint256 => bool) public loanAutoPayEnabled;\\n\\n // Autopay fee set for automatic loan payments\\n uint16 private _autopayFee;\\n\\n /**\\n * @notice This event is emitted when a loan is autopaid.\\n * @param bidId The id of the bid/loan which was repaid.\\n * @param msgsender The account that called the method\\n */\\n event AutoPaidLoanMinimum(uint256 indexed bidId, address indexed msgsender);\\n\\n /**\\n * @notice This event is emitted when loan autopayments are enabled or disabled.\\n * @param bidId The id of the bid/loan.\\n * @param enabled Whether the autopayments are enabled or disabled\\n */\\n event AutoPayEnabled(uint256 indexed bidId, bool enabled);\\n\\n /**\\n * @notice This event is emitted when the autopay fee has been updated.\\n * @param newFee The new autopay fee set.\\n * @param oldFee The previously set autopay fee.\\n */\\n event AutopayFeeSet(uint16 newFee, uint16 oldFee);\\n\\n constructor(address _protocolAddress) {\\n tellerV2 = ITellerV2(_protocolAddress);\\n }\\n\\n /**\\n * @notice Initialized the proxy.\\n * @param _fee The fee collected for automatic payment processing.\\n * @param _owner The address of the ownership to be transferred to.\\n */\\n function initialize(uint16 _fee, address _owner) external initializer {\\n _transferOwnership(_owner);\\n _setAutopayFee(_fee);\\n }\\n\\n /**\\n * @notice Let the owner of the contract set a new autopay fee.\\n * @param _newFee The new autopay fee to set.\\n */\\n function setAutopayFee(uint16 _newFee) public virtual onlyOwner {\\n _setAutopayFee(_newFee);\\n }\\n\\n function _setAutopayFee(uint16 _newFee) internal {\\n // Skip if the fee is the same\\n if (_newFee == _autopayFee) return;\\n uint16 oldFee = _autopayFee;\\n _autopayFee = _newFee;\\n emit AutopayFeeSet(_newFee, oldFee);\\n }\\n\\n /**\\n * @notice Returns the current autopay fee.\\n */\\n function getAutopayFee() public view virtual returns (uint16) {\\n return _autopayFee;\\n }\\n\\n /**\\n * @notice Function for a borrower to enable or disable autopayments\\n * @param _bidId The id of the bid to cancel.\\n * @param _autoPayEnabled boolean for allowing autopay on a loan\\n */\\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external {\\n require(\\n _msgSender() == tellerV2.getLoanBorrower(_bidId),\\n \\\"Only the borrower can set autopay\\\"\\n );\\n\\n loanAutoPayEnabled[_bidId] = _autoPayEnabled;\\n\\n emit AutoPayEnabled(_bidId, _autoPayEnabled);\\n }\\n\\n /**\\n * @notice Function for a minimum autopayment to be performed on a loan\\n * @param _bidId The id of the bid to repay.\\n */\\n function autoPayLoanMinimum(uint256 _bidId) external {\\n require(\\n loanAutoPayEnabled[_bidId],\\n \\\"Autopay is not enabled for that loan\\\"\\n );\\n\\n address lendingToken = ITellerV2(tellerV2).getLoanLendingToken(_bidId);\\n address borrower = ITellerV2(tellerV2).getLoanBorrower(_bidId);\\n\\n uint256 amountToRepayMinimum = getEstimatedMinimumPayment(_bidId);\\n uint256 autopayFeeAmount = amountToRepayMinimum.percent(\\n getAutopayFee()\\n );\\n\\n // Pull lendingToken in from the borrower to this smart contract\\n ERC20(lendingToken).safeTransferFrom(\\n borrower,\\n address(this),\\n amountToRepayMinimum + autopayFeeAmount\\n );\\n\\n // Transfer fee to msg sender\\n ERC20(lendingToken).safeTransfer(_msgSender(), autopayFeeAmount);\\n\\n // Approve the lendingToken to tellerV2\\n ERC20(lendingToken).approve(address(tellerV2), amountToRepayMinimum);\\n\\n // Use that lendingToken to repay the loan\\n tellerV2.repayLoan(_bidId, amountToRepayMinimum);\\n\\n emit AutoPaidLoanMinimum(_bidId, msg.sender);\\n }\\n\\n function getEstimatedMinimumPayment(uint256 _bidId)\\n public\\n virtual\\n returns (uint256 _amount)\\n {\\n Payment memory estimatedPayment = tellerV2.calculateAmountDue(_bidId);\\n\\n _amount = estimatedPayment.principal + estimatedPayment.interest;\\n }\\n}\\n\",\"keccak256\":\"0x56249765577690e76ce89ed51f1cfdc7a906ea38cec6d13eb132a46dd2b3f3f0\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\\n external\\n view\\n returns (uint256 _amount);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x27778a3446cdbfed6356d5047f9926231261b37def2712a3cc63e3779350e5e4\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanLiquidateable(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n\\n function getLoanSummary(uint256 _bidId)\\n external\\n view\\n returns (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n );\\n}\\n\",\"keccak256\":\"0x2750d9717451e34323ef523810ff2a3a6285f146009955220d3860a7c4326077\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2Autopay.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\ninterface ITellerV2Autopay {\\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external;\\n\\n function autoPayLoanMinimum(uint256 _bidId) external;\\n\\n function initialize(uint16 _newFee, address _newOwner) external;\\n\\n function setAutopayFee(uint16 _newFee) external;\\n}\\n\",\"keccak256\":\"0x375b493547dafd238f26ee323da88ae76fb38643fabc8cc57d9910b2969df21e\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405234801561001057600080fd5b5060405161114038038061114083398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b60805161108b6100b560003960008181610156015281816101e8015281816103b30152818161045901528181610549015281816105f201526106c1015261108b6000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80638e648fbb116100715780638e648fbb1461013b578063941675db14610151578063a90f4b9b14610178578063b0b69ed414610199578063e0dbcde5146101ac578063f2fde38b146101bf57600080fd5b806310a34194146100ae5780631a1a4257146100c35780632fa7b9fd146100fb578063715018a61461010e5780638da5cb5b14610116575b600080fd5b6100c16100bc366004610d0b565b6101d2565b005b6100e66100d1366004610d3b565b60656020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6100c1610109366004610d3b565b610330565b6100c161068a565b6033546001600160a01b03165b6040516001600160a01b0390911681526020016100f2565b60665460405161ffff90911681526020016100f2565b6101237f000000000000000000000000000000000000000000000000000000000000000081565b61018b610186366004610d3b565b61069e565b6040519081526020016100f2565b6100c16101a7366004610d6b565b610754565b6100c16101ba366004610d9b565b610768565b6100c16101cd366004610dc7565b610885565b604051633ef0a2f760e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690633ef0a2f79060240160206040518083038186803b15801561023257600080fd5b505afa158015610246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026a9190610de4565b6001600160a01b0316336001600160a01b0316146102d95760405162461bcd60e51b815260206004820152602160248201527f4f6e6c792074686520626f72726f7765722063616e20736574206175746f70616044820152607960f81b60648201526084015b60405180910390fd5b600082815260656020908152604091829020805460ff1916841515908117909155915191825283917fd5509862e358cd409ee88c54179adfea59890ed720d2e0b2b4bfec845cb7e23e910160405180910390a25050565b60008181526065602052604090205460ff1661039a5760405162461bcd60e51b8152602060048201526024808201527f4175746f706179206973206e6f7420656e61626c656420666f722074686174206044820152633637b0b760e11b60648201526084016102d0565b604051631457303360e01b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063145730339060240160206040518083038186803b1580156103fd57600080fd5b505afa158015610411573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104359190610de4565b604051633ef0a2f760e01b8152600481018490529091506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633ef0a2f79060240160206040518083038186803b15801561049b57600080fd5b505afa1580156104af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d39190610de4565b905060006104e08461069e565b905060006104fb6104f460665461ffff1690565b83906108fb565b905061051e833061050c8486610e17565b6001600160a01b038816929190610916565b6105326001600160a01b0385163383610987565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820184905285169063095ea7b390604401602060405180830381600087803b15801561059c57600080fd5b505af11580156105b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d49190610e2f565b50604051638a700b5360e01b815260048101869052602481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638a700b5390604401600060405180830381600087803b15801561063e57600080fd5b505af1158015610652573d6000803e3d6000fd5b50506040513392508791507f19795cc98ca16b7ef5c8da6b881e6d974b70b5ac32e61432bae368f9511229aa90600090a35050505050565b6106926109b7565b61069c6000610a11565b565b60405163d974cc5760e01b81526004810182905260009081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d974cc5790602401604080518083038186803b15801561070257600080fd5b505afa158015610716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073a9190610e4c565b6020810151815191925061074d91610e17565b9392505050565b61075c6109b7565b61076581610a63565b50565b600054610100900460ff16158080156107885750600054600160ff909116105b806107a25750303b1580156107a2575060005460ff166001145b6108055760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016102d0565b6000805460ff191660011790558015610828576000805461ff0019166101001790555b61083182610a11565b61083a83610a63565b8015610880576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b61088d6109b7565b6001600160a01b0381166108f25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102d0565b61076581610a11565b600061090d838361ffff166002610acc565b90505b92915050565b6040516001600160a01b03808516602483015283166044820152606481018290526109819085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610af3565b50505050565b6040516001600160a01b03831660248201526044810182905261088090849063a9059cbb60e01b9060640161094a565b6033546001600160a01b0316331461069c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d0565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60665461ffff82811691161415610a775750565b6066805461ffff83811661ffff198316811790935560408051938452911660208301819052917f9ea45a732f370dc854e5140c35197eab50d654de8b22b87766b50cc29c7c9cb3910160405180910390a15050565b6000610ad782610bc5565b610ae18486610ea9565b610aeb9190610ec8565b949350505050565b6000610b48826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610bdd9092919063ffffffff16565b8051909150156108805780806020019051810190610b669190610e2f565b6108805760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102d0565b6000610bd282600a610fce565b610910906064610ea9565b6060610aeb848460008585600080866001600160a01b03168587604051610c049190611006565b60006040518083038185875af1925050503d8060008114610c41576040519150601f19603f3d011682016040523d82523d6000602084013e610c46565b606091505b5091509150610c5787838387610c62565b979650505050505050565b60608315610cce578251610cc7576001600160a01b0385163b610cc75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102d0565b5081610aeb565b610aeb8383815115610ce35781518083602001fd5b8060405162461bcd60e51b81526004016102d09190611022565b801515811461076557600080fd5b60008060408385031215610d1e57600080fd5b823591506020830135610d3081610cfd565b809150509250929050565b600060208284031215610d4d57600080fd5b5035919050565b803561ffff81168114610d6657600080fd5b919050565b600060208284031215610d7d57600080fd5b61090d82610d54565b6001600160a01b038116811461076557600080fd5b60008060408385031215610dae57600080fd5b610db783610d54565b91506020830135610d3081610d86565b600060208284031215610dd957600080fd5b813561074d81610d86565b600060208284031215610df657600080fd5b815161074d81610d86565b634e487b7160e01b600052601160045260246000fd5b60008219821115610e2a57610e2a610e01565b500190565b600060208284031215610e4157600080fd5b815161074d81610cfd565b600060408284031215610e5e57600080fd5b6040516040810181811067ffffffffffffffff82111715610e8f57634e487b7160e01b600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b6000816000190483118215151615610ec357610ec3610e01565b500290565b600082610ee557634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115610f25578160001904821115610f0b57610f0b610e01565b80851615610f1857918102915b93841c9390800290610eef565b509250929050565b600082610f3c57506001610910565b81610f4957506000610910565b8160018114610f5f5760028114610f6957610f85565b6001915050610910565b60ff841115610f7a57610f7a610e01565b50506001821b610910565b5060208310610133831016604e8410600b8410161715610fa8575081810a610910565b610fb28383610eea565b8060001904821115610fc657610fc6610e01565b029392505050565b600061090d8383610f2d565b60005b83811015610ff5578181015183820152602001610fdd565b838111156109815750506000910152565b60008251611018818460208701610fda565b9190910192915050565b6020815260008251806020840152611041816040850160208701610fda565b601f01601f1916919091016040019291505056fea2646970667358221220e619962edb780f03f6133934ecac38e1785466bcc2bea93675d07e72641aad3064736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80638e648fbb116100715780638e648fbb1461013b578063941675db14610151578063a90f4b9b14610178578063b0b69ed414610199578063e0dbcde5146101ac578063f2fde38b146101bf57600080fd5b806310a34194146100ae5780631a1a4257146100c35780632fa7b9fd146100fb578063715018a61461010e5780638da5cb5b14610116575b600080fd5b6100c16100bc366004610d0b565b6101d2565b005b6100e66100d1366004610d3b565b60656020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6100c1610109366004610d3b565b610330565b6100c161068a565b6033546001600160a01b03165b6040516001600160a01b0390911681526020016100f2565b60665460405161ffff90911681526020016100f2565b6101237f000000000000000000000000000000000000000000000000000000000000000081565b61018b610186366004610d3b565b61069e565b6040519081526020016100f2565b6100c16101a7366004610d6b565b610754565b6100c16101ba366004610d9b565b610768565b6100c16101cd366004610dc7565b610885565b604051633ef0a2f760e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690633ef0a2f79060240160206040518083038186803b15801561023257600080fd5b505afa158015610246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026a9190610de4565b6001600160a01b0316336001600160a01b0316146102d95760405162461bcd60e51b815260206004820152602160248201527f4f6e6c792074686520626f72726f7765722063616e20736574206175746f70616044820152607960f81b60648201526084015b60405180910390fd5b600082815260656020908152604091829020805460ff1916841515908117909155915191825283917fd5509862e358cd409ee88c54179adfea59890ed720d2e0b2b4bfec845cb7e23e910160405180910390a25050565b60008181526065602052604090205460ff1661039a5760405162461bcd60e51b8152602060048201526024808201527f4175746f706179206973206e6f7420656e61626c656420666f722074686174206044820152633637b0b760e11b60648201526084016102d0565b604051631457303360e01b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063145730339060240160206040518083038186803b1580156103fd57600080fd5b505afa158015610411573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104359190610de4565b604051633ef0a2f760e01b8152600481018490529091506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633ef0a2f79060240160206040518083038186803b15801561049b57600080fd5b505afa1580156104af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d39190610de4565b905060006104e08461069e565b905060006104fb6104f460665461ffff1690565b83906108fb565b905061051e833061050c8486610e17565b6001600160a01b038816929190610916565b6105326001600160a01b0385163383610987565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820184905285169063095ea7b390604401602060405180830381600087803b15801561059c57600080fd5b505af11580156105b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d49190610e2f565b50604051638a700b5360e01b815260048101869052602481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638a700b5390604401600060405180830381600087803b15801561063e57600080fd5b505af1158015610652573d6000803e3d6000fd5b50506040513392508791507f19795cc98ca16b7ef5c8da6b881e6d974b70b5ac32e61432bae368f9511229aa90600090a35050505050565b6106926109b7565b61069c6000610a11565b565b60405163d974cc5760e01b81526004810182905260009081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d974cc5790602401604080518083038186803b15801561070257600080fd5b505afa158015610716573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073a9190610e4c565b6020810151815191925061074d91610e17565b9392505050565b61075c6109b7565b61076581610a63565b50565b600054610100900460ff16158080156107885750600054600160ff909116105b806107a25750303b1580156107a2575060005460ff166001145b6108055760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016102d0565b6000805460ff191660011790558015610828576000805461ff0019166101001790555b61083182610a11565b61083a83610a63565b8015610880576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b61088d6109b7565b6001600160a01b0381166108f25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102d0565b61076581610a11565b600061090d838361ffff166002610acc565b90505b92915050565b6040516001600160a01b03808516602483015283166044820152606481018290526109819085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610af3565b50505050565b6040516001600160a01b03831660248201526044810182905261088090849063a9059cbb60e01b9060640161094a565b6033546001600160a01b0316331461069c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d0565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60665461ffff82811691161415610a775750565b6066805461ffff83811661ffff198316811790935560408051938452911660208301819052917f9ea45a732f370dc854e5140c35197eab50d654de8b22b87766b50cc29c7c9cb3910160405180910390a15050565b6000610ad782610bc5565b610ae18486610ea9565b610aeb9190610ec8565b949350505050565b6000610b48826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610bdd9092919063ffffffff16565b8051909150156108805780806020019051810190610b669190610e2f565b6108805760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102d0565b6000610bd282600a610fce565b610910906064610ea9565b6060610aeb848460008585600080866001600160a01b03168587604051610c049190611006565b60006040518083038185875af1925050503d8060008114610c41576040519150601f19603f3d011682016040523d82523d6000602084013e610c46565b606091505b5091509150610c5787838387610c62565b979650505050505050565b60608315610cce578251610cc7576001600160a01b0385163b610cc75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102d0565b5081610aeb565b610aeb8383815115610ce35781518083602001fd5b8060405162461bcd60e51b81526004016102d09190611022565b801515811461076557600080fd5b60008060408385031215610d1e57600080fd5b823591506020830135610d3081610cfd565b809150509250929050565b600060208284031215610d4d57600080fd5b5035919050565b803561ffff81168114610d6657600080fd5b919050565b600060208284031215610d7d57600080fd5b61090d82610d54565b6001600160a01b038116811461076557600080fd5b60008060408385031215610dae57600080fd5b610db783610d54565b91506020830135610d3081610d86565b600060208284031215610dd957600080fd5b813561074d81610d86565b600060208284031215610df657600080fd5b815161074d81610d86565b634e487b7160e01b600052601160045260246000fd5b60008219821115610e2a57610e2a610e01565b500190565b600060208284031215610e4157600080fd5b815161074d81610cfd565b600060408284031215610e5e57600080fd5b6040516040810181811067ffffffffffffffff82111715610e8f57634e487b7160e01b600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b6000816000190483118215151615610ec357610ec3610e01565b500290565b600082610ee557634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115610f25578160001904821115610f0b57610f0b610e01565b80851615610f1857918102915b93841c9390800290610eef565b509250929050565b600082610f3c57506001610910565b81610f4957506000610910565b8160018114610f5f5760028114610f6957610f85565b6001915050610910565b60ff841115610f7a57610f7a610e01565b50506001821b610910565b5060208310610133831016604e8410600b8410161715610fa8575081810a610910565b610fb28383610eea565b8060001904821115610fc657610fc6610e01565b029392505050565b600061090d8383610f2d565b60005b83811015610ff5578181015183820152602001610fdd565b838111156109815750506000910152565b60008251611018818460208701610fda565b9190910192915050565b6020815260008251806020840152611041816040850160208701610fda565b601f01601f1916919091016040019291505056fea2646970667358221220e619962edb780f03f6133934ecac38e1785466bcc2bea93675d07e72641aad3064736f6c63430008090033", "devdoc": { "details": "Helper contract to autopay loans", "events": { @@ -378,7 +378,7 @@ "storageLayout": { "storage": [ { - "astId": 1625, + "astId": 326, "contract": "contracts/TellerV2Autopay.sol:TellerV2Autopay", "label": "_initialized", "offset": 0, @@ -386,7 +386,7 @@ "type": "t_uint8" }, { - "astId": 1628, + "astId": 329, "contract": "contracts/TellerV2Autopay.sol:TellerV2Autopay", "label": "_initializing", "offset": 1, @@ -394,7 +394,7 @@ "type": "t_bool" }, { - "astId": 3912, + "astId": 2613, "contract": "contracts/TellerV2Autopay.sol:TellerV2Autopay", "label": "__gap", "offset": 0, @@ -402,7 +402,7 @@ "type": "t_array(t_uint256)50_storage" }, { - "astId": 1309, + "astId": 10, "contract": "contracts/TellerV2Autopay.sol:TellerV2Autopay", "label": "_owner", "offset": 0, @@ -410,7 +410,7 @@ "type": "t_address" }, { - "astId": 1429, + "astId": 130, "contract": "contracts/TellerV2Autopay.sol:TellerV2Autopay", "label": "__gap", "offset": 0, @@ -418,7 +418,7 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 19829, + "astId": 22086, "contract": "contracts/TellerV2Autopay.sol:TellerV2Autopay", "label": "loanAutoPayEnabled", "offset": 0, @@ -426,7 +426,7 @@ "type": "t_mapping(t_uint256,t_bool)" }, { - "astId": 19831, + "astId": 22088, "contract": "contracts/TellerV2Autopay.sol:TellerV2Autopay", "label": "_autopayFee", "offset": 0, diff --git a/packages/contracts/deployments/goerli/TellerV2Autopay_Proxy.json b/packages/contracts/deployments/goerli/TellerV2Autopay_Proxy.json index 110f2ddf2..17af65140 100644 --- a/packages/contracts/deployments/goerli/TellerV2Autopay_Proxy.json +++ b/packages/contracts/deployments/goerli/TellerV2Autopay_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "abi": [ { "inputs": [ @@ -146,90 +146,90 @@ "type": "receive" } ], - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", - "transactionIndex": 2, - "gasUsed": "794154", - "logsBloom": "0x000000000000000000000000000080004000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020001010000000000000000000000000000000000000200000000000200000008000000008080000010000000000000004002000000000000000000000000000000000000000000c0000000000000800000000000000000000000000000000400000000000000000000000000400000000000000020000110000000000000044000000000000400000000000000000020010000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1", - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", + "transactionIndex": 9, + "gasUsed": "794440", + "logsBloom": "0x00000000000000000000000000000000400000000000000000800000000000000000000000000000000000000000010000000000000000000000000000000000000000000000200000002000000002000001800000000040000000000000000000000000020000000000020000000800000000800000001000002000000000400200000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400008000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000020000000000000000001000000000000000000000000000000000010000000000000", + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057", + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", "logs": [ { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000eaba36e88f3060fc9d613fb2bee64837df9cb46e" + "0x0000000000000000000000004590383ae832ebdfb262d750ee81361e690cfc9c" ], "data": "0x", "logIndex": 0, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" }, { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x0000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "data": "0x", "logIndex": 1, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" }, { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0x9ea45a732f370dc854e5140c35197eab50d654de8b22b87766b50cc29c7c9cb3" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000", "logIndex": 2, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" }, { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", "logIndex": 3, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" }, { - "transactionIndex": 2, - "blockNumber": 8538507, - "transactionHash": "0x716f68413d58fc0f76dd30ac09702169612f60508fe4671cc785ac980bb8b327", - "address": "0xFe198b163c25844F3d6548fC2aE2DE66af9f36Ff", + "transactionIndex": 9, + "blockNumber": 8689047, + "transactionHash": "0xb91000b2c175933454fee75c149ef0fe4aeaf66cfab4278b51c00f3562fd410d", + "address": "0x62f7849eCEEA8a253b204D3D49592325f96e6929", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 4, - "blockHash": "0xf4f7d1d2ec96758569779d075130a9ec523bde20d1920c65344d95ba970beaa1" + "blockHash": "0xfbc8f21cc758883d638b362edacdc42668568b6d1b7c90a98635ce833e47a057" } ], - "blockNumber": 8538507, - "cumulativeGasUsed": "836154", + "blockNumber": 8689047, + "cumulativeGasUsed": "983440", "status": 1, "byzantium": true }, "args": [ - "0xeABA36E88f3060Fc9d613Fb2beE64837dF9cb46e", - "0x5956c8158bde236d8e3638362ff7555C329A839B", - "0xe0dbcde50000000000000000000000000000000000000000000000000000000000000005000000000000000000000000afe87013dc96ede1e116a288d80fcaa0effe5fe5" + "0x4590383ae832eBDFB262d750eE81361E690cFC9c", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", + "0xe0dbcde500000000000000000000000000000000000000000000000000000000000000050000000000000000000000005a5b978142c8f08dd013901b50892bac49f3b700" ], "numDeployments": 1, "solcInputHash": "0e89febeebc7444140de8e67c9067d2c", diff --git a/packages/contracts/deployments/goerli/TellerV2_Implementation.json b/packages/contracts/deployments/goerli/TellerV2_Implementation.json index 3e49da064..491e77b6b 100644 --- a/packages/contracts/deployments/goerli/TellerV2_Implementation.json +++ b/packages/contracts/deployments/goerli/TellerV2_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0x2551A099129ad9b0b1FEc16f34D9CB73c237be8b", + "address": "0xf67B9F261853393d2791d151159D3e2C575C1574", "abi": [ { "inputs": [ @@ -1702,27 +1702,27 @@ "type": "function" } ], - "transactionHash": "0x1741467199d63d35f0d171dddba99025f9bdd17ac83a96d94680db2edc68ff13", + "transactionHash": "0x0e17e92e4b07bd22a093ab84875a5f3ad73102a50e0f3da038935b4ade29acd5", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x2551A099129ad9b0b1FEc16f34D9CB73c237be8b", - "transactionIndex": 0, + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0xf67B9F261853393d2791d151159D3e2C575C1574", + "transactionIndex": 17, "gasUsed": "5097754", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x34b7167a8e90acb4cd0137c85628f673c1a659744c650a7f8e9692599a43b95d", - "transactionHash": "0x1741467199d63d35f0d171dddba99025f9bdd17ac83a96d94680db2edc68ff13", + "blockHash": "0xe65d42ac364851d70d58cc1c14d65ede831bab56c338cb65e02617b07aa1d124", + "transactionHash": "0x0e17e92e4b07bd22a093ab84875a5f3ad73102a50e0f3da038935b4ade29acd5", "logs": [], - "blockNumber": 8667195, - "cumulativeGasUsed": "5097754", + "blockNumber": 8688914, + "cumulativeGasUsed": "5454754", "status": 1, "byzantium": true }, "args": [ - "0xF39674F4d3878A732Cb4c70b377C013AffB89C1F" + "0x47BEBF31526a6255B23Bd6b83ab8e2c93b85508f" ], - "numDeployments": 3, - "solcInputHash": "704ec39527d925eea3260ddc4e8d1e8a", + "numDeployments": 1, + "solcInputHash": "e0730cda169a6d13b8fda0f782338556", "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"trustedForwarder\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"action\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"ActionNotAllowed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"payment\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minimumOwed\",\"type\":\"uint256\"}],\"name\":\"PaymentNotMinimum\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"}],\"name\":\"AcceptedBid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"CancelledBid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"string\",\"name\":\"feeType\",\"type\":\"string\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeePaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"}],\"name\":\"LoanLiquidated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"LoanRepaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"LoanRepayment\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"forwarder\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"MarketForwarderApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"}],\"name\":\"MarketOwnerCancelledBid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newFee\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"oldFee\",\"type\":\"uint16\"}],\"name\":\"ProtocolFeeSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"bidId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"metadataURI\",\"type\":\"bytes32\"}],\"name\":\"SubmittedBid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"forwarder\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"TrustedMarketForwarderSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"CURRENT_CODE_VERSION\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"LIQUIDATION_DELAY\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"__lenderVolumeFilled\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"__totalVolumeFilled\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_forwarder\",\"type\":\"address\"}],\"name\":\"approveMarketForwarder\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"bidDefaultDuration\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"bidExpirationTime\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bidId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"bidPaymentCycleType\",\"outputs\":[{\"internalType\":\"enum PaymentCycleType\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"bids\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"marketplaceId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"_metadataURI\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"contract ERC20\",\"name\":\"lendingToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"interest\",\"type\":\"uint256\"}],\"internalType\":\"struct Payment\",\"name\":\"totalRepaid\",\"type\":\"tuple\"},{\"internalType\":\"uint32\",\"name\":\"timestamp\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"acceptedTimestamp\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"lastRepaidTimestamp\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"loanDuration\",\"type\":\"uint32\"}],\"internalType\":\"struct LoanDetails\",\"name\":\"loanDetails\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"paymentCycleAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"paymentCycle\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"APR\",\"type\":\"uint16\"}],\"internalType\":\"struct Terms\",\"name\":\"terms\",\"type\":\"tuple\"},{\"internalType\":\"enum BidState\",\"name\":\"state\",\"type\":\"uint8\"},{\"internalType\":\"enum PaymentType\",\"name\":\"paymentType\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"borrowerBids\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_timestamp\",\"type\":\"uint256\"}],\"name\":\"calculateAmountDue\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"interest\",\"type\":\"uint256\"}],\"internalType\":\"struct Payment\",\"name\":\"due\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"calculateAmountDue\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"interest\",\"type\":\"uint256\"}],\"internalType\":\"struct Payment\",\"name\":\"due\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_timestamp\",\"type\":\"uint256\"}],\"name\":\"calculateAmountOwed\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"interest\",\"type\":\"uint256\"}],\"internalType\":\"struct Payment\",\"name\":\"owed\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"calculateAmountOwed\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"interest\",\"type\":\"uint256\"}],\"internalType\":\"struct Payment\",\"name\":\"owed\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"calculateNextDueDate\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"dueDate_\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"cancelBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"claimLoanNFT\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateralManager\",\"outputs\":[{\"internalType\":\"contract ICollateralManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getBidState\",\"outputs\":[{\"internalType\":\"enum BidState\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_borrower\",\"type\":\"address\"}],\"name\":\"getBorrowerActiveLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_borrower\",\"type\":\"address\"}],\"name\":\"getBorrowerLoanIds\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getLoanBorrower\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"borrower_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getLoanLender\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"lender_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getLoanLendingToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getLoanMarketId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getLoanSummary\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"principalTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"principalAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"acceptedTimestamp\",\"type\":\"uint32\"},{\"internalType\":\"enum BidState\",\"name\":\"bidState\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"getMetadataURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"metadataURI_\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_forwarder\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"hasApprovedMarketForwarder\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"_protocolFee\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"_marketRegistry\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_reputationManager\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_lenderCommitmentForwarder\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_collateralManager\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_lenderManager\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"isLoanDefaulted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"isLoanExpired\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"isLoanLiquidateable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"isPaymentLate\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forwarder\",\"type\":\"address\"}],\"name\":\"isTrustedForwarder\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_trustedMarketForwarder\",\"type\":\"address\"}],\"name\":\"isTrustedMarketForwarder\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"lastRepaidTimestamp\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"lenderAcceptBid\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToProtocol\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountToMarketplace\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountToBorrower\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lenderCommitmentForwarder\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lenderManager\",\"outputs\":[{\"internalType\":\"contract ILenderManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lenderVolumeFilled\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"liquidateLoanFull\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"marketOwnerCancelBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketRegistry\",\"outputs\":[{\"internalType\":\"contract IMarketRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseProtocol\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"protocolFee\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"repayLoan\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"repayLoanFull\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_bidId\",\"type\":\"uint256\"}],\"name\":\"repayLoanMinimum\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reputationManager\",\"outputs\":[{\"internalType\":\"contract IReputationManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_lenderManager\",\"type\":\"address\"}],\"name\":\"setLenderManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"newFee\",\"type\":\"uint16\"}],\"name\":\"setProtocolFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_reputationManager\",\"type\":\"address\"}],\"name\":\"setReputationManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_marketId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_forwarder\",\"type\":\"address\"}],\"name\":\"setTrustedMarketForwarder\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_lendingToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_marketplaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_principal\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_duration\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_APR\",\"type\":\"uint16\"},{\"internalType\":\"string\",\"name\":\"_metadataURI\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"}],\"name\":\"submitBid\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"bidId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_lendingToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_marketplaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_principal\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"_duration\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_APR\",\"type\":\"uint16\"},{\"internalType\":\"string\",\"name\":\"_metadataURI\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"enum CollateralType\",\"name\":\"_collateralType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_collateralAddress\",\"type\":\"address\"}],\"internalType\":\"struct Collateral[]\",\"name\":\"_collateralInfo\",\"type\":\"tuple[]\"}],\"name\":\"submitBid\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"bidId_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"totalVolumeFilled\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpauseProtocol\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"uris\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"ActionNotAllowed(uint256,string,string)\":[{\"params\":{\"action\":\"The action string (i.e: 'repayLoan', 'cancelBid', 'etc)\",\"bidId\":\"The id of the bid.\",\"message\":\"The message string to return to the user explaining why the tx was reverted\"}}],\"PaymentNotMinimum(uint256,uint256,uint256)\":[{\"params\":{\"bidId\":\"The id of the bid the borrower is attempting to repay.\",\"minimumOwed\":\"The minimum owed value\",\"payment\":\"The payment made by the borrower\"}}]},\"events\":{\"AcceptedBid(uint256,address)\":{\"params\":{\"bidId\":\"The id of the bid accepted.\",\"lender\":\"The address of the accepted bid lender.\"}},\"CancelledBid(uint256)\":{\"params\":{\"bidId\":\"The id of the cancelled bid.\"}},\"FeePaid(uint256,string,uint256)\":{\"params\":{\"amount\":\"The amount of the fee being paid.\",\"bidId\":\"The id of the bid.\",\"feeType\":\"The name of the fee being paid.\"}},\"LoanLiquidated(uint256,address)\":{\"params\":{\"bidId\":\"The id of the bid/loan which was repaid.\"}},\"LoanRepaid(uint256)\":{\"params\":{\"bidId\":\"The id of the bid/loan which was repaid.\"}},\"LoanRepayment(uint256)\":{\"params\":{\"bidId\":\"The id of the bid/loan to which the payment was made.\"}},\"MarketOwnerCancelledBid(uint256)\":{\"params\":{\"bidId\":\"The id of the bid funded. Note: The `CancelledBid` event will also be emitted.\"}},\"SubmittedBid(uint256,address,address,bytes32)\":{\"params\":{\"bidId\":\"The id of the bid submitted.\",\"borrower\":\"The address of the bid borrower.\",\"metadataURI\":\"URI for additional bid information as part of loan bid.\"}}},\"kind\":\"dev\",\"methods\":{\"approveMarketForwarder(uint256,address)\":{\"params\":{\"_forwarder\":\"A forwarder contract address.\",\"_marketId\":\"An ID for a lending market.\"}},\"calculateAmountDue(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to get the payment amount for.\"}},\"calculateAmountDue(uint256,uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to get the payment amount for.\",\"_timestamp\":\"The timestamp at which to get the due payment at.\"}},\"calculateAmountOwed(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to calculate the owed amount for.\"}},\"calculateAmountOwed(uint256,uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to calculate the owed amount for.\",\"_timestamp\":\"The timestamp at which to calculate the loan owed amount at.\"}},\"calculateNextDueDate(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid.\"}},\"cancelBid(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid to cancel.\"}},\"getLoanBorrower(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid/loan to get the borrower for.\"},\"returns\":{\"borrower_\":\"The address of the borrower associated with the bid.\"}},\"getLoanLender(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid/loan to get the lender for.\"},\"returns\":{\"lender_\":\"The address of the lender associated with the bid.\"}},\"getMetadataURI(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid to return the metadataURI for\"},\"returns\":{\"metadataURI_\":\"The metadataURI for the bid, as a string.\"}},\"hasApprovedMarketForwarder(uint256,address,address)\":{\"params\":{\"_account\":\"The address to verify set an approval.\",\"_forwarder\":\"A forwarder contract address.\",\"_marketId\":\"An ID for a lending market.\"},\"returns\":{\"_0\":\"A boolean indicating if an approval was set.\"}},\"initialize(uint16,address,address,address,address,address)\":{\"params\":{\"_collateralManager\":\"The address of the collateral manager contracts.\",\"_lenderCommitmentForwarder\":\"The address of the lender commitment forwarder contract.\",\"_lenderManager\":\"The address of the lender manager contract for loans on the protocol.\",\"_marketRegistry\":\"The address of the market registry contract for the protocol.\",\"_protocolFee\":\"The fee collected by the protocol for loan processing.\",\"_reputationManager\":\"The address of the reputation manager contract.\"}},\"isLoanDefaulted(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to check for.\"},\"returns\":{\"_0\":\"bool True if the loan is defaulted.\"}},\"isLoanExpired(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to check for.\"}},\"isLoanLiquidateable(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to check for.\"},\"returns\":{\"_0\":\"bool True if the loan is liquidateable.\"}},\"isPaymentLate(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to check for.\"}},\"isTrustedMarketForwarder(uint256,address)\":{\"params\":{\"_marketId\":\"An ID for a lending market.\",\"_trustedMarketForwarder\":\"An address to check if is a trusted forwarder in the given market.\"},\"returns\":{\"_0\":\"A boolean indicating the forwarder address is trusted in a market.\"}},\"lastRepaidTimestamp(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to get the timestamp for.\"}},\"lenderAcceptBid(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan bid to accept.\"}},\"liquidateLoanFull(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan to make the payment towards.\"}},\"marketOwnerCancelBid(uint256)\":{\"params\":{\"_bidId\":\"The id of the bid to cancel.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"repayLoan(uint256,uint256)\":{\"params\":{\"_amount\":\"The amount of the payment.\",\"_bidId\":\"The id of the loan to make the payment towards.\"}},\"repayLoanFull(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan to make the payment towards.\"}},\"repayLoanMinimum(uint256)\":{\"params\":{\"_bidId\":\"The id of the loan to make the payment towards.\"}},\"setProtocolFee(uint16)\":{\"params\":{\"newFee\":\"The new protocol fee to be set.\"}},\"setReputationManager(address)\":{\"params\":{\"_reputationManager\":\"The new contract address.\"}},\"setTrustedMarketForwarder(uint256,address)\":{\"params\":{\"_forwarder\":\"A forwarder contract address.\",\"_marketId\":\"An ID for a lending market.\"}},\"submitBid(address,uint256,uint256,uint32,uint16,string,address)\":{\"params\":{\"_APR\":\"The proposed interest rate for the loan bid.\",\"_duration\":\"The recurrent length of time before which a payment is due.\",\"_lendingToken\":\"The lending token asset requested to be borrowed.\",\"_marketplaceId\":\"The unique id of the marketplace for the bid.\",\"_metadataURI\":\"The URI for additional borrower loan information as part of loan bid.\",\"_principal\":\"The principal amount of the loan bid.\",\"_receiver\":\"The address where the loan amount will be sent to.\"}},\"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\":{\"params\":{\"_APR\":\"The proposed interest rate for the loan bid.\",\"_collateralInfo\":\"Additional information about the collateral asset.\",\"_duration\":\"The recurrent length of time before which a payment is due.\",\"_lendingToken\":\"The lending token asset requested to be borrowed.\",\"_marketplaceId\":\"The unique id of the marketplace for the bid.\",\"_metadataURI\":\"The URI for additional borrower loan information as part of loan bid.\",\"_principal\":\"The principal amount of the loan bid.\",\"_receiver\":\"The address where the loan amount will be sent to.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"errors\":{\"ActionNotAllowed(uint256,string,string)\":[{\"notice\":\"This error is reverted when the action isn't allowed\"}],\"PaymentNotMinimum(uint256,uint256,uint256)\":[{\"notice\":\"This error is reverted when repayment amount is less than the required minimum\"}]},\"events\":{\"AcceptedBid(uint256,address)\":{\"notice\":\"This event is emitted when a bid has been accepted by a lender.\"},\"CancelledBid(uint256)\":{\"notice\":\"This event is emitted when a previously submitted bid has been cancelled.\"},\"FeePaid(uint256,string,uint256)\":{\"notice\":\"This event is emitted when a fee has been paid related to a bid.\"},\"LoanLiquidated(uint256,address)\":{\"notice\":\"This event is emitted when a loan has been fully repaid.\"},\"LoanRepaid(uint256)\":{\"notice\":\"This event is emitted when a loan has been fully repaid.\"},\"LoanRepayment(uint256)\":{\"notice\":\"This event is emitted when a payment is made towards an active loan.\"},\"MarketOwnerCancelledBid(uint256)\":{\"notice\":\"This event is emitted when market owner has cancelled a pending bid in their market.\"},\"ProtocolFeeSet(uint16,uint16)\":{\"notice\":\"This event is emitted when the protocol fee has been updated.\"},\"SubmittedBid(uint256,address,address,bytes32)\":{\"notice\":\"This event is emitted when a new bid is submitted.\"}},\"kind\":\"user\",\"methods\":{\"CURRENT_CODE_VERSION()\":{\"notice\":\"Constant Variables *\"},\"approveMarketForwarder(uint256,address)\":{\"notice\":\"Approves a forwarder contract to use their address as a sender for a specific market.The forwarder given must be trusted by the market given.\"},\"bidId()\":{\"notice\":\"Storage Variables \"},\"calculateAmountDue(uint256)\":{\"notice\":\"Calculates the minimum payment amount due for a loan.\"},\"calculateAmountDue(uint256,uint256)\":{\"notice\":\"Calculates the minimum payment amount due for a loan at a specific timestamp.\"},\"calculateAmountOwed(uint256)\":{\"notice\":\"Calculates the total amount owed for a bid.\"},\"calculateAmountOwed(uint256,uint256)\":{\"notice\":\"Calculates the total amount owed for a loan bid at a specific timestamp.\"},\"calculateNextDueDate(uint256)\":{\"notice\":\"Returns the next due date for a loan payment.\"},\"cancelBid(uint256)\":{\"notice\":\"Function for a borrower to cancel their pending bid.\"},\"constructor\":{\"notice\":\"Constructor *\"},\"getLoanBorrower(uint256)\":{\"notice\":\"Returns the borrower address for a given bid.\"},\"getLoanLender(uint256)\":{\"notice\":\"Returns the lender address for a given bid. If the stored lender address is the `LenderManager` NFT address, return the `ownerOf` for the bid ID.\"},\"getMetadataURI(uint256)\":{\"notice\":\"Gets the metadataURI for a bidId.\"},\"hasApprovedMarketForwarder(uint256,address,address)\":{\"notice\":\"Checks if an account has approved a forwarder for a market.\"},\"initialize(uint16,address,address,address,address,address)\":{\"notice\":\"Initializes the proxy.\"},\"isLoanDefaulted(uint256)\":{\"notice\":\"Checks to see if a borrower is delinquent.\"},\"isLoanExpired(uint256)\":{\"notice\":\"Checks to see if a pending loan has expired so it is no longer able to be accepted.\"},\"isLoanLiquidateable(uint256)\":{\"notice\":\"Checks to see if a loan was delinquent for longer than liquidation delay.\"},\"isPaymentLate(uint256)\":{\"notice\":\"Checks to see if a borrower is delinquent.\"},\"isTrustedMarketForwarder(uint256,address)\":{\"notice\":\"Checks if an address is a trusted forwarder contract for a given market.\"},\"lastRepaidTimestamp(uint256)\":{\"notice\":\"Returns the last repaid timestamp for a loan.\"},\"lenderAcceptBid(uint256)\":{\"notice\":\"Function for a lender to accept a proposed loan bid.\"},\"liquidateLoanFull(uint256)\":{\"notice\":\"Function for users to liquidate a defaulted loan.\"},\"marketOwnerCancelBid(uint256)\":{\"notice\":\"Function for a market owner to cancel a bid in the market.\"},\"pauseProtocol()\":{\"notice\":\"Lets the DAO/owner of the protocol implement an emergency stop mechanism.\"},\"protocolFee()\":{\"notice\":\"Returns the current protocol fee.\"},\"repayLoan(uint256,uint256)\":{\"notice\":\"Function for users to make a payment towards an active loan.\"},\"repayLoanFull(uint256)\":{\"notice\":\"Function for users to repay an active loan in full.\"},\"repayLoanMinimum(uint256)\":{\"notice\":\"Function for users to make the minimum amount due for an active loan.\"},\"setProtocolFee(uint16)\":{\"notice\":\"Lets the DAO/owner of the protocol to set a new protocol fee.\"},\"setReputationManager(address)\":{\"notice\":\"Lets the DAO/owner of the protocol to set a new reputation manager contract.\"},\"setTrustedMarketForwarder(uint256,address)\":{\"notice\":\"Sets a trusted forwarder for a lending market.The caller must owner the market given. See {MarketRegistry}\"},\"submitBid(address,uint256,uint256,uint32,uint16,string,address)\":{\"notice\":\"Function for a borrower to create a bid for a loan without Collateral.\"},\"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\":{\"notice\":\"Function for a borrower to create a bid for a loan with Collateral.\"},\"unpauseProtocol()\":{\"notice\":\"Lets the DAO/owner of the protocol undo a previously implemented emergency stop.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TellerV2.sol\":\"TellerV2\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n _requireNotPaused();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n _requirePaused();\\n _;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x40c636b4572ff5f1dc50cf22097e93c0723ee14eff87e99ac2b02636eeca1250\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165Upgradeable.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721Upgradeable is IERC165Upgradeable {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2c0b89cef83f353c6f9488c013d8a5968587ffdd6dfc26aad53774214b97e229\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0x6b9a5d35b744b25529a2856a8093e7c03fb35a34b1c4fb5499e560f8ade140da\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * 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, IERC20Metadata {\\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\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual override 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 override 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 this function is\\n * overridden;\\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 override returns (uint8) {\\n return 18;\\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 * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\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 address owner = _msgSender();\\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\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 address owner = _msgSender();\\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\\n uint256 currentAllowance = allowance(owner, spender);\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `from` to `to`.\\n *\\n * This 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 * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\\n // decrementing then incrementing.\\n _balances[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\\n unchecked {\\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\\n _balances[account] += amount;\\n }\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n // Overflow not possible: amount <= accountBalance <= totalSupply.\\n _totalSupply -= amount;\\n }\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(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(\\n address owner,\\n address spender,\\n uint256 amount\\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\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 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(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after 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 * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x4ffc0547c02ad22925310c585c0f166f8759e2648a09e9b489100c42f15dd98d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\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 unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction 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 unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\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 unchecked {\\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 /**\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\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 unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\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 return a + b;\\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 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 return a * b;\\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.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\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 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\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 * 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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\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(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\\n\\npragma solidity ^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 *\\n * [WARNING]\\n * ====\\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\\n * unusable.\\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\\n *\\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\\n * array of EnumerableSet.\\n * ====\\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 // 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) {\\n // 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 if (lastIndex != toDeleteIndex) {\\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] = valueIndex; // Replace lastValue's index to valueIndex\\n }\\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 return set._values[index];\\n }\\n\\n /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function _values(Set storage set) private view returns (bytes32[] memory) {\\n return set._values;\\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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n bytes32[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(AddressSet storage set) internal view returns (address[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n address[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\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 in 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 /**\\n * @dev Return the entire set in an array\\n *\\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\\n */\\n function values(UintSet storage set) internal view returns (uint256[] memory) {\\n bytes32[] memory store = _values(set._inner);\\n uint256[] memory result;\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := store\\n }\\n\\n return result;\\n }\\n}\\n\",\"keccak256\":\"0xc3ff3f5c4584e1d9a483ad7ced51ab64523201f4e3d3c65293e4ca8aeb77a961\",\"license\":\"MIT\"},\"contracts/EAS/TellerAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"../Types.sol\\\";\\nimport \\\"../interfaces/IEAS.sol\\\";\\nimport \\\"../interfaces/IASRegistry.sol\\\";\\n\\n/**\\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\\n */\\ncontract TellerAS is IEAS {\\n error AccessDenied();\\n error AlreadyRevoked();\\n error InvalidAttestation();\\n error InvalidExpirationTime();\\n error InvalidOffset();\\n error InvalidRegistry();\\n error InvalidSchema();\\n error InvalidVerifier();\\n error NotFound();\\n error NotPayable();\\n\\n string public constant VERSION = \\\"0.8\\\";\\n\\n // A terminator used when concatenating and hashing multiple fields.\\n string private constant HASH_TERMINATOR = \\\"@\\\";\\n\\n // The AS global registry.\\n IASRegistry private immutable _asRegistry;\\n\\n // The EIP712 verifier used to verify signed attestations.\\n IEASEIP712Verifier private immutable _eip712Verifier;\\n\\n // A mapping between attestations and their related attestations.\\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\\n\\n // A mapping between an account and its received attestations.\\n mapping(address => mapping(bytes32 => bytes32[]))\\n private _receivedAttestations;\\n\\n // A mapping between an account and its sent attestations.\\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\\n\\n // A mapping between a schema and its attestations.\\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\\n\\n // The global mapping between attestations and their UUIDs.\\n mapping(bytes32 => Attestation) private _db;\\n\\n // The global counter for the total number of attestations.\\n uint256 private _attestationsCount;\\n\\n bytes32 private _lastUUID;\\n\\n /**\\n * @dev Creates a new EAS instance.\\n *\\n * @param registry The address of the global AS registry.\\n * @param verifier The address of the EIP712 verifier.\\n */\\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\\n if (address(registry) == address(0x0)) {\\n revert InvalidRegistry();\\n }\\n\\n if (address(verifier) == address(0x0)) {\\n revert InvalidVerifier();\\n }\\n\\n _asRegistry = registry;\\n _eip712Verifier = verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getASRegistry() external view override returns (IASRegistry) {\\n return _asRegistry;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getEIP712Verifier()\\n external\\n view\\n override\\n returns (IEASEIP712Verifier)\\n {\\n return _eip712Verifier;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestationsCount() external view override returns (uint256) {\\n return _attestationsCount;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) public payable virtual override returns (bytes32) {\\n return\\n _attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n msg.sender\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public payable virtual override returns (bytes32) {\\n _eip712Verifier.attest(\\n recipient,\\n schema,\\n expirationTime,\\n refUUID,\\n data,\\n attester,\\n v,\\n r,\\n s\\n );\\n\\n return\\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revoke(bytes32 uuid) public virtual override {\\n return _revoke(uuid, msg.sender);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual override {\\n _eip712Verifier.revoke(uuid, attester, v, r, s);\\n\\n _revoke(uuid, attester);\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n override\\n returns (Attestation memory)\\n {\\n return _db[uuid];\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationValid(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _db[uuid].uuid != 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function isAttestationActive(bytes32 uuid)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return\\n isAttestationValid(uuid) &&\\n _db[uuid].expirationTime >= block.timestamp &&\\n _db[uuid].revocationTime == 0;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _receivedAttestations[recipient][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _receivedAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _sentAttestations[attester][schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _sentAttestations[recipient][schema].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _relatedAttestations[uuid],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _relatedAttestations[uuid].length;\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view override returns (bytes32[] memory) {\\n return\\n _sliceUUIDs(\\n _schemaAttestations[schema],\\n start,\\n length,\\n reverseOrder\\n );\\n }\\n\\n /**\\n * @inheritdoc IEAS\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n override\\n returns (uint256)\\n {\\n return _schemaAttestations[schema].length;\\n }\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function _attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester\\n ) private returns (bytes32) {\\n if (expirationTime <= block.timestamp) {\\n revert InvalidExpirationTime();\\n }\\n\\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\\n if (asRecord.uuid == EMPTY_UUID) {\\n revert InvalidSchema();\\n }\\n\\n IASResolver resolver = asRecord.resolver;\\n if (address(resolver) != address(0x0)) {\\n if (msg.value != 0 && !resolver.isPayable()) {\\n revert NotPayable();\\n }\\n\\n if (\\n !resolver.resolve{ value: msg.value }(\\n recipient,\\n asRecord.schema,\\n data,\\n expirationTime,\\n attester\\n )\\n ) {\\n revert InvalidAttestation();\\n }\\n }\\n\\n Attestation memory attestation = Attestation({\\n uuid: EMPTY_UUID,\\n schema: schema,\\n recipient: recipient,\\n attester: attester,\\n time: block.timestamp,\\n expirationTime: expirationTime,\\n revocationTime: 0,\\n refUUID: refUUID,\\n data: data\\n });\\n\\n _lastUUID = _getUUID(attestation);\\n attestation.uuid = _lastUUID;\\n\\n _receivedAttestations[recipient][schema].push(_lastUUID);\\n _sentAttestations[attester][schema].push(_lastUUID);\\n _schemaAttestations[schema].push(_lastUUID);\\n\\n _db[_lastUUID] = attestation;\\n _attestationsCount++;\\n\\n if (refUUID != 0) {\\n if (!isAttestationValid(refUUID)) {\\n revert NotFound();\\n }\\n\\n _relatedAttestations[refUUID].push(_lastUUID);\\n }\\n\\n emit Attested(recipient, attester, _lastUUID, schema);\\n\\n return _lastUUID;\\n }\\n\\n function getLastUUID() external view returns (bytes32) {\\n return _lastUUID;\\n }\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n */\\n function _revoke(bytes32 uuid, address attester) private {\\n Attestation storage attestation = _db[uuid];\\n if (attestation.uuid == EMPTY_UUID) {\\n revert NotFound();\\n }\\n\\n if (attestation.attester != attester) {\\n revert AccessDenied();\\n }\\n\\n if (attestation.revocationTime != 0) {\\n revert AlreadyRevoked();\\n }\\n\\n attestation.revocationTime = block.timestamp;\\n\\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\\n }\\n\\n /**\\n * @dev Calculates a UUID for a given attestation.\\n *\\n * @param attestation The input attestation.\\n *\\n * @return Attestation UUID.\\n */\\n function _getUUID(Attestation memory attestation)\\n private\\n view\\n returns (bytes32)\\n {\\n return\\n keccak256(\\n abi.encodePacked(\\n attestation.schema,\\n attestation.recipient,\\n attestation.attester,\\n attestation.time,\\n attestation.expirationTime,\\n attestation.data,\\n HASH_TERMINATOR,\\n _attestationsCount\\n )\\n );\\n }\\n\\n /**\\n * @dev Returns a slice in an array of attestation UUIDs.\\n *\\n * @param uuids The array of attestation UUIDs.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function _sliceUUIDs(\\n bytes32[] memory uuids,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) private pure returns (bytes32[] memory) {\\n uint256 attestationsLength = uuids.length;\\n if (attestationsLength == 0) {\\n return new bytes32[](0);\\n }\\n\\n if (start >= attestationsLength) {\\n revert InvalidOffset();\\n }\\n\\n uint256 len = length;\\n if (attestationsLength < start + length) {\\n len = attestationsLength - start;\\n }\\n\\n bytes32[] memory res = new bytes32[](len);\\n\\n for (uint256 i = 0; i < len; ++i) {\\n res[i] = uuids[\\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\\n ];\\n }\\n\\n return res;\\n }\\n}\\n\",\"keccak256\":\"0x01848d2b9b7815144137d3ad654ac3246dd740f03e9e951ecf70374d71f8e354\",\"license\":\"MIT\"},\"contracts/ERC2771ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (metatx/ERC2771Context.sol)\\n\\npragma solidity ^0.8.9;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Context variant with ERC2771 support.\\n * @dev This is modified from the OZ library to remove the gap of storage variables at the end.\\n */\\nabstract contract ERC2771ContextUpgradeable is\\n Initializable,\\n ContextUpgradeable\\n{\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address private immutable _trustedForwarder;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(address trustedForwarder) {\\n _trustedForwarder = trustedForwarder;\\n }\\n\\n function isTrustedForwarder(address forwarder)\\n public\\n view\\n virtual\\n returns (bool)\\n {\\n return forwarder == _trustedForwarder;\\n }\\n\\n function _msgSender()\\n internal\\n view\\n virtual\\n override\\n returns (address sender)\\n {\\n if (isTrustedForwarder(msg.sender)) {\\n // The assembly code is more direct than the Solidity version using `abi.decode`.\\n assembly {\\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\\n }\\n } else {\\n return super._msgSender();\\n }\\n }\\n\\n function _msgData()\\n internal\\n view\\n virtual\\n override\\n returns (bytes calldata)\\n {\\n if (isTrustedForwarder(msg.sender)) {\\n return msg.data[:msg.data.length - 20];\\n } else {\\n return super._msgData();\\n }\\n }\\n}\\n\",\"keccak256\":\"0xca6e53699cb6e4001eff7527dc3fcea591be3b04514ab899933fc0f107de4933\",\"license\":\"MIT\"},\"contracts/ProtocolFee.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\ncontract ProtocolFee is OwnableUpgradeable {\\n // Protocol fee set for loan processing.\\n uint16 private _protocolFee;\\n\\n /**\\n * @notice This event is emitted when the protocol fee has been updated.\\n * @param newFee The new protocol fee set.\\n * @param oldFee The previously set protocol fee.\\n */\\n event ProtocolFeeSet(uint16 newFee, uint16 oldFee);\\n\\n /**\\n * @notice Initialized the protocol fee.\\n * @param initFee The initial protocol fee to be set on the protocol.\\n */\\n function __ProtocolFee_init(uint16 initFee) internal onlyInitializing {\\n __Ownable_init();\\n __ProtocolFee_init_unchained(initFee);\\n }\\n\\n function __ProtocolFee_init_unchained(uint16 initFee)\\n internal\\n onlyInitializing\\n {\\n setProtocolFee(initFee);\\n }\\n\\n /**\\n * @notice Returns the current protocol fee.\\n */\\n function protocolFee() public view virtual returns (uint16) {\\n return _protocolFee;\\n }\\n\\n /**\\n * @notice Lets the DAO/owner of the protocol to set a new protocol fee.\\n * @param newFee The new protocol fee to be set.\\n */\\n function setProtocolFee(uint16 newFee) public virtual onlyOwner {\\n // Skip if the fee is the same\\n if (newFee == _protocolFee) return;\\n\\n uint16 oldFee = _protocolFee;\\n _protocolFee = newFee;\\n emit ProtocolFeeSet(newFee, oldFee);\\n }\\n}\\n\",\"keccak256\":\"0x8a4fbca87131233a11efc1c5006a9b9d5ea45b82078c85726ce9e07ef13e2893\",\"license\":\"MIT\"},\"contracts/TellerV2.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// Contracts\\nimport \\\"./ProtocolFee.sol\\\";\\nimport \\\"./TellerV2Storage.sol\\\";\\nimport \\\"./TellerV2Context.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\\\";\\n\\n// Interfaces\\nimport \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"./interfaces/ITellerV2.sol\\\";\\nimport { Collateral } from \\\"./interfaces/escrow/ICollateralEscrowV1.sol\\\";\\n\\n// Libraries\\nimport \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\nimport \\\"./libraries/NumbersLib.sol\\\";\\nimport { BokkyPooBahsDateTimeLibrary as BPBDTL } from \\\"./libraries/DateTimeLib.sol\\\";\\nimport { V2Calculations, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\n\\n/* Errors */\\n/**\\n * @notice This error is reverted when the action isn't allowed\\n * @param bidId The id of the bid.\\n * @param action The action string (i.e: 'repayLoan', 'cancelBid', 'etc)\\n * @param message The message string to return to the user explaining why the tx was reverted\\n */\\nerror ActionNotAllowed(uint256 bidId, string action, string message);\\n\\n/**\\n * @notice This error is reverted when repayment amount is less than the required minimum\\n * @param bidId The id of the bid the borrower is attempting to repay.\\n * @param payment The payment made by the borrower\\n * @param minimumOwed The minimum owed value\\n */\\nerror PaymentNotMinimum(uint256 bidId, uint256 payment, uint256 minimumOwed);\\n\\ncontract TellerV2 is\\n ITellerV2,\\n OwnableUpgradeable,\\n ProtocolFee,\\n PausableUpgradeable,\\n TellerV2Storage,\\n TellerV2Context\\n{\\n using Address for address;\\n using SafeERC20 for ERC20;\\n using NumbersLib for uint256;\\n using EnumerableSet for EnumerableSet.AddressSet;\\n using EnumerableSet for EnumerableSet.UintSet;\\n\\n /** Events */\\n\\n /**\\n * @notice This event is emitted when a new bid is submitted.\\n * @param bidId The id of the bid submitted.\\n * @param borrower The address of the bid borrower.\\n * @param metadataURI URI for additional bid information as part of loan bid.\\n */\\n event SubmittedBid(\\n uint256 indexed bidId,\\n address indexed borrower,\\n address receiver,\\n bytes32 indexed metadataURI\\n );\\n\\n /**\\n * @notice This event is emitted when a bid has been accepted by a lender.\\n * @param bidId The id of the bid accepted.\\n * @param lender The address of the accepted bid lender.\\n */\\n event AcceptedBid(uint256 indexed bidId, address indexed lender);\\n\\n /**\\n * @notice This event is emitted when a previously submitted bid has been cancelled.\\n * @param bidId The id of the cancelled bid.\\n */\\n event CancelledBid(uint256 indexed bidId);\\n\\n /**\\n * @notice This event is emitted when market owner has cancelled a pending bid in their market.\\n * @param bidId The id of the bid funded.\\n *\\n * Note: The `CancelledBid` event will also be emitted.\\n */\\n event MarketOwnerCancelledBid(uint256 indexed bidId);\\n\\n /**\\n * @notice This event is emitted when a payment is made towards an active loan.\\n * @param bidId The id of the bid/loan to which the payment was made.\\n */\\n event LoanRepayment(uint256 indexed bidId);\\n\\n /**\\n * @notice This event is emitted when a loan has been fully repaid.\\n * @param bidId The id of the bid/loan which was repaid.\\n */\\n event LoanRepaid(uint256 indexed bidId);\\n\\n /**\\n * @notice This event is emitted when a loan has been fully repaid.\\n * @param bidId The id of the bid/loan which was repaid.\\n */\\n event LoanLiquidated(uint256 indexed bidId, address indexed liquidator);\\n\\n /**\\n * @notice This event is emitted when a fee has been paid related to a bid.\\n * @param bidId The id of the bid.\\n * @param feeType The name of the fee being paid.\\n * @param amount The amount of the fee being paid.\\n */\\n event FeePaid(\\n uint256 indexed bidId,\\n string indexed feeType,\\n uint256 indexed amount\\n );\\n\\n /** Modifiers */\\n\\n /**\\n * @notice This modifier is used to check if the state of a bid is pending, before running an action.\\n * @param _bidId The id of the bid to check the state for.\\n * @param _action The desired action to run on the bid.\\n */\\n modifier pendingBid(uint256 _bidId, string memory _action) {\\n if (bids[_bidId].state != BidState.PENDING) {\\n revert ActionNotAllowed(_bidId, _action, \\\"Bid must be pending\\\");\\n }\\n\\n _;\\n }\\n\\n /**\\n * @notice This modifier is used to check if the state of a loan has been accepted, before running an action.\\n * @param _bidId The id of the bid to check the state for.\\n * @param _action The desired action to run on the bid.\\n */\\n modifier acceptedLoan(uint256 _bidId, string memory _action) {\\n if (bids[_bidId].state != BidState.ACCEPTED) {\\n revert ActionNotAllowed(_bidId, _action, \\\"Loan must be accepted\\\");\\n }\\n\\n _;\\n }\\n\\n /** Constant Variables **/\\n\\n uint8 public constant CURRENT_CODE_VERSION = 9;\\n\\n uint32 public constant LIQUIDATION_DELAY = 86400; //ONE DAY IN SECONDS\\n\\n /** Constructor **/\\n\\n constructor(address trustedForwarder) TellerV2Context(trustedForwarder) {}\\n\\n /** External Functions **/\\n\\n /**\\n * @notice Initializes the proxy.\\n * @param _protocolFee The fee collected by the protocol for loan processing.\\n * @param _marketRegistry The address of the market registry contract for the protocol.\\n * @param _reputationManager The address of the reputation manager contract.\\n * @param _lenderCommitmentForwarder The address of the lender commitment forwarder contract.\\n * @param _collateralManager The address of the collateral manager contracts.\\n * @param _lenderManager The address of the lender manager contract for loans on the protocol.\\n */\\n function initialize(\\n uint16 _protocolFee,\\n address _marketRegistry,\\n address _reputationManager,\\n address _lenderCommitmentForwarder,\\n address _collateralManager,\\n address _lenderManager\\n ) external initializer {\\n __ProtocolFee_init(_protocolFee);\\n\\n __Pausable_init();\\n\\n require(\\n _lenderCommitmentForwarder.isContract(),\\n \\\"LenderCommitmentForwarder must be a contract\\\"\\n );\\n lenderCommitmentForwarder = _lenderCommitmentForwarder;\\n\\n require(\\n _marketRegistry.isContract(),\\n \\\"MarketRegistry must be a contract\\\"\\n );\\n marketRegistry = IMarketRegistry(_marketRegistry);\\n\\n require(\\n _reputationManager.isContract(),\\n \\\"ReputationManager must be a contract\\\"\\n );\\n reputationManager = IReputationManager(_reputationManager);\\n\\n require(\\n _collateralManager.isContract(),\\n \\\"CollateralManager must be a contract\\\"\\n );\\n collateralManager = ICollateralManager(_collateralManager);\\n\\n _setLenderManager(_lenderManager);\\n }\\n\\n function setLenderManager(address _lenderManager)\\n external\\n reinitializer(8)\\n onlyOwner\\n {\\n _setLenderManager(_lenderManager);\\n }\\n\\n function _setLenderManager(address _lenderManager)\\n internal\\n onlyInitializing\\n {\\n require(\\n _lenderManager.isContract(),\\n \\\"LenderManager must be a contract\\\"\\n );\\n lenderManager = ILenderManager(_lenderManager);\\n }\\n\\n /**\\n * @notice Gets the metadataURI for a bidId.\\n * @param _bidId The id of the bid to return the metadataURI for\\n * @return metadataURI_ The metadataURI for the bid, as a string.\\n */\\n function getMetadataURI(uint256 _bidId)\\n public\\n view\\n returns (string memory metadataURI_)\\n {\\n // Check uri mapping first\\n metadataURI_ = uris[_bidId];\\n // If the URI is not present in the mapping\\n if (\\n keccak256(abi.encodePacked(metadataURI_)) ==\\n 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 // hardcoded constant of keccak256('')\\n ) {\\n // Return depreciated bytes32 uri as a string\\n uint256 convertedURI = uint256(bids[_bidId]._metadataURI);\\n metadataURI_ = StringsUpgradeable.toHexString(convertedURI, 32);\\n }\\n }\\n\\n /**\\n * @notice Lets the DAO/owner of the protocol to set a new reputation manager contract.\\n * @param _reputationManager The new contract address.\\n */\\n function setReputationManager(address _reputationManager) public onlyOwner {\\n reputationManager = IReputationManager(_reputationManager);\\n }\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan without Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) public override whenNotPaused returns (uint256 bidId_) {\\n bidId_ = _submitBid(\\n _lendingToken,\\n _marketplaceId,\\n _principal,\\n _duration,\\n _APR,\\n _metadataURI,\\n _receiver\\n );\\n }\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) public override whenNotPaused returns (uint256 bidId_) {\\n bidId_ = _submitBid(\\n _lendingToken,\\n _marketplaceId,\\n _principal,\\n _duration,\\n _APR,\\n _metadataURI,\\n _receiver\\n );\\n\\n bool validation = collateralManager.commitCollateral(\\n bidId_,\\n _collateralInfo\\n );\\n\\n require(\\n validation == true,\\n \\\"Collateral balance could not be validated\\\"\\n );\\n }\\n\\n function _submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) internal returns (uint256 bidId_) {\\n address sender = _msgSenderForMarket(_marketplaceId);\\n (bool isVerified, ) = marketRegistry.isVerifiedBorrower(\\n _marketplaceId,\\n sender\\n );\\n require(isVerified, \\\"Not verified borrower\\\");\\n require(\\n !marketRegistry.isMarketClosed(_marketplaceId),\\n \\\"Market is closed\\\"\\n );\\n\\n // Set response bid ID.\\n bidId_ = bidId;\\n\\n // Create and store our bid into the mapping\\n Bid storage bid = bids[bidId];\\n bid.borrower = sender;\\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\\n bid.marketplaceId = _marketplaceId;\\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\\n bid.loanDetails.principal = _principal;\\n bid.loanDetails.loanDuration = _duration;\\n bid.loanDetails.timestamp = uint32(block.timestamp);\\n\\n // Set payment cycle type based on market setting (custom or monthly)\\n (bid.terms.paymentCycle, bidPaymentCycleType[bidId]) = marketRegistry\\n .getPaymentCycle(_marketplaceId);\\n\\n bid.terms.APR = _APR;\\n\\n bidDefaultDuration[bidId] = marketRegistry.getPaymentDefaultDuration(\\n _marketplaceId\\n );\\n\\n bidExpirationTime[bidId] = marketRegistry.getBidExpirationTime(\\n _marketplaceId\\n );\\n\\n bid.paymentType = marketRegistry.getPaymentType(_marketplaceId);\\n\\n bid.terms.paymentCycleAmount = V2Calculations\\n .calculatePaymentCycleAmount(\\n bid.paymentType,\\n bidPaymentCycleType[bidId],\\n _principal,\\n _duration,\\n bid.terms.paymentCycle,\\n _APR\\n );\\n\\n uris[bidId] = _metadataURI;\\n bid.state = BidState.PENDING;\\n\\n emit SubmittedBid(\\n bidId,\\n bid.borrower,\\n bid.receiver,\\n keccak256(abi.encodePacked(_metadataURI))\\n );\\n\\n // Store bid inside borrower bids mapping\\n borrowerBids[bid.borrower].push(bidId);\\n\\n // Increment bid id counter\\n bidId++;\\n }\\n\\n /**\\n * @notice Function for a borrower to cancel their pending bid.\\n * @param _bidId The id of the bid to cancel.\\n */\\n function cancelBid(uint256 _bidId) external {\\n if (\\n _msgSenderForMarket(bids[_bidId].marketplaceId) !=\\n bids[_bidId].borrower\\n ) {\\n revert ActionNotAllowed({\\n bidId: _bidId,\\n action: \\\"cancelBid\\\",\\n message: \\\"Only the bid owner can cancel!\\\"\\n });\\n }\\n _cancelBid(_bidId);\\n }\\n\\n /**\\n * @notice Function for a market owner to cancel a bid in the market.\\n * @param _bidId The id of the bid to cancel.\\n */\\n function marketOwnerCancelBid(uint256 _bidId) external {\\n if (\\n _msgSender() !=\\n marketRegistry.getMarketOwner(bids[_bidId].marketplaceId)\\n ) {\\n revert ActionNotAllowed({\\n bidId: _bidId,\\n action: \\\"marketOwnerCancelBid\\\",\\n message: \\\"Only the market owner can cancel!\\\"\\n });\\n }\\n _cancelBid(_bidId);\\n emit MarketOwnerCancelledBid(_bidId);\\n }\\n\\n /**\\n * @notice Function for users to cancel a bid.\\n * @param _bidId The id of the bid to be cancelled.\\n */\\n function _cancelBid(uint256 _bidId)\\n internal\\n pendingBid(_bidId, \\\"cancelBid\\\")\\n {\\n // Set the bid state to CANCELLED\\n bids[_bidId].state = BidState.CANCELLED;\\n\\n // Emit CancelledBid event\\n emit CancelledBid(_bidId);\\n }\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n override\\n pendingBid(_bidId, \\\"lenderAcceptBid\\\")\\n whenNotPaused\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n )\\n {\\n // Retrieve bid\\n Bid storage bid = bids[_bidId];\\n\\n address sender = _msgSenderForMarket(bid.marketplaceId);\\n\\n (bool isVerified, ) = marketRegistry.isVerifiedLender(\\n bid.marketplaceId,\\n sender\\n );\\n require(isVerified, \\\"Not verified lender\\\");\\n\\n require(\\n !marketRegistry.isMarketClosed(bid.marketplaceId),\\n \\\"Market is closed\\\"\\n );\\n\\n require(!isLoanExpired(_bidId), \\\"Bid has expired\\\");\\n\\n // Set timestamp\\n bid.loanDetails.acceptedTimestamp = uint32(block.timestamp);\\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\\n\\n // Mark borrower's request as accepted\\n bid.state = BidState.ACCEPTED;\\n\\n // Declare the bid acceptor as the lender of the bid\\n bid.lender = sender;\\n\\n // Tell the collateral manager to deploy the escrow and pull funds from the borrower if applicable\\n collateralManager.deployAndDeposit(_bidId);\\n\\n // Transfer funds to borrower from the lender\\n amountToProtocol = bid.loanDetails.principal.percent(protocolFee());\\n amountToMarketplace = bid.loanDetails.principal.percent(\\n marketRegistry.getMarketplaceFee(bid.marketplaceId)\\n );\\n amountToBorrower =\\n bid.loanDetails.principal -\\n amountToProtocol -\\n amountToMarketplace;\\n //transfer fee to protocol\\n bid.loanDetails.lendingToken.safeTransferFrom(\\n sender,\\n owner(),\\n amountToProtocol\\n );\\n\\n //transfer fee to marketplace\\n bid.loanDetails.lendingToken.safeTransferFrom(\\n sender,\\n marketRegistry.getMarketFeeRecipient(bid.marketplaceId),\\n amountToMarketplace\\n );\\n\\n //transfer funds to borrower\\n bid.loanDetails.lendingToken.safeTransferFrom(\\n sender,\\n bid.receiver,\\n amountToBorrower\\n );\\n\\n // Record volume filled by lenders\\n lenderVolumeFilled[address(bid.loanDetails.lendingToken)][sender] += bid\\n .loanDetails\\n .principal;\\n totalVolumeFilled[address(bid.loanDetails.lendingToken)] += bid\\n .loanDetails\\n .principal;\\n\\n // Add borrower's active bid\\n _borrowerBidsActive[bid.borrower].add(_bidId);\\n\\n // Emit AcceptedBid\\n emit AcceptedBid(_bidId, sender);\\n\\n emit FeePaid(_bidId, \\\"protocol\\\", amountToProtocol);\\n emit FeePaid(_bidId, \\\"marketplace\\\", amountToMarketplace);\\n }\\n\\n function claimLoanNFT(uint256 _bidId)\\n external\\n acceptedLoan(_bidId, \\\"claimLoanNFT\\\")\\n whenNotPaused\\n {\\n // Retrieve bid\\n Bid storage bid = bids[_bidId];\\n\\n address sender = _msgSenderForMarket(bid.marketplaceId);\\n require(sender == bid.lender, \\\"only lender can claim NFT\\\");\\n // mint an NFT with the lender manager\\n lenderManager.registerLoan(_bidId, sender);\\n // set lender address to the lender manager so we know to check the owner of the NFT for the true lender\\n bid.lender = address(lenderManager);\\n }\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId)\\n external\\n acceptedLoan(_bidId, \\\"repayLoan\\\")\\n {\\n (\\n uint256 owedPrincipal,\\n uint256 duePrincipal,\\n uint256 interest\\n ) = V2Calculations.calculateAmountOwed(\\n bids[_bidId],\\n block.timestamp,\\n bidPaymentCycleType[_bidId]\\n );\\n _repayLoan(\\n _bidId,\\n Payment({ principal: duePrincipal, interest: interest }),\\n owedPrincipal + interest,\\n true\\n );\\n }\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId)\\n external\\n acceptedLoan(_bidId, \\\"repayLoan\\\")\\n {\\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\\n .calculateAmountOwed(\\n bids[_bidId],\\n block.timestamp,\\n bidPaymentCycleType[_bidId]\\n );\\n _repayLoan(\\n _bidId,\\n Payment({ principal: owedPrincipal, interest: interest }),\\n owedPrincipal + interest,\\n true\\n );\\n }\\n\\n // function that the borrower (ideally) sends to repay the loan\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount)\\n external\\n acceptedLoan(_bidId, \\\"repayLoan\\\")\\n {\\n (\\n uint256 owedPrincipal,\\n uint256 duePrincipal,\\n uint256 interest\\n ) = V2Calculations.calculateAmountOwed(\\n bids[_bidId],\\n block.timestamp,\\n bidPaymentCycleType[_bidId]\\n );\\n uint256 minimumOwed = duePrincipal + interest;\\n\\n // If amount is less than minimumOwed, we revert\\n if (_amount < minimumOwed) {\\n revert PaymentNotMinimum(_bidId, _amount, minimumOwed);\\n }\\n\\n _repayLoan(\\n _bidId,\\n Payment({ principal: _amount - interest, interest: interest }),\\n owedPrincipal + interest,\\n true\\n );\\n }\\n\\n /**\\n * @notice Lets the DAO/owner of the protocol implement an emergency stop mechanism.\\n */\\n function pauseProtocol() public virtual onlyOwner whenNotPaused {\\n _pause();\\n }\\n\\n /**\\n * @notice Lets the DAO/owner of the protocol undo a previously implemented emergency stop.\\n */\\n function unpauseProtocol() public virtual onlyOwner whenPaused {\\n _unpause();\\n }\\n\\n //TODO: add an incentive for liquidator\\n /**\\n * @notice Function for users to liquidate a defaulted loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function liquidateLoanFull(uint256 _bidId)\\n external\\n acceptedLoan(_bidId, \\\"liquidateLoan\\\")\\n {\\n require(isLoanLiquidateable(_bidId), \\\"Loan must be liquidateable.\\\");\\n\\n Bid storage bid = bids[_bidId];\\n\\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\\n .calculateAmountOwed(\\n bid,\\n block.timestamp,\\n bidPaymentCycleType[_bidId]\\n );\\n _repayLoan(\\n _bidId,\\n Payment({ principal: owedPrincipal, interest: interest }),\\n owedPrincipal + interest,\\n false\\n );\\n\\n bid.state = BidState.LIQUIDATED;\\n\\n // If loan is backed by collateral, withdraw and send to the liquidator\\n address liquidator = _msgSenderForMarket(bid.marketplaceId);\\n collateralManager.liquidateCollateral(_bidId, liquidator);\\n\\n emit LoanLiquidated(_bidId, liquidator);\\n }\\n\\n /**\\n * @notice Internal function to make a loan payment.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _payment The Payment struct with payments amounts towards principal and interest respectively.\\n * @param _owedAmount The total amount owed on the loan.\\n */\\n function _repayLoan(\\n uint256 _bidId,\\n Payment memory _payment,\\n uint256 _owedAmount,\\n bool _shouldWithdrawCollateral\\n ) internal {\\n Bid storage bid = bids[_bidId];\\n uint256 paymentAmount = _payment.principal + _payment.interest;\\n\\n RepMark mark = reputationManager.updateAccountReputation(\\n bid.borrower,\\n _bidId\\n );\\n\\n // Check if we are sending a payment or amount remaining\\n if (paymentAmount >= _owedAmount) {\\n paymentAmount = _owedAmount;\\n bid.state = BidState.PAID;\\n\\n // Remove borrower's active bid\\n _borrowerBidsActive[bid.borrower].remove(_bidId);\\n\\n // If loan is is being liquidated and backed by collateral, withdraw and send to borrower\\n if (_shouldWithdrawCollateral) {\\n collateralManager.withdraw(_bidId);\\n }\\n\\n emit LoanRepaid(_bidId);\\n } else {\\n emit LoanRepayment(_bidId);\\n }\\n\\n address lender = getLoanLender(_bidId);\\n\\n // Send payment to the lender\\n bid.loanDetails.lendingToken.safeTransferFrom(\\n _msgSenderForMarket(bid.marketplaceId),\\n lender,\\n paymentAmount\\n );\\n\\n // update our mappings\\n bid.loanDetails.totalRepaid.principal += _payment.principal;\\n bid.loanDetails.totalRepaid.interest += _payment.interest;\\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\\n\\n // If the loan is paid in full and has a mark, we should update the current reputation\\n if (mark != RepMark.Good) {\\n reputationManager.updateAccountReputation(bid.borrower, _bidId);\\n }\\n }\\n\\n /**\\n * @notice Calculates the total amount owed for a bid.\\n * @param _bidId The id of the loan bid to calculate the owed amount for.\\n */\\n function calculateAmountOwed(uint256 _bidId)\\n public\\n view\\n returns (Payment memory owed)\\n {\\n if (bids[_bidId].state != BidState.ACCEPTED) return owed;\\n\\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\\n .calculateAmountOwed(\\n bids[_bidId],\\n block.timestamp,\\n bidPaymentCycleType[_bidId]\\n );\\n owed.principal = owedPrincipal;\\n owed.interest = interest;\\n }\\n\\n /**\\n * @notice Calculates the total amount owed for a loan bid at a specific timestamp.\\n * @param _bidId The id of the loan bid to calculate the owed amount for.\\n * @param _timestamp The timestamp at which to calculate the loan owed amount at.\\n */\\n function calculateAmountOwed(uint256 _bidId, uint256 _timestamp)\\n public\\n view\\n returns (Payment memory owed)\\n {\\n Bid storage bid = bids[_bidId];\\n if (\\n bid.state != BidState.ACCEPTED ||\\n bid.loanDetails.acceptedTimestamp >= _timestamp\\n ) return owed;\\n\\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\\n owed.principal = owedPrincipal;\\n owed.interest = interest;\\n }\\n\\n /**\\n * @notice Calculates the minimum payment amount due for a loan.\\n * @param _bidId The id of the loan bid to get the payment amount for.\\n */\\n function calculateAmountDue(uint256 _bidId)\\n public\\n view\\n returns (Payment memory due)\\n {\\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\\n\\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\\n .calculateAmountOwed(\\n bids[_bidId],\\n block.timestamp,\\n bidPaymentCycleType[_bidId]\\n );\\n due.principal = duePrincipal;\\n due.interest = interest;\\n }\\n\\n /**\\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\\n * @param _bidId The id of the loan bid to get the payment amount for.\\n * @param _timestamp The timestamp at which to get the due payment at.\\n */\\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\\n public\\n view\\n returns (Payment memory due)\\n {\\n Bid storage bid = bids[_bidId];\\n if (\\n bids[_bidId].state != BidState.ACCEPTED ||\\n bid.loanDetails.acceptedTimestamp >= _timestamp\\n ) return due;\\n\\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\\n due.principal = duePrincipal;\\n due.interest = interest;\\n }\\n\\n /**\\n * @notice Returns the next due date for a loan payment.\\n * @param _bidId The id of the loan bid.\\n */\\n function calculateNextDueDate(uint256 _bidId)\\n public\\n view\\n returns (uint32 dueDate_)\\n {\\n Bid storage bid = bids[_bidId];\\n if (bids[_bidId].state != BidState.ACCEPTED) return dueDate_;\\n\\n uint32 lastRepaidTimestamp = lastRepaidTimestamp(_bidId);\\n\\n // Calculate due date if payment cycle is set to monthly\\n if (bidPaymentCycleType[_bidId] == PaymentCycleType.Monthly) {\\n // Calculate the cycle number the last repayment was made\\n uint256 lastPaymentCycle = BPBDTL.diffMonths(\\n bid.loanDetails.acceptedTimestamp,\\n lastRepaidTimestamp\\n );\\n if (\\n BPBDTL.getDay(lastRepaidTimestamp) >\\n BPBDTL.getDay(bid.loanDetails.acceptedTimestamp)\\n ) {\\n lastPaymentCycle += 2;\\n } else {\\n lastPaymentCycle += 1;\\n }\\n\\n dueDate_ = uint32(\\n BPBDTL.addMonths(\\n bid.loanDetails.acceptedTimestamp,\\n lastPaymentCycle\\n )\\n );\\n } else if (bidPaymentCycleType[_bidId] == PaymentCycleType.Seconds) {\\n // Start with the original due date being 1 payment cycle since bid was accepted\\n dueDate_ =\\n bid.loanDetails.acceptedTimestamp +\\n bid.terms.paymentCycle;\\n // Calculate the cycle number the last repayment was made\\n uint32 delta = lastRepaidTimestamp -\\n bid.loanDetails.acceptedTimestamp;\\n if (delta > 0) {\\n uint32 repaymentCycle = uint32(\\n Math.ceilDiv(delta, bid.terms.paymentCycle)\\n );\\n dueDate_ += (repaymentCycle * bid.terms.paymentCycle);\\n }\\n }\\n\\n uint32 endOfLoan = bid.loanDetails.acceptedTimestamp +\\n bid.loanDetails.loanDuration;\\n //if we are in the last payment cycle, the next due date is the end of loan duration\\n if (dueDate_ > endOfLoan) {\\n dueDate_ = endOfLoan;\\n }\\n }\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) public view override returns (bool) {\\n if (bids[_bidId].state != BidState.ACCEPTED) return false;\\n return uint32(block.timestamp) > calculateNextDueDate(_bidId);\\n }\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n * @return bool True if the loan is defaulted.\\n */\\n function isLoanDefaulted(uint256 _bidId)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _canLiquidateLoan(_bidId, 0);\\n }\\n\\n /**\\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\\n * @param _bidId The id of the loan bid to check for.\\n * @return bool True if the loan is liquidateable.\\n */\\n function isLoanLiquidateable(uint256 _bidId)\\n public\\n view\\n override\\n returns (bool)\\n {\\n return _canLiquidateLoan(_bidId, LIQUIDATION_DELAY);\\n }\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n * @param _liquidationDelay Amount of additional seconds after a loan defaulted to allow a liquidation.\\n * @return bool True if the loan is liquidateable.\\n */\\n function _canLiquidateLoan(uint256 _bidId, uint32 _liquidationDelay)\\n internal\\n view\\n returns (bool)\\n {\\n Bid storage bid = bids[_bidId];\\n\\n // Make sure loan cannot be liquidated if it is not active\\n if (bid.state != BidState.ACCEPTED) return false;\\n\\n if (bidDefaultDuration[_bidId] == 0) return false;\\n\\n return (uint32(block.timestamp) -\\n _liquidationDelay -\\n lastRepaidTimestamp(_bidId) >\\n bidDefaultDuration[_bidId]);\\n }\\n\\n function getBidState(uint256 _bidId)\\n external\\n view\\n override\\n returns (BidState)\\n {\\n return bids[_bidId].state;\\n }\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n override\\n returns (uint256[] memory)\\n {\\n return _borrowerBidsActive[_borrower].values();\\n }\\n\\n function getBorrowerLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n return borrowerBids[_borrower];\\n }\\n\\n /**\\n * @notice Checks to see if a pending loan has expired so it is no longer able to be accepted.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanExpired(uint256 _bidId) public view returns (bool) {\\n Bid storage bid = bids[_bidId];\\n\\n if (bid.state != BidState.PENDING) return false;\\n if (bidExpirationTime[_bidId] == 0) return false;\\n\\n return (uint32(block.timestamp) >\\n bid.loanDetails.timestamp + bidExpirationTime[_bidId]);\\n }\\n\\n /**\\n * @notice Returns the last repaid timestamp for a loan.\\n * @param _bidId The id of the loan bid to get the timestamp for.\\n */\\n function lastRepaidTimestamp(uint256 _bidId) public view returns (uint32) {\\n return V2Calculations.lastRepaidTimestamp(bids[_bidId]);\\n }\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n public\\n view\\n returns (address borrower_)\\n {\\n borrower_ = bids[_bidId].borrower;\\n }\\n\\n /**\\n * @notice Returns the lender address for a given bid. If the stored lender address is the `LenderManager` NFT address, return the `ownerOf` for the bid ID.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n public\\n view\\n returns (address lender_)\\n {\\n lender_ = bids[_bidId].lender;\\n\\n if (lender_ == address(lenderManager)) {\\n return lenderManager.ownerOf(_bidId);\\n }\\n }\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_)\\n {\\n token_ = address(bids[_bidId].loanDetails.lendingToken);\\n }\\n\\n function getLoanMarketId(uint256 _bidId)\\n external\\n view\\n returns (uint256 _marketId)\\n {\\n _marketId = bids[_bidId].marketplaceId;\\n }\\n\\n function getLoanSummary(uint256 _bidId)\\n external\\n view\\n returns (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n )\\n {\\n Bid storage bid = bids[_bidId];\\n\\n borrower = bid.borrower;\\n lender = bid.lender;\\n marketId = bid.marketplaceId;\\n principalTokenAddress = address(bid.loanDetails.lendingToken);\\n principalAmount = bid.loanDetails.principal;\\n acceptedTimestamp = bid.loanDetails.acceptedTimestamp;\\n bidState = bid.state;\\n }\\n\\n /** OpenZeppelin Override Functions **/\\n\\n function _msgSender()\\n internal\\n view\\n virtual\\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\\n returns (address sender)\\n {\\n sender = ERC2771ContextUpgradeable._msgSender();\\n }\\n\\n function _msgData()\\n internal\\n view\\n virtual\\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\\n returns (bytes calldata)\\n {\\n return ERC2771ContextUpgradeable._msgData();\\n }\\n}\\n\",\"keccak256\":\"0xf2da6aebe9c2792c2c6d130ada2f0c1a54f2c1a70458e76e2a344b49db6c9392\",\"license\":\"MIT\"},\"contracts/TellerV2Context.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./TellerV2Storage.sol\\\";\\nimport \\\"./ERC2771ContextUpgradeable.sol\\\";\\n\\n/**\\n * @dev This contract should not use any storage\\n */\\n\\nabstract contract TellerV2Context is\\n ERC2771ContextUpgradeable,\\n TellerV2Storage\\n{\\n using EnumerableSet for EnumerableSet.AddressSet;\\n\\n event TrustedMarketForwarderSet(\\n uint256 indexed marketId,\\n address forwarder,\\n address sender\\n );\\n event MarketForwarderApproved(\\n uint256 indexed marketId,\\n address indexed forwarder,\\n address sender\\n );\\n\\n constructor(address trustedForwarder)\\n ERC2771ContextUpgradeable(trustedForwarder)\\n {}\\n\\n /**\\n * @notice Checks if an address is a trusted forwarder contract for a given market.\\n * @param _marketId An ID for a lending market.\\n * @param _trustedMarketForwarder An address to check if is a trusted forwarder in the given market.\\n * @return A boolean indicating the forwarder address is trusted in a market.\\n */\\n function isTrustedMarketForwarder(\\n uint256 _marketId,\\n address _trustedMarketForwarder\\n ) public view returns (bool) {\\n return\\n _trustedMarketForwarders[_marketId] == _trustedMarketForwarder ||\\n lenderCommitmentForwarder == _trustedMarketForwarder;\\n }\\n\\n /**\\n * @notice Checks if an account has approved a forwarder for a market.\\n * @param _marketId An ID for a lending market.\\n * @param _forwarder A forwarder contract address.\\n * @param _account The address to verify set an approval.\\n * @return A boolean indicating if an approval was set.\\n */\\n function hasApprovedMarketForwarder(\\n uint256 _marketId,\\n address _forwarder,\\n address _account\\n ) public view returns (bool) {\\n return\\n isTrustedMarketForwarder(_marketId, _forwarder) &&\\n _approvedForwarderSenders[_forwarder].contains(_account);\\n }\\n\\n /**\\n * @notice Sets a trusted forwarder for a lending market.\\n * @notice The caller must owner the market given. See {MarketRegistry}\\n * @param _marketId An ID for a lending market.\\n * @param _forwarder A forwarder contract address.\\n */\\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\\n external\\n {\\n require(\\n marketRegistry.getMarketOwner(_marketId) == _msgSender(),\\n \\\"Caller must be the market owner\\\"\\n );\\n _trustedMarketForwarders[_marketId] = _forwarder;\\n emit TrustedMarketForwarderSet(_marketId, _forwarder, _msgSender());\\n }\\n\\n /**\\n * @notice Approves a forwarder contract to use their address as a sender for a specific market.\\n * @notice The forwarder given must be trusted by the market given.\\n * @param _marketId An ID for a lending market.\\n * @param _forwarder A forwarder contract address.\\n */\\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\\n external\\n {\\n require(\\n isTrustedMarketForwarder(_marketId, _forwarder),\\n \\\"Forwarder must be trusted by the market\\\"\\n );\\n _approvedForwarderSenders[_forwarder].add(_msgSender());\\n emit MarketForwarderApproved(_marketId, _forwarder, _msgSender());\\n }\\n\\n /**\\n * @notice Retrieves the function caller address by checking the appended calldata if the _actual_ caller is a trusted forwarder.\\n * @param _marketId An ID for a lending market.\\n * @return sender The address to use as the function caller.\\n */\\n function _msgSenderForMarket(uint256 _marketId)\\n internal\\n view\\n virtual\\n returns (address)\\n {\\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\\n address sender;\\n assembly {\\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\\n }\\n // Ensure the appended sender address approved the forwarder\\n require(\\n _approvedForwarderSenders[_msgSender()].contains(sender),\\n \\\"Sender must approve market forwarder\\\"\\n );\\n return sender;\\n }\\n\\n return _msgSender();\\n }\\n\\n /**\\n * @notice Retrieves the actual function calldata from a trusted forwarder call.\\n * @param _marketId An ID for a lending market to verify if the caller is a trusted forwarder.\\n * @return calldata The modified bytes array of the function calldata without the appended sender's address.\\n */\\n function _msgDataForMarket(uint256 _marketId)\\n internal\\n view\\n virtual\\n returns (bytes calldata)\\n {\\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\\n return msg.data[:msg.data.length - 20];\\n } else {\\n return _msgData();\\n }\\n }\\n}\\n\",\"keccak256\":\"0xac04758cc31571352e976d2b33e660d8161176fdf712c76049fb1eda2289f551\",\"license\":\"MIT\"},\"contracts/TellerV2Storage.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport { IMarketRegistry } from \\\"./interfaces/IMarketRegistry.sol\\\";\\nimport \\\"./interfaces/IReputationManager.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./interfaces/ICollateralManager.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"./libraries/V2Calculations.sol\\\";\\nimport \\\"./interfaces/ILenderManager.sol\\\";\\n\\nenum BidState {\\n NONEXISTENT,\\n PENDING,\\n CANCELLED,\\n ACCEPTED,\\n PAID,\\n LIQUIDATED\\n}\\n\\n/**\\n * @notice Represents a total amount for a payment.\\n * @param principal Amount that counts towards the principal.\\n * @param interest Amount that counts toward interest.\\n */\\nstruct Payment {\\n uint256 principal;\\n uint256 interest;\\n}\\n\\n/**\\n * @notice Details about a loan request.\\n * @param borrower Account address who is requesting a loan.\\n * @param receiver Account address who will receive the loan amount.\\n * @param lender Account address who accepted and funded the loan request.\\n * @param marketplaceId ID of the marketplace the bid was submitted to.\\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\\n * @param loanDetails Struct of the specific loan details.\\n * @param terms Struct of the loan request terms.\\n * @param state Represents the current state of the loan.\\n */\\nstruct Bid {\\n address borrower;\\n address receiver;\\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\\n uint256 marketplaceId;\\n bytes32 _metadataURI; // DEPRECATED\\n LoanDetails loanDetails;\\n Terms terms;\\n BidState state;\\n PaymentType paymentType;\\n}\\n\\n/**\\n * @notice Details about the loan.\\n * @param lendingToken The token address for the loan.\\n * @param principal The amount of tokens initially lent out.\\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\\n * @param loanDuration The duration of the loan.\\n */\\nstruct LoanDetails {\\n ERC20 lendingToken;\\n uint256 principal;\\n Payment totalRepaid;\\n uint32 timestamp;\\n uint32 acceptedTimestamp;\\n uint32 lastRepaidTimestamp;\\n uint32 loanDuration;\\n}\\n\\n/**\\n * @notice Information on the terms of a loan request\\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\\n */\\nstruct Terms {\\n uint256 paymentCycleAmount;\\n uint32 paymentCycle;\\n uint16 APR;\\n}\\n\\nabstract contract TellerV2Storage_G0 {\\n /** Storage Variables */\\n\\n // Current number of bids.\\n uint256 public bidId = 0;\\n\\n // Mapping of bidId to bid information.\\n mapping(uint256 => Bid) public bids;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => uint256[]) public borrowerBids;\\n\\n // Mapping of volume filled by lenders.\\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\\n\\n // Volume filled by all lenders.\\n uint256 public __totalVolumeFilled; // DEPRECIATED\\n\\n // List of allowed lending tokens\\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\\n\\n IMarketRegistry public marketRegistry;\\n IReputationManager public reputationManager;\\n\\n // Mapping of borrowers to borrower requests.\\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\\n\\n mapping(uint256 => uint32) public bidDefaultDuration;\\n mapping(uint256 => uint32) public bidExpirationTime;\\n\\n // Mapping of volume filled by lenders.\\n // Asset address => Lender address => Volume amount\\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\\n\\n // Volume filled by all lenders.\\n // Asset address => Volume amount\\n mapping(address => uint256) public totalVolumeFilled;\\n\\n uint256 public version;\\n\\n // Mapping of metadataURIs by bidIds.\\n // Bid Id => metadataURI string\\n mapping(uint256 => string) public uris;\\n}\\n\\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\\n // market ID => trusted forwarder\\n mapping(uint256 => address) internal _trustedMarketForwarders;\\n // trusted forwarder => set of pre-approved senders\\n mapping(address => EnumerableSet.AddressSet)\\n internal _approvedForwarderSenders;\\n}\\n\\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\\n address public lenderCommitmentForwarder;\\n}\\n\\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\\n ICollateralManager public collateralManager;\\n}\\n\\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\\n // Address of the lender manager contract\\n ILenderManager public lenderManager;\\n // BidId to payment cycle type (custom or monthly)\\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\\n}\\n\\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\\n\",\"keccak256\":\"0x45d89012d8fefcf203ae434d2780bc92f1d51f7a816b3c768a4591101644a1da\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\n// A representation of an empty/uninitialized UUID.\\nbytes32 constant EMPTY_UUID = 0;\\n\",\"keccak256\":\"0x2e4bcf4a965f840193af8729251386c1826cd050411ba4a9e85984a2551fd2ff\",\"license\":\"MIT\"},\"contracts/interfaces/IASRegistry.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASResolver.sol\\\";\\n\\n/**\\n * @title The global AS registry interface.\\n */\\ninterface IASRegistry {\\n /**\\n * @title A struct representing a record for a submitted AS (Attestation Schema).\\n */\\n struct ASRecord {\\n // A unique identifier of the AS.\\n bytes32 uuid;\\n // Optional schema resolver.\\n IASResolver resolver;\\n // Auto-incrementing index for reference, assigned by the registry itself.\\n uint256 index;\\n // Custom specification of the AS (e.g., an ABI).\\n bytes schema;\\n }\\n\\n /**\\n * @dev Triggered when a new AS has been registered\\n *\\n * @param uuid The AS UUID.\\n * @param index The AS index.\\n * @param schema The AS schema.\\n * @param resolver An optional AS schema resolver.\\n * @param attester The address of the account used to register the AS.\\n */\\n event Registered(\\n bytes32 indexed uuid,\\n uint256 indexed index,\\n bytes schema,\\n IASResolver resolver,\\n address attester\\n );\\n\\n /**\\n * @dev Submits and reserve a new AS\\n *\\n * @param schema The AS data schema.\\n * @param resolver An optional AS schema resolver.\\n *\\n * @return The UUID of the new AS.\\n */\\n function register(bytes calldata schema, IASResolver resolver)\\n external\\n returns (bytes32);\\n\\n /**\\n * @dev Returns an existing AS by UUID\\n *\\n * @param uuid The UUID of the AS to retrieve.\\n *\\n * @return The AS data members.\\n */\\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getASCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x74752921f592df45c8717d7084627e823b1dbc93bad7187cd3023c9690df7e60\",\"license\":\"MIT\"},\"contracts/interfaces/IASResolver.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title The interface of an optional AS resolver.\\n */\\ninterface IASResolver {\\n /**\\n * @dev Returns whether the resolver supports ETH transfers\\n */\\n function isPayable() external pure returns (bool);\\n\\n /**\\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The AS data schema.\\n * @param data The actual attestation data.\\n * @param expirationTime The expiration time of the attestation.\\n * @param msgSender The sender of the original attestation message.\\n *\\n * @return Whether the data is valid according to the scheme.\\n */\\n function resolve(\\n address recipient,\\n bytes calldata schema,\\n bytes calldata data,\\n uint256 expirationTime,\\n address msgSender\\n ) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0xfce671ea099d9f997a69c3447eb4a9c9693d37c5b97e43ada376e614e1c7cb61\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralManager.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ICollateralManager {\\n /**\\n * @notice Checks the validity of a borrower's collateral balance.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n /**\\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\\n * @param _bidId The id of the associated bid.\\n * @param _collateralInfo Additional information about the collateral asset.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function commitCollateral(\\n uint256 _bidId,\\n Collateral calldata _collateralInfo\\n ) external returns (bool validation_);\\n\\n function checkBalances(\\n address _borrowerAddress,\\n Collateral[] calldata _collateralInfo\\n ) external returns (bool validated_, bool[] memory checks_);\\n\\n /**\\n * @notice Deploys a new collateral escrow.\\n * @param _bidId The associated bidId of the collateral escrow.\\n */\\n function deployAndDeposit(uint256 _bidId) external;\\n\\n /**\\n * @notice Gets the address of a deployed escrow.\\n * @notice _bidId The bidId to return the escrow for.\\n * @return The address of the escrow.\\n */\\n function getEscrow(uint256 _bidId) external view returns (address);\\n\\n /**\\n * @notice Gets the collateral info for a given bid id.\\n * @param _bidId The bidId to return the collateral info for.\\n * @return The stored collateral info.\\n */\\n function getCollateralInfo(uint256 _bidId)\\n external\\n view\\n returns (Collateral[] memory);\\n\\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\\n external\\n view\\n returns (uint256 _amount);\\n\\n /**\\n * @notice Withdraws deposited collateral from the created escrow of a bid.\\n * @param _bidId The id of the bid to withdraw collateral for.\\n */\\n function withdraw(uint256 _bidId) external;\\n\\n /**\\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\\n * @param _bidId The id of the associated bid.\\n * @return validation_ Boolean indicating if the collateral balance was validated.\\n */\\n function revalidateCollateral(uint256 _bidId) external returns (bool);\\n\\n /**\\n * @notice Sends the deposited collateral to a liquidator of a bid.\\n * @notice Can only be called by the protocol.\\n * @param _bidId The id of the liquidated bid.\\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\\n */\\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\\n external;\\n}\\n\",\"keccak256\":\"0x27778a3446cdbfed6356d5047f9926231261b37def2712a3cc63e3779350e5e4\"},\"contracts/interfaces/IEAS.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n// SPDX-License-Identifier: MIT\\n\\nimport \\\"./IASRegistry.sol\\\";\\nimport \\\"./IEASEIP712Verifier.sol\\\";\\n\\n/**\\n * @title EAS - Ethereum Attestation Service interface\\n */\\ninterface IEAS {\\n /**\\n * @dev A struct representing a single attestation.\\n */\\n struct Attestation {\\n // A unique identifier of the attestation.\\n bytes32 uuid;\\n // A unique identifier of the AS.\\n bytes32 schema;\\n // The recipient of the attestation.\\n address recipient;\\n // The attester/sender of the attestation.\\n address attester;\\n // The time when the attestation was created (Unix timestamp).\\n uint256 time;\\n // The time when the attestation expires (Unix timestamp).\\n uint256 expirationTime;\\n // The time when the attestation was revoked (Unix timestamp).\\n uint256 revocationTime;\\n // The UUID of the related attestation.\\n bytes32 refUUID;\\n // Custom attestation data.\\n bytes data;\\n }\\n\\n /**\\n * @dev Triggered when an attestation has been made.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param uuid The UUID the revoked attestation.\\n * @param schema The UUID of the AS.\\n */\\n event Attested(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Triggered when an attestation has been revoked.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param uuid The UUID the revoked attestation.\\n */\\n event Revoked(\\n address indexed recipient,\\n address indexed attester,\\n bytes32 uuid,\\n bytes32 indexed schema\\n );\\n\\n /**\\n * @dev Returns the address of the AS global registry.\\n *\\n * @return The address of the AS global registry.\\n */\\n function getASRegistry() external view returns (IASRegistry);\\n\\n /**\\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\\n *\\n * @return The address of the EIP712 verifier used to verify signed attestations.\\n */\\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\\n\\n /**\\n * @dev Returns the global counter for the total number of attestations.\\n *\\n * @return The global counter for the total number of attestations.\\n */\\n function getAttestationsCount() external view returns (uint256);\\n\\n /**\\n * @dev Attests to a specific AS.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n *\\n * @return The UUID of the new attestation.\\n */\\n function attestByDelegation(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable returns (bytes32);\\n\\n /**\\n * @dev Revokes an existing attestation to a specific AS.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n */\\n function revoke(bytes32 uuid) external;\\n\\n /**\\n * @dev Attests to a specific AS using a provided EIP712 signature.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revokeByDelegation(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns an existing attestation by UUID.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The attestation data members.\\n */\\n function getAttestation(bytes32 uuid)\\n external\\n view\\n returns (Attestation memory);\\n\\n /**\\n * @dev Checks whether an attestation exists.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation exists.\\n */\\n function isAttestationValid(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Checks whether an attestation is active.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return Whether an attestation is active.\\n */\\n function isAttestationActive(bytes32 uuid) external view returns (bool);\\n\\n /**\\n * @dev Returns all received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getReceivedAttestationUUIDs(\\n address recipient,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of received attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all sent attestation UUIDs.\\n *\\n * @param attester The attesting account.\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSentAttestationUUIDs(\\n address attester,\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of sent attestation UUIDs.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all attestations related to a specific attestation.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getRelatedAttestationUUIDs(\\n bytes32 uuid,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of related attestation UUIDs.\\n *\\n * @param uuid The UUID of the attestation to retrieve.\\n *\\n * @return The number of related attestations.\\n */\\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns all per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n * @param start The offset to start from.\\n * @param length The number of total members to retrieve.\\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\\n *\\n * @return An array of attestation UUIDs.\\n */\\n function getSchemaAttestationUUIDs(\\n bytes32 schema,\\n uint256 start,\\n uint256 length,\\n bool reverseOrder\\n ) external view returns (bytes32[] memory);\\n\\n /**\\n * @dev Returns the number of per-schema attestation UUIDs.\\n *\\n * @param schema The UUID of the AS.\\n *\\n * @return The number of attestations.\\n */\\n function getSchemaAttestationUUIDsCount(bytes32 schema)\\n external\\n view\\n returns (uint256);\\n}\\n\",\"keccak256\":\"0x5db90829269f806ed14a6c638f38d4aac1fa0f85829b34a2fcddd5200261c148\",\"license\":\"MIT\"},\"contracts/interfaces/IEASEIP712Verifier.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n/**\\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\\n */\\ninterface IEASEIP712Verifier {\\n /**\\n * @dev Returns the current nonce per-account.\\n *\\n * @param account The requested accunt.\\n *\\n * @return The current nonce.\\n */\\n function getNonce(address account) external view returns (uint256);\\n\\n /**\\n * @dev Verifies signed attestation.\\n *\\n * @param recipient The recipient of the attestation.\\n * @param schema The UUID of the AS.\\n * @param expirationTime The expiration time of the attestation.\\n * @param refUUID An optional related attestation's UUID.\\n * @param data Additional custom data.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function attest(\\n address recipient,\\n bytes32 schema,\\n uint256 expirationTime,\\n bytes32 refUUID,\\n bytes calldata data,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Verifies signed revocations.\\n *\\n * @param uuid The UUID of the attestation to revoke.\\n * @param attester The attesting account.\\n * @param v The recovery ID.\\n * @param r The x-coordinate of the nonce R.\\n * @param s The signature data.\\n */\\n function revoke(\\n bytes32 uuid,\\n address attester,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\",\"keccak256\":\"0xeca3ac3bacec52af15b2c86c5bf1a1be315aade51fa86f95da2b426b28486b1e\",\"license\":\"MIT\"},\"contracts/interfaces/ILenderManager.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\\\";\\n\\nabstract contract ILenderManager is IERC721Upgradeable {\\n /**\\n * @notice Registers a new active lender for a loan, minting the nft.\\n * @param _bidId The id for the loan to set.\\n * @param _newLender The address of the new active lender.\\n */\\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\\n}\\n\",\"keccak256\":\"0xceb1ea2ef4c6e2ad7986db84de49c959e8d59844563d27daca5b8d78b732a8f7\",\"license\":\"MIT\"},\"contracts/interfaces/IMarketRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"../EAS/TellerAS.sol\\\";\\nimport { PaymentType, PaymentCycleType } from \\\"../libraries/V2Calculations.sol\\\";\\n\\ninterface IMarketRegistry {\\n function initialize(TellerAS tellerAs) external;\\n\\n function isVerifiedLender(uint256 _marketId, address _lender)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function isMarketClosed(uint256 _marketId) external view returns (bool);\\n\\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\\n external\\n view\\n returns (bool, bytes32);\\n\\n function getMarketOwner(uint256 _marketId) external view returns (address);\\n\\n function getMarketFeeRecipient(uint256 _marketId)\\n external\\n view\\n returns (address);\\n\\n function getMarketURI(uint256 _marketId)\\n external\\n view\\n returns (string memory);\\n\\n function getPaymentCycle(uint256 _marketId)\\n external\\n view\\n returns (uint32, PaymentCycleType);\\n\\n function getPaymentDefaultDuration(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getBidExpirationTime(uint256 _marketId)\\n external\\n view\\n returns (uint32);\\n\\n function getMarketplaceFee(uint256 _marketId)\\n external\\n view\\n returns (uint16);\\n\\n function getPaymentType(uint256 _marketId)\\n external\\n view\\n returns (PaymentType);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n PaymentType _paymentType,\\n PaymentCycleType _paymentCycleType,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n\\n function createMarket(\\n address _initialOwner,\\n uint32 _paymentCycleDuration,\\n uint32 _paymentDefaultDuration,\\n uint32 _bidExpirationTime,\\n uint16 _feePercent,\\n bool _requireLenderAttestation,\\n bool _requireBorrowerAttestation,\\n string calldata _uri\\n ) external returns (uint256 marketId_);\\n}\\n\",\"keccak256\":\"0x7209557aa8e3ddd81d0b863a8c063520a0011d96e1b3690a322f3371468f6dc6\",\"license\":\"MIT\"},\"contracts/interfaces/IReputationManager.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nenum RepMark {\\n Good,\\n Delinquent,\\n Default\\n}\\n\\ninterface IReputationManager {\\n function initialize(address protocolAddress) external;\\n\\n function getDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getDefaultedLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDelinquentLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function getCurrentDefaultLoanIds(address _account)\\n external\\n returns (uint256[] memory);\\n\\n function updateAccountReputation(address _account) external;\\n\\n function updateAccountReputation(address _account, uint256 _bidId)\\n external\\n returns (RepMark);\\n}\\n\",\"keccak256\":\"0x8d6e50fd460912231e53135b4459aa2f6f16007ae8deb32bc2cee1e88311a8d8\",\"license\":\"MIT\"},\"contracts/interfaces/ITellerV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport { Payment, BidState } from \\\"../TellerV2Storage.sol\\\";\\nimport { Collateral } from \\\"./escrow/ICollateralEscrowV1.sol\\\";\\n\\ninterface ITellerV2 {\\n /**\\n * @notice Function for a borrower to create a bid for a loan.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a borrower to create a bid for a loan with Collateral.\\n * @param _lendingToken The lending token asset requested to be borrowed.\\n * @param _marketplaceId The unique id of the marketplace for the bid.\\n * @param _principal The principal amount of the loan bid.\\n * @param _duration The recurrent length of time before which a payment is due.\\n * @param _APR The proposed interest rate for the loan bid.\\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\\n * @param _receiver The address where the loan amount will be sent to.\\n * @param _collateralInfo Additional information about the collateral asset.\\n */\\n function submitBid(\\n address _lendingToken,\\n uint256 _marketplaceId,\\n uint256 _principal,\\n uint32 _duration,\\n uint16 _APR,\\n string calldata _metadataURI,\\n address _receiver,\\n Collateral[] calldata _collateralInfo\\n ) external returns (uint256 bidId_);\\n\\n /**\\n * @notice Function for a lender to accept a proposed loan bid.\\n * @param _bidId The id of the loan bid to accept.\\n */\\n function lenderAcceptBid(uint256 _bidId)\\n external\\n returns (\\n uint256 amountToProtocol,\\n uint256 amountToMarketplace,\\n uint256 amountToBorrower\\n );\\n\\n function calculateAmountDue(uint256 _bidId)\\n external\\n view\\n returns (Payment memory due);\\n\\n /**\\n * @notice Function for users to make the minimum amount due for an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanMinimum(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to repay an active loan in full.\\n * @param _bidId The id of the loan to make the payment towards.\\n */\\n function repayLoanFull(uint256 _bidId) external;\\n\\n /**\\n * @notice Function for users to make a payment towards an active loan.\\n * @param _bidId The id of the loan to make the payment towards.\\n * @param _amount The amount of the payment.\\n */\\n function repayLoan(uint256 _bidId, uint256 _amount) external;\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isLoanLiquidateable(uint256 _bidId) external view returns (bool);\\n\\n /**\\n * @notice Checks to see if a borrower is delinquent.\\n * @param _bidId The id of the loan bid to check for.\\n */\\n function isPaymentLate(uint256 _bidId) external view returns (bool);\\n\\n function getBidState(uint256 _bidId) external view returns (BidState);\\n\\n function getBorrowerActiveLoanIds(address _borrower)\\n external\\n view\\n returns (uint256[] memory);\\n\\n /**\\n * @notice Returns the borrower address for a given bid.\\n * @param _bidId The id of the bid/loan to get the borrower for.\\n * @return borrower_ The address of the borrower associated with the bid.\\n */\\n function getLoanBorrower(uint256 _bidId)\\n external\\n view\\n returns (address borrower_);\\n\\n /**\\n * @notice Returns the lender address for a given bid.\\n * @param _bidId The id of the bid/loan to get the lender for.\\n * @return lender_ The address of the lender associated with the bid.\\n */\\n function getLoanLender(uint256 _bidId)\\n external\\n view\\n returns (address lender_);\\n\\n function getLoanLendingToken(uint256 _bidId)\\n external\\n view\\n returns (address token_);\\n\\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\\n\\n function getLoanSummary(uint256 _bidId)\\n external\\n view\\n returns (\\n address borrower,\\n address lender,\\n uint256 marketId,\\n address principalTokenAddress,\\n uint256 principalAmount,\\n uint32 acceptedTimestamp,\\n BidState bidState\\n );\\n}\\n\",\"keccak256\":\"0x2750d9717451e34323ef523810ff2a3a6285f146009955220d3860a7c4326077\",\"license\":\"MIT\"},\"contracts/interfaces/escrow/ICollateralEscrowV1.sol\":{\"content\":\"// SPDX-Licence-Identifier: MIT\\npragma solidity >=0.8.0 <0.9.0;\\n\\nenum CollateralType {\\n ERC20,\\n ERC721,\\n ERC1155\\n}\\n\\nstruct Collateral {\\n CollateralType _collateralType;\\n uint256 _amount;\\n uint256 _tokenId;\\n address _collateralAddress;\\n}\\n\\ninterface ICollateralEscrowV1 {\\n /**\\n * @notice Deposits a collateral ERC20 token into the escrow.\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositToken(address _collateralAddress, uint256 _amount) external;\\n\\n /**\\n * @notice Deposits a collateral asset into the escrow.\\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\\n * @param _collateralAddress The address of the collateral token.\\n * @param _amount The amount to deposit.\\n */\\n function depositAsset(\\n CollateralType _collateralType,\\n address _collateralAddress,\\n uint256 _amount,\\n uint256 _tokenId\\n ) external payable;\\n\\n /**\\n * @notice Withdraws a collateral asset from the escrow.\\n * @param _collateralAddress The address of the collateral contract.\\n * @param _amount The amount to withdraw.\\n * @param _recipient The address to send the assets to.\\n */\\n function withdraw(\\n address _collateralAddress,\\n uint256 _amount,\\n address _recipient\\n ) external;\\n\\n function getBid() external view returns (uint256);\\n\\n function initialize(uint256 _bidId) external;\\n}\\n\",\"keccak256\":\"0xefb7928c982f328c8df17f736b2c542df12f6c5b326933076faaae970ae49fa8\"},\"contracts/libraries/DateTimeLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.6.0 <0.9.0;\\n\\n// ----------------------------------------------------------------------------\\n// BokkyPooBah's DateTime Library v1.01\\n//\\n// A gas-efficient Solidity date and time library\\n//\\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\\n//\\n// Tested date range 1970/01/01 to 2345/12/31\\n//\\n// Conventions:\\n// Unit | Range | Notes\\n// :-------- |:-------------:|:-----\\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\\n// year | 1970 ... 2345 |\\n// month | 1 ... 12 |\\n// day | 1 ... 31 |\\n// hour | 0 ... 23 |\\n// minute | 0 ... 59 |\\n// second | 0 ... 59 |\\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\\n//\\n//\\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\\n// ----------------------------------------------------------------------------\\n\\nlibrary BokkyPooBahsDateTimeLibrary {\\n uint constant SECONDS_PER_DAY = 24 * 60 * 60;\\n uint constant SECONDS_PER_HOUR = 60 * 60;\\n uint constant SECONDS_PER_MINUTE = 60;\\n int constant OFFSET19700101 = 2440588;\\n\\n uint constant DOW_MON = 1;\\n uint constant DOW_TUE = 2;\\n uint constant DOW_WED = 3;\\n uint constant DOW_THU = 4;\\n uint constant DOW_FRI = 5;\\n uint constant DOW_SAT = 6;\\n uint constant DOW_SUN = 7;\\n\\n // ------------------------------------------------------------------------\\n // Calculate the number of days from 1970/01/01 to year/month/day using\\n // the date conversion algorithm from\\n // https://aa.usno.navy.mil/faq/JD_formula.html\\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\\n //\\n // days = day\\n // - 32075\\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\\n // - offset\\n // ------------------------------------------------------------------------\\n function _daysFromDate(uint year, uint month, uint day)\\n internal\\n pure\\n returns (uint _days)\\n {\\n require(year >= 1970);\\n int _year = int(year);\\n int _month = int(month);\\n int _day = int(day);\\n\\n int __days = _day -\\n 32075 +\\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\\n 4 +\\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\\n 12 -\\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\\n 4 -\\n OFFSET19700101;\\n\\n _days = uint(__days);\\n }\\n\\n // ------------------------------------------------------------------------\\n // Calculate year/month/day from the number of days since 1970/01/01 using\\n // the date conversion algorithm from\\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\\n // and adding the offset 2440588 so that 1970/01/01 is day 0\\n //\\n // int L = days + 68569 + offset\\n // int N = 4 * L / 146097\\n // L = L - (146097 * N + 3) / 4\\n // year = 4000 * (L + 1) / 1461001\\n // L = L - 1461 * year / 4 + 31\\n // month = 80 * L / 2447\\n // dd = L - 2447 * month / 80\\n // L = month / 11\\n // month = month + 2 - 12 * L\\n // year = 100 * (N - 49) + year + L\\n // ------------------------------------------------------------------------\\n function _daysToDate(uint _days)\\n internal\\n pure\\n returns (uint year, uint month, uint day)\\n {\\n int __days = int(_days);\\n\\n int L = __days + 68569 + OFFSET19700101;\\n int N = (4 * L) / 146097;\\n L = L - (146097 * N + 3) / 4;\\n int _year = (4000 * (L + 1)) / 1461001;\\n L = L - (1461 * _year) / 4 + 31;\\n int _month = (80 * L) / 2447;\\n int _day = L - (2447 * _month) / 80;\\n L = _month / 11;\\n _month = _month + 2 - 12 * L;\\n _year = 100 * (N - 49) + _year + L;\\n\\n year = uint(_year);\\n month = uint(_month);\\n day = uint(_day);\\n }\\n\\n function timestampFromDate(uint year, uint month, uint day)\\n internal\\n pure\\n returns (uint timestamp)\\n {\\n timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;\\n }\\n\\n function timestampFromDateTime(\\n uint year,\\n uint month,\\n uint day,\\n uint hour,\\n uint minute,\\n uint second\\n ) internal pure returns (uint timestamp) {\\n timestamp =\\n _daysFromDate(year, month, day) *\\n SECONDS_PER_DAY +\\n hour *\\n SECONDS_PER_HOUR +\\n minute *\\n SECONDS_PER_MINUTE +\\n second;\\n }\\n\\n function timestampToDate(uint timestamp)\\n internal\\n pure\\n returns (uint year, uint month, uint day)\\n {\\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\\n }\\n\\n function timestampToDateTime(uint timestamp)\\n internal\\n pure\\n returns (\\n uint year,\\n uint month,\\n uint day,\\n uint hour,\\n uint minute,\\n uint second\\n )\\n {\\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\\n uint secs = timestamp % SECONDS_PER_DAY;\\n hour = secs / SECONDS_PER_HOUR;\\n secs = secs % SECONDS_PER_HOUR;\\n minute = secs / SECONDS_PER_MINUTE;\\n second = secs % SECONDS_PER_MINUTE;\\n }\\n\\n function isValidDate(uint year, uint month, uint day)\\n internal\\n pure\\n returns (bool valid)\\n {\\n if (year >= 1970 && month > 0 && month <= 12) {\\n uint daysInMonth = _getDaysInMonth(year, month);\\n if (day > 0 && day <= daysInMonth) {\\n valid = true;\\n }\\n }\\n }\\n\\n function isValidDateTime(\\n uint year,\\n uint month,\\n uint day,\\n uint hour,\\n uint minute,\\n uint second\\n ) internal pure returns (bool valid) {\\n if (isValidDate(year, month, day)) {\\n if (hour < 24 && minute < 60 && second < 60) {\\n valid = true;\\n }\\n }\\n }\\n\\n function isLeapYear(uint timestamp) internal pure returns (bool leapYear) {\\n (uint year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\\n leapYear = _isLeapYear(year);\\n }\\n\\n function _isLeapYear(uint year) internal pure returns (bool leapYear) {\\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\\n }\\n\\n function isWeekDay(uint timestamp) internal pure returns (bool weekDay) {\\n weekDay = getDayOfWeek(timestamp) <= DOW_FRI;\\n }\\n\\n function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) {\\n weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;\\n }\\n\\n function getDaysInMonth(uint timestamp)\\n internal\\n pure\\n returns (uint daysInMonth)\\n {\\n (uint year, uint month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\\n daysInMonth = _getDaysInMonth(year, month);\\n }\\n\\n function _getDaysInMonth(uint year, uint month)\\n internal\\n pure\\n returns (uint daysInMonth)\\n {\\n if (\\n month == 1 ||\\n month == 3 ||\\n month == 5 ||\\n month == 7 ||\\n month == 8 ||\\n month == 10 ||\\n month == 12\\n ) {\\n daysInMonth = 31;\\n } else if (month != 2) {\\n daysInMonth = 30;\\n } else {\\n daysInMonth = _isLeapYear(year) ? 29 : 28;\\n }\\n }\\n\\n // 1 = Monday, 7 = Sunday\\n function getDayOfWeek(uint timestamp)\\n internal\\n pure\\n returns (uint dayOfWeek)\\n {\\n uint _days = timestamp / SECONDS_PER_DAY;\\n dayOfWeek = ((_days + 3) % 7) + 1;\\n }\\n\\n function getYear(uint timestamp) internal pure returns (uint year) {\\n (year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\\n }\\n\\n function getMonth(uint timestamp) internal pure returns (uint month) {\\n (, month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\\n }\\n\\n function getDay(uint timestamp) internal pure returns (uint day) {\\n (, , day) = _daysToDate(timestamp / SECONDS_PER_DAY);\\n }\\n\\n function getHour(uint timestamp) internal pure returns (uint hour) {\\n uint secs = timestamp % SECONDS_PER_DAY;\\n hour = secs / SECONDS_PER_HOUR;\\n }\\n\\n function getMinute(uint timestamp) internal pure returns (uint minute) {\\n uint secs = timestamp % SECONDS_PER_HOUR;\\n minute = secs / SECONDS_PER_MINUTE;\\n }\\n\\n function getSecond(uint timestamp) internal pure returns (uint second) {\\n second = timestamp % SECONDS_PER_MINUTE;\\n }\\n\\n function addYears(uint timestamp, uint _years)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n (uint year, uint month, uint day) = _daysToDate(\\n timestamp / SECONDS_PER_DAY\\n );\\n year += _years;\\n uint daysInMonth = _getDaysInMonth(year, month);\\n if (day > daysInMonth) {\\n day = daysInMonth;\\n }\\n newTimestamp =\\n _daysFromDate(year, month, day) *\\n SECONDS_PER_DAY +\\n (timestamp % SECONDS_PER_DAY);\\n require(newTimestamp >= timestamp);\\n }\\n\\n function addMonths(uint timestamp, uint _months)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n (uint year, uint month, uint day) = _daysToDate(\\n timestamp / SECONDS_PER_DAY\\n );\\n month += _months;\\n year += (month - 1) / 12;\\n month = ((month - 1) % 12) + 1;\\n uint daysInMonth = _getDaysInMonth(year, month);\\n if (day > daysInMonth) {\\n day = daysInMonth;\\n }\\n newTimestamp =\\n _daysFromDate(year, month, day) *\\n SECONDS_PER_DAY +\\n (timestamp % SECONDS_PER_DAY);\\n require(newTimestamp >= timestamp);\\n }\\n\\n function addDays(uint timestamp, uint _days)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n newTimestamp = timestamp + _days * SECONDS_PER_DAY;\\n require(newTimestamp >= timestamp);\\n }\\n\\n function addHours(uint timestamp, uint _hours)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;\\n require(newTimestamp >= timestamp);\\n }\\n\\n function addMinutes(uint timestamp, uint _minutes)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;\\n require(newTimestamp >= timestamp);\\n }\\n\\n function addSeconds(uint timestamp, uint _seconds)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n newTimestamp = timestamp + _seconds;\\n require(newTimestamp >= timestamp);\\n }\\n\\n function subYears(uint timestamp, uint _years)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n (uint year, uint month, uint day) = _daysToDate(\\n timestamp / SECONDS_PER_DAY\\n );\\n year -= _years;\\n uint daysInMonth = _getDaysInMonth(year, month);\\n if (day > daysInMonth) {\\n day = daysInMonth;\\n }\\n newTimestamp =\\n _daysFromDate(year, month, day) *\\n SECONDS_PER_DAY +\\n (timestamp % SECONDS_PER_DAY);\\n require(newTimestamp <= timestamp);\\n }\\n\\n function subMonths(uint timestamp, uint _months)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n (uint year, uint month, uint day) = _daysToDate(\\n timestamp / SECONDS_PER_DAY\\n );\\n uint yearMonth = year * 12 + (month - 1) - _months;\\n year = yearMonth / 12;\\n month = (yearMonth % 12) + 1;\\n uint daysInMonth = _getDaysInMonth(year, month);\\n if (day > daysInMonth) {\\n day = daysInMonth;\\n }\\n newTimestamp =\\n _daysFromDate(year, month, day) *\\n SECONDS_PER_DAY +\\n (timestamp % SECONDS_PER_DAY);\\n require(newTimestamp <= timestamp);\\n }\\n\\n function subDays(uint timestamp, uint _days)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n newTimestamp = timestamp - _days * SECONDS_PER_DAY;\\n require(newTimestamp <= timestamp);\\n }\\n\\n function subHours(uint timestamp, uint _hours)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;\\n require(newTimestamp <= timestamp);\\n }\\n\\n function subMinutes(uint timestamp, uint _minutes)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;\\n require(newTimestamp <= timestamp);\\n }\\n\\n function subSeconds(uint timestamp, uint _seconds)\\n internal\\n pure\\n returns (uint newTimestamp)\\n {\\n newTimestamp = timestamp - _seconds;\\n require(newTimestamp <= timestamp);\\n }\\n\\n function diffYears(uint fromTimestamp, uint toTimestamp)\\n internal\\n pure\\n returns (uint _years)\\n {\\n require(fromTimestamp <= toTimestamp);\\n (uint fromYear, , ) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);\\n (uint toYear, , ) = _daysToDate(toTimestamp / SECONDS_PER_DAY);\\n _years = toYear - fromYear;\\n }\\n\\n function diffMonths(uint fromTimestamp, uint toTimestamp)\\n internal\\n pure\\n returns (uint _months)\\n {\\n require(fromTimestamp <= toTimestamp);\\n (uint fromYear, uint fromMonth, ) = _daysToDate(\\n fromTimestamp / SECONDS_PER_DAY\\n );\\n (uint toYear, uint toMonth, ) = _daysToDate(\\n toTimestamp / SECONDS_PER_DAY\\n );\\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\\n }\\n\\n function diffDays(uint fromTimestamp, uint toTimestamp)\\n internal\\n pure\\n returns (uint _days)\\n {\\n require(fromTimestamp <= toTimestamp);\\n _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;\\n }\\n\\n function diffHours(uint fromTimestamp, uint toTimestamp)\\n internal\\n pure\\n returns (uint _hours)\\n {\\n require(fromTimestamp <= toTimestamp);\\n _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;\\n }\\n\\n function diffMinutes(uint fromTimestamp, uint toTimestamp)\\n internal\\n pure\\n returns (uint _minutes)\\n {\\n require(fromTimestamp <= toTimestamp);\\n _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;\\n }\\n\\n function diffSeconds(uint fromTimestamp, uint toTimestamp)\\n internal\\n pure\\n returns (uint _seconds)\\n {\\n require(fromTimestamp <= toTimestamp);\\n _seconds = toTimestamp - fromTimestamp;\\n }\\n}\\n\",\"keccak256\":\"0xf194df8ea9946a5bb3300223629b7e4959c1f20bacba27b3dc5f6dd2a160147a\",\"license\":\"MIT\"},\"contracts/libraries/NumbersLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n// Libraries\\nimport { SafeCast } from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"./WadRayMath.sol\\\";\\n\\n/**\\n * @dev Utility library for uint256 numbers\\n *\\n * @author develop@teller.finance\\n */\\nlibrary NumbersLib {\\n using WadRayMath for uint256;\\n\\n /**\\n * @dev It represents 100% with 2 decimal places.\\n */\\n uint16 internal constant PCT_100 = 10000;\\n\\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\\n return 100 * (10**decimals);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\\n */\\n function percent(uint256 self, uint16 percentage)\\n internal\\n pure\\n returns (uint256)\\n {\\n return percent(self, percentage, 2);\\n }\\n\\n /**\\n * @notice Returns a percentage value of a number.\\n * @param self The number to get a percentage of.\\n * @param percentage The percentage value to calculate with.\\n * @param decimals The number of decimals the percentage value is in.\\n */\\n function percent(uint256 self, uint256 percentage, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n return (self * percentage) / percentFactor(decimals);\\n }\\n\\n /**\\n * @notice it returns the absolute number of a specified parameter\\n * @param self the number to be returned in it's absolute\\n * @return the absolute number\\n */\\n function abs(int256 self) internal pure returns (uint256) {\\n return self >= 0 ? uint256(self) : uint256(-1 * self);\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @dev Returned value is type uint16.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\\n */\\n function ratioOf(uint256 num1, uint256 num2)\\n internal\\n pure\\n returns (uint16)\\n {\\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\\n }\\n\\n /**\\n * @notice Returns a ratio percentage of {num1} to {num2}.\\n * @param num1 The number used to get the ratio for.\\n * @param num2 The number used to get the ratio from.\\n * @param decimals The number of decimals the percentage value is returned in.\\n * @return Ratio percentage value.\\n */\\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\\n internal\\n pure\\n returns (uint256)\\n {\\n if (num2 == 0) return 0;\\n return (num1 * percentFactor(decimals)) / num2;\\n }\\n\\n /**\\n * @notice Calculates the payment amount for a cycle duration.\\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\\n * @param principal The starting amount that is owed on the loan.\\n * @param loanDuration The length of the loan.\\n * @param cycleDuration The length of the loan's payment cycle.\\n * @param apr The annual percentage rate of the loan.\\n */\\n function pmt(\\n uint256 principal,\\n uint32 loanDuration,\\n uint32 cycleDuration,\\n uint16 apr,\\n uint256 daysInYear\\n ) internal pure returns (uint256) {\\n require(\\n loanDuration >= cycleDuration,\\n \\\"PMT: cycle duration < loan duration\\\"\\n );\\n if (apr == 0)\\n return\\n Math.mulDiv(\\n principal,\\n cycleDuration,\\n loanDuration,\\n Math.Rounding.Up\\n );\\n\\n // Number of payment cycles for the duration of the loan\\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\\n\\n uint256 one = WadRayMath.wad();\\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\\n daysInYear\\n );\\n uint256 exp = (one + r).wadPow(n);\\n uint256 numerator = principal.wadMul(r).wadMul(exp);\\n uint256 denominator = exp - one;\\n\\n return numerator.wadDiv(denominator);\\n }\\n}\\n\",\"keccak256\":\"0x78009ffb3737ab7615a1e38a26635d6c06b65b7b7959af46d6ef840d220e70cf\",\"license\":\"MIT\"},\"contracts/libraries/V2Calculations.sol\":{\"content\":\"pragma solidity >=0.8.0 <0.9.0;\\n\\n// SPDX-License-Identifier: MIT\\n\\n// Libraries\\nimport \\\"./NumbersLib.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { Bid } from \\\"../TellerV2Storage.sol\\\";\\n\\nenum PaymentType {\\n EMI,\\n Bullet\\n}\\n\\nenum PaymentCycleType {\\n Seconds,\\n Monthly\\n}\\n\\nlibrary V2Calculations {\\n using NumbersLib for uint256;\\n\\n /**\\n * @notice Returns the timestamp of the last payment made for a loan.\\n * @param _bid The loan bid struct to get the timestamp for.\\n */\\n function lastRepaidTimestamp(Bid storage _bid)\\n internal\\n view\\n returns (uint32)\\n {\\n return\\n _bid.loanDetails.lastRepaidTimestamp == 0\\n ? _bid.loanDetails.acceptedTimestamp\\n : _bid.loanDetails.lastRepaidTimestamp;\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan.\\n * @param _bid The loan bid struct to get the owed amount for.\\n * @param _timestamp The timestamp at which to get the owed amount at.\\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\\n */\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n // Total principal left to pay\\n return\\n calculateAmountOwed(\\n _bid,\\n lastRepaidTimestamp(_bid),\\n _timestamp,\\n _paymentCycleType\\n );\\n }\\n\\n function calculateAmountOwed(\\n Bid storage _bid,\\n uint256 _lastRepaidTimestamp,\\n uint256 _timestamp,\\n PaymentCycleType _paymentCycleType\\n )\\n internal\\n view\\n returns (\\n uint256 owedPrincipal_,\\n uint256 duePrincipal_,\\n uint256 interest_\\n )\\n {\\n owedPrincipal_ =\\n _bid.loanDetails.principal -\\n _bid.loanDetails.totalRepaid.principal;\\n\\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n\\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\\n\\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\\n int256 durationLeftOnLoan = int256(\\n uint256(_bid.loanDetails.loanDuration)\\n ) -\\n (int256(_timestamp) -\\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\\n bool isLastPaymentCycle = durationLeftOnLoan <\\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\\n\\n if (_bid.paymentType == PaymentType.Bullet) {\\n if (isLastPaymentCycle) {\\n duePrincipal_ = owedPrincipal_;\\n }\\n } else {\\n // Default to PaymentType.EMI\\n // Max payable amount in a cycle\\n // NOTE: the last cycle could have less than the calculated payment amount\\n uint256 maxCycleOwed = isLastPaymentCycle\\n ? owedPrincipal_ + interest_\\n : _bid.terms.paymentCycleAmount;\\n\\n // Calculate accrued amount due since last repayment\\n uint256 owedAmount = (maxCycleOwed * owedTime) /\\n _bid.terms.paymentCycle;\\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\\n }\\n }\\n\\n /**\\n * @notice Calculates the amount owed for a loan for the next payment cycle.\\n * @param _type The payment type of the loan.\\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\\n * @param _principal The starting amount that is owed on the loan.\\n * @param _duration The length of the loan.\\n * @param _paymentCycle The length of the loan's payment cycle.\\n * @param _apr The annual percentage rate of the loan.\\n */\\n function calculatePaymentCycleAmount(\\n PaymentType _type,\\n PaymentCycleType _cycleType,\\n uint256 _principal,\\n uint32 _duration,\\n uint32 _paymentCycle,\\n uint16 _apr\\n ) internal returns (uint256) {\\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\\n ? 360 days\\n : 365 days;\\n if (_type == PaymentType.Bullet) {\\n return\\n _principal.percent(_apr).percent(\\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\\n 10\\n );\\n }\\n // Default to PaymentType.EMI\\n return\\n NumbersLib.pmt(\\n _principal,\\n _duration,\\n _paymentCycle,\\n _apr,\\n daysInYear\\n );\\n }\\n}\\n\",\"keccak256\":\"0xcb9f3cb8f8800aa321690418467da8dc40ff115b7697374e5c4364e4c7b2d759\",\"license\":\"MIT\"},\"contracts/libraries/WadRayMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\n/**\\n * @title WadRayMath library\\n * @author Multiplier Finance\\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\\n */\\nlibrary WadRayMath {\\n using SafeMath for uint256;\\n\\n uint256 internal constant WAD = 1e18;\\n uint256 internal constant halfWAD = WAD / 2;\\n\\n uint256 internal constant RAY = 1e27;\\n uint256 internal constant halfRAY = RAY / 2;\\n\\n uint256 internal constant WAD_RAY_RATIO = 1e9;\\n uint256 internal constant PCT_WAD_RATIO = 1e14;\\n uint256 internal constant PCT_RAY_RATIO = 1e23;\\n\\n function ray() internal pure returns (uint256) {\\n return RAY;\\n }\\n\\n function wad() internal pure returns (uint256) {\\n return WAD;\\n }\\n\\n function halfRay() internal pure returns (uint256) {\\n return halfRAY;\\n }\\n\\n function halfWad() internal pure returns (uint256) {\\n return halfWAD;\\n }\\n\\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfWAD.add(a.mul(b)).div(WAD);\\n }\\n\\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(WAD)).div(b);\\n }\\n\\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return halfRAY.add(a.mul(b)).div(RAY);\\n }\\n\\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 halfB = b / 2;\\n\\n return halfB.add(a.mul(RAY)).div(b);\\n }\\n\\n function rayToWad(uint256 a) internal pure returns (uint256) {\\n uint256 halfRatio = WAD_RAY_RATIO / 2;\\n\\n return halfRatio.add(a).div(WAD_RAY_RATIO);\\n }\\n\\n function rayToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_RAY_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToPct(uint256 a) internal pure returns (uint16) {\\n uint256 halfRatio = PCT_WAD_RATIO / 2;\\n\\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\\n return SafeCast.toUint16(val);\\n }\\n\\n function wadToRay(uint256 a) internal pure returns (uint256) {\\n return a.mul(WAD_RAY_RATIO);\\n }\\n\\n function pctToRay(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(RAY).div(1e4);\\n }\\n\\n function pctToWad(uint16 a) internal pure returns (uint256) {\\n return uint256(a).mul(WAD).div(1e4);\\n }\\n\\n /**\\n * @dev calculates base^duration. The code uses the ModExp precompile\\n * @return z base^duration, in ray\\n */\\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, RAY, rayMul);\\n }\\n\\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\\n return _pow(x, n, WAD, wadMul);\\n }\\n\\n function _pow(\\n uint256 x,\\n uint256 n,\\n uint256 p,\\n function(uint256, uint256) internal pure returns (uint256) mul\\n ) internal pure returns (uint256 z) {\\n z = n % 2 != 0 ? x : p;\\n\\n for (n /= 2; n != 0; n /= 2) {\\n x = mul(x, x);\\n\\n if (n % 2 != 0) {\\n z = mul(z, x);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2781319be7a96f56966c601c061849fa94dbf9af5ad80a20c40b879a8d03f14a\",\"license\":\"MIT\"}},\"version\":1}", "bytecode": "0x60a060405260006097553480156200001657600080fd5b5060405162005bc638038062005bc683398101604081905262000039916200004b565b6001600160a01b03166080526200007d565b6000602082840312156200005e57600080fd5b81516001600160a01b03811681146200007657600080fd5b9392505050565b608051615b26620000a06000396000818161080701526141020152615b266000f3fe608060405234801561001057600080fd5b50600436106103d05760003560e01c80636b868afb116101ff578063b0e21e8a1161011a578063dbf62489116100ad578063e8cbab091161007c578063e8cbab0914610b1d578063ecb96fe614610b30578063f2fde38b14610b43578063f93b6be514610b5657600080fd5b8063dbf6248914610a73578063e0d3d58d14610a7b578063e41c22f214610af7578063e4467f3514610b0a57600080fd5b8063bf77ffae116100e9578063bf77ffae14610a07578063d4eda4cf14610a3a578063d87569cc14610a4d578063d974cc5714610a6057600080fd5b8063b0e21e8a146109c2578063ba6d5b15146109d8578063ba971206146109eb578063bde644fb146109f457600080fd5b80638da5cb5b11610192578063a10905ea11610161578063a10905ea1461095b578063a51e2bad1461096e578063a8cb5d6814610981578063ab65ee95146109af57600080fd5b80638da5cb5b14610904578063930fbae1146109155780639703ef35146109355780639a11e3391461094857600080fd5b80637bbd53d7116101ce5780637bbd53d7146108c25780638288da8a146108d55780638a700b53146108e85780638ac47319146108fb57600080fd5b80636b868afb146108815780636c6ca79c14610894578063706a43c3146108a7578063715018a6146108ba57600080fd5b806323be345c116102ef5780634423c5f111610282578063572b6c0511610251578063572b6c05146107f75780635c975abb146108375780636aedfe68146108485780636b76c0851461085b57600080fd5b80634423c5f1146106ac5780634a06f6ea146107c857806354fd4d50146107db57806356a837f4146107e457600080fd5b80633819bcdc116102be5780633819bcdc146106335780633ef0a2f71461064657806340910c701461066f5780634148f94c1461069257600080fd5b806323be345c146105bd5780632519dc79146105d05780632e9332d4146105f0578063367358911461060357600080fd5b80631420a266116103675780631c960764116103365780631c9607641461057a5780631d123633146105845780631fff59d914610597578063206c54c7146105aa57600080fd5b80631420a266146104fb578063145730331461051057806318520f051461055457806319b353de1461056757600080fd5b80631042b85f116103a35780631042b85f1461046d578063106182231461048d5780631253c546146104a0578063127caa88146104c057600080fd5b8063054de0ff146103d557806306f33a92146103fe578063089487b51461041f578063093f56171461044a575b600080fd5b6103e86103e3366004614da6565b610b5e565b6040516103f59190614dc3565b60405180910390f35b61041161040c366004614e72565b610b88565b6040519081526020016103f5565b61041161042d366004614f14565b60a360209081526000928352604080842090915290825290205481565b61045d610458366004614f4d565b610baf565b60405190151581526020016103f5565b61048061047b366004614f66565b610c04565b6040516103f59190614f88565b61045d61049b366004614f4d565b610c9d565b6104b36104ae366004614f4d565b610d33565b6040516103f59190614ff7565b6104e66104ce366004614f4d565b60a26020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016103f5565b61050e61050936600461500a565b610dcd565b005b61053c61051e366004614f4d565b6000908152609860205260409020600501546001600160a01b031690565b6040516001600160a01b0390911681526020016103f5565b61050e610562366004614f4d565b610f29565b61045d61057536600461502f565b6110b3565b6104e66201518081565b6103e8610592366004614da6565b6110f2565b61045d6105a5366004614f4d565b61115e565b61050e6105b8366004614f4d565b61116d565b60aa5461053c906001600160a01b031681565b6104116105de366004614da6565b60a46020526000908152604090205481565b61050e6105fe36600461500a565b6112de565b610626610611366004614f4d565b60ac6020526000908152604090205460ff1681565b6040516103f59190615097565b6104116106413660046150aa565b6113c1565b61053c610654366004614f4d565b6000908152609860205260409020546001600160a01b031690565b61041161067d366004614f4d565b60009081526098602052604090206003015490565b61069a600981565b60405160ff90911681526020016103f5565b6107b36106ba366004614f4d565b60986020908152600091825260409182902080546001820154600283015460038401546004850154875160e08101895260058701546001600160a01b0390811682526006880154828a01528951808b018b52600789015481526008890154818b0152828b0152600988015463ffffffff808216606080860191909152600160201b80840483166080870152600160401b8404831660a0870152600160601b909304821660c08601528c519081018d52600a8b01548152600b8b01549182169b81019b909b520461ffff1699890199909952600c909601549488169793841696939092169490939192909160ff8082169161010090041689565b6040516103f5999897969594939291906150f3565b60ab5461053c906001600160a01b031681565b61041160a55481565b61050e6107f2366004614da6565b6113f2565b61045d610805366004614da6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b60655462010000900460ff1661045d565b610480610856366004614f66565b61141c565b6104e6610869366004614f4d565b60a16020526000908152604090205463ffffffff1681565b609f5461053c906001600160a01b031681565b6104806108a2366004614f4d565b6114b5565b6104e66108b5366004614f4d565b611535565b61050e611746565b6104116108d03660046151ec565b61175a565b61050e6108e3366004614f4d565b611875565b61050e6108f6366004614f66565b611a60565b61041160975481565b6033546001600160a01b031661053c565b610411610923366004614da6565b609a6020526000908152604090205481565b61050e610943366004614f4d565b611b7c565b61050e610956366004614f4d565b611c31565b61053c610969366004614f4d565b611cf7565b6104e661097c366004614f4d565b611da1565b61099461098f366004614f4d565b611db8565b604080519384526020840192909252908201526060016103f5565b61050e6109bd3660046152ec565b612449565b60655460405161ffff90911681526020016103f5565b60a95461053c906001600160a01b031681565b610411609b5481565b6104b3610a02366004614f4d565b612721565b610a2d610a15366004614f4d565b6000908152609860205260409020600c015460ff1690565b6040516103f5919061536e565b61050e610a48366004614f4d565b612830565b61045d610a5b36600461500a565b6128fb565b610480610a6e366004614f4d565b612935565b61050e6129b5565b610ae4610a89366004614f4d565b6000908152609860205260409020805460028201546003830154600584015460068501546009860154600c909601546001600160a01b0395861697948616969395909216939092600160201b900463ffffffff169160ff1690565b6040516103f5979695949392919061537c565b61050e610b05366004614da6565b6129cd565b61050e610b183660046153c3565b612a76565b61045d610b2b366004614f4d565b612ae0565b609e5461053c906001600160a01b031681565b61050e610b51366004614da6565b612aed565b61050e612b63565b6001600160a01b038116600090815260a060205260409020606090610b8290612b7b565b92915050565b6000610b92612b88565b610ba28989898989898989612bd4565b9998505050505050505050565b600060036000838152609860205260409020600c015460ff166005811115610bd957610bd9615071565b14610be657506000919050565b610bef82611535565b63ffffffff164263ffffffff16119050919050565b604080518082019091526000808252602082015260008381526098602052604090206003600c82015460ff166005811115610c4157610c41615071565b141580610c5f57506009810154600160201b900463ffffffff168311155b15610c6a5750610b82565b600084815260ac60205260408120548190610c8b908490879060ff16613242565b91865250602085015250505092915050565b60008181526098602052604081206001600c82015460ff166005811115610cc657610cc6615071565b14610cd45750600092915050565b600083815260a2602052604090205463ffffffff16610cf65750600092915050565b600083815260a260205260409020546009820154610d1d9163ffffffff90811691166153f6565b63ffffffff164263ffffffff1611915050919050565b60a66020526000908152604090208054610d4c9061541e565b80601f0160208091040260200160405190810160405280929190818152602001828054610d789061541e565b8015610dc55780601f10610d9a57610100808354040283529160200191610dc5565b820191906000526020600020905b815481529060010190602001808311610da857829003601f168201915b505050505081565b610dd5613270565b609e54604051633d36902960e01b8152600481018590526001600160a01b039283169290911690633d3690299060240160206040518083038186803b158015610e1d57600080fd5b505afa158015610e31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e559190615459565b6001600160a01b031614610eb05760405162461bcd60e51b815260206004820152601f60248201527f43616c6c6572206d75737420626520746865206d61726b6574206f776e65720060448201526064015b60405180910390fd5b600082815260a76020526040902080546001600160a01b0319166001600160a01b038316179055817fa593acf9edc343669c7fc50d2caa3911326adef438361f0fa911be85c9e296a482610f02613270565b604080516001600160a01b0393841681529290911660208301520160405180910390a25050565b60408051808201909152600c81526b18db185a5b531bd85b93919560a21b6020820152819060036000838152609860205260409020600c015460ff166005811115610f7657610f76615071565b14610f985781816040516347bc33cb60e11b8152600401610ea7929190615476565b610fa0612b88565b60008381526098602052604081206003810154909190610fbf9061327f565b60028301549091506001600160a01b038083169116146110215760405162461bcd60e51b815260206004820152601960248201527f6f6e6c79206c656e6465722063616e20636c61696d204e4654000000000000006044820152606401610ea7565b60ab5460405163096c998360e41b8152600481018790526001600160a01b038381166024830152909116906396c9983090604401600060405180830381600087803b15801561106f57600080fd5b505af1158015611083573d6000803e3d6000fd5b505060ab54600290940180546001600160a01b0319166001600160a01b0390951694909417909355505050505050565b60006110bf84846128fb565b80156110e857506001600160a01b038316600090815260a8602052604090206110e8908361332a565b90505b9392505050565b6001600160a01b03811660009081526099602090815260409182902080548351818402810184019094528084526060939283018282801561115257602002820191906000526020600020905b81548152602001906001019080831161113e575b50505050509050919050565b6000610b82826201518061334c565b609e5460008281526098602052604090819020600301549051633d36902960e01b81526001600160a01b0390921691633d369029916111b29160040190815260200190565b60206040518083038186803b1580156111ca57600080fd5b505afa1580156111de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112029190615459565b6001600160a01b0316611213613270565b6001600160a01b0316146112a7576040516347bc33cb60e11b8152600481018290526060602482015260146064820152731b585c9ad95d13dddb995c90d85b98d95b109a5960621b608482015260a06044820152602160a48201527f4f6e6c7920746865206d61726b6574206f776e65722063616e2063616e63656c60c4820152602160f81b60e482015261010401610ea7565b6112b0816133e8565b60405181907ff3f271d754f5264e0d143bf9be577d6eba153b0d833bd3a127d7b1a280bb13f190600090a250565b6112e882826128fb565b6113445760405162461bcd60e51b815260206004820152602760248201527f466f72776172646572206d757374206265207472757374656420627920746865604482015266081b585c9ad95d60ca1b6064820152608401610ea7565b61136d61134f613270565b6001600160a01b038316600090815260a8602052604090209061349c565b50806001600160a01b0316827f65d6b5305e8c0e58e88454a1aeecae0f55975222338b25abd0997b4d305056a16113a2613270565b6040516001600160a01b03909116815260200160405180910390a35050565b609960205281600052604060002081815481106113dd57600080fd5b90600052602060002001600091509150505481565b6113fa6134b1565b609f80546001600160a01b0319166001600160a01b0392909216919091179055565b604080518082018252600080825260208083018290528582526098905291909120600c81015460039060ff16600581111561145957611459615071565b14158061147757506009810154600160201b900463ffffffff168311155b156114825750610b82565b600084815260ac602052604081205481906114a3908490879060ff16613242565b90865260208601525050505092915050565b604080518082019091526000808252602082015260036000838152609860205260409020600c015460ff1660058111156114f1576114f1615071565b146114fb57919050565b600082815260986020908152604080832060ac909252822054829161152491429060ff16613242565b918552506020840152509092915050565b6000818152609860205260408120600c81015460039060ff16600581111561155f5761155f615071565b1461156a5750919050565b600061157584611da1565b90506001600085815260ac602052604090205460ff16600181111561159c5761159c615071565b141561163c5760098201546000906115c59063ffffffff600160201b909104811690841661352a565b60098401549091506115e390600160201b900463ffffffff166135b1565b6115f28363ffffffff166135b1565b111561160a576116036002826154c5565b9050611618565b6116156001826154c5565b90505b600983015461163490600160201b900463ffffffff16826135cb565b9350506116fc565b600084815260ac602052604081205460ff16600181111561165f5761165f615071565b14156116fc57600b82015460098301546116899163ffffffff90811691600160201b9004166153f6565b60098301549093506000906116ab90600160201b900463ffffffff16836154dd565b905063ffffffff8116156116fa57600b8301546000906116d49063ffffffff808516911661369d565b600b8501549091506116ec9063ffffffff1682615502565b6116f690866153f6565b9450505b505b60098201546000906117249063ffffffff600160601b8204811691600160201b9004166153f6565b90508063ffffffff168463ffffffff16111561173e578093505b505050919050565b61174e6134b1565b61175860006136d4565b565b6000611764612b88565b6117748b8b8b8b8b8b8b8b612bd4565b60aa54604051631532dc4560e01b81529192506000916001600160a01b0390911690631532dc45906117ae9085908890889060040161553b565b602060405180830381600087803b1580156117c857600080fd5b505af11580156117dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061180091906155dc565b90506001811515146118665760405162461bcd60e51b815260206004820152602960248201527f436f6c6c61746572616c2062616c616e636520636f756c64206e6f74206265206044820152681d985b1a59185d195960ba1b6064820152608401610ea7565b509a9950505050505050505050565b60408051808201909152600d81526c3634b8bab4b230ba32a637b0b760991b6020820152819060036000838152609860205260409020600c015460ff1660058111156118c3576118c3615071565b146118e55781816040516347bc33cb60e11b8152600401610ea7929190615476565b6118ee8361115e565b61193a5760405162461bcd60e51b815260206004820152601b60248201527f4c6f616e206d757374206265206c697175696461746561626c652e00000000006044820152606401610ea7565b600083815260986020908152604080832060ac9092528220549091908190611968908490429060ff16613242565b925050915061199986604051806040016040528085815260200184815250838561199291906154c5565b6000613726565b600c8301805460ff1916600517905560038301546000906119b99061327f565b60aa5460405163f0472c4960e01b8152600481018a90526001600160a01b03808416602483015292935091169063f0472c4990604401600060405180830381600087803b158015611a0957600080fd5b505af1158015611a1d573d6000803e3d6000fd5b50506040516001600160a01b03841692508991507f73de9acc561f27528ab0a3b5dd63fefb4e59f95575891299a6f862a78779817690600090a350505050505050565b6040805180820190915260098152683932b830bca637b0b760b91b6020820152829060036000838152609860205260409020600c015460ff166005811115611aaa57611aaa615071565b14611acc5781816040516347bc33cb60e11b8152600401610ea7929190615476565b600084815260986020908152604080832060ac90925282205482918291611af89190429060ff16613242565b919450925090506000611b0b82846154c5565b905080871015611b3e5760405162dd9d0f60e61b8152600481018990526024810188905260448101829052606401610ea7565b611b72886040518060400160405280858b611b5991906155f7565b8152602001859052611b6b85886154c5565b6001613726565b5050505050505050565b600081815260986020526040902080546003909101546001600160a01b0390911690611ba79061327f565b6001600160a01b031614611c25576040516347bc33cb60e11b81526004810182905260606024820152600960648201526818d85b98d95b109a5960ba1b608482015260a06044820152601e60a48201527f4f6e6c792074686520626964206f776e65722063616e2063616e63656c21000060c482015260e401610ea7565b611c2e816133e8565b50565b6040805180820190915260098152683932b830bca637b0b760b91b6020820152819060036000838152609860205260409020600c015460ff166005811115611c7b57611c7b615071565b14611c9d5781816040516347bc33cb60e11b8152600401610ea7929190615476565b600083815260986020908152604080832060ac9092528220548291611cc691429060ff16613242565b9250509150611cf0856040518060400160405280858152602001848152508385611b6b91906154c5565b5050505050565b60008181526098602052604090206002015460ab546001600160a01b039182169116811415611d9c5760ab546040516331a9108f60e11b8152600481018490526001600160a01b0390911690636352211e9060240160206040518083038186803b158015611d6457600080fd5b505afa158015611d78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b829190615459565b919050565b6000818152609860205260408120610b8290613a0d565b6000806000836040518060400160405280600f81526020016e1b195b99195c9058d8d95c1d109a59608a1b81525060016005811115611df957611df9615071565b6000838152609860205260409020600c015460ff166005811115611e1f57611e1f615071565b14611e415781816040516347bc33cb60e11b8152600401610ea792919061560e565b611e49612b88565b60008681526098602052604081206003810154909190611e689061327f565b609e546003840154604051633ef19a9b60e01b815260048101919091526001600160a01b03808416602483015292935060009290911690633ef19a9b90604401604080518083038186803b158015611ebf57600080fd5b505afa158015611ed3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ef7919061565b565b50905080611f3d5760405162461bcd60e51b81526020600482015260136024820152722737ba103b32b934b334b2b2103632b73232b960691b6044820152606401610ea7565b609e546003840154604051631cc672df60e01b81526001600160a01b0390921691631cc672df91611f749160040190815260200190565b60206040518083038186803b158015611f8c57600080fd5b505afa158015611fa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc491906155dc565b156120045760405162461bcd60e51b815260206004820152601060248201526f13585c9ad95d081a5cc818db1bdcd95960821b6044820152606401610ea7565b61200d89610c9d565b1561204c5760405162461bcd60e51b815260206004820152600f60248201526e109a59081a185cc8195e1c1a5c9959608a1b6044820152606401610ea7565b6009830180546bffffffffffffffff000000001916600160201b4263ffffffff1690810263ffffffff60401b191691909117600160401b91909102179055600c830180546003919060ff191660018302179055506002830180546001600160a01b0319166001600160a01b038481169190911790915560aa546040516346f0b08b60e11b8152600481018c9052911690638de1611690602401600060405180830381600087803b1580156120ff57600080fd5b505af1158015612113573d6000803e3d6000fd5b5050505061213261212760655461ffff1690565b600685015490613a53565b609e54600385015460405163028ba63960e21b8152929a506121c0926001600160a01b0390921691630a2e98e4916121709160040190815260200190565b60206040518083038186803b15801561218857600080fd5b505afa15801561219c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121279190615687565b9650868884600501600101546121d691906155f7565b6121e091906155f7565b955061220e826121f86033546001600160a01b031690565b60058601546001600160a01b031691908b613a65565b609e5460038401546040516332209bcb60e11b81526122b19285926001600160a01b039091169163644137969161224b9160040190815260200190565b60206040518083038186803b15801561226357600080fd5b505afa158015612277573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229b9190615459565b60058601546001600160a01b031691908a613a65565b600183015460058401546122d4916001600160a01b039182169185911689613a65565b600683015460058401546001600160a01b03908116600090815260a360209081526040808320938716835292905290812080549091906123159084906154c5565b9091555050600683015460058401546001600160a01b0316600090815260a460205260408120805490919061234b9084906154c5565b909155505082546001600160a01b0316600090815260a060205260409020612373908a613ac5565b506040516001600160a01b038316908a907fde9d3bfa8771df6761c0afac2375c88c70a3aa30478e1bd15363294033b470ed90600090a3604051671c1c9bdd1bd8dbdb60c21b81528890600801604051908190038120908b907f476a21a61ac4a7da250e040733aa10facd2eeee584b2c009d178c3de3d8a12dc90600090a46040516a6d61726b6574706c61636560a81b81528790600b01604051908190038120908b907f476a21a61ac4a7da250e040733aa10facd2eeee584b2c009d178c3de3d8a12dc90600090a450505050509193909250565b600054610100900460ff16158080156124695750600054600160ff909116105b806124835750303b158015612483575060005460ff166001145b61249f5760405162461bcd60e51b8152600401610ea7906156a4565b6000805460ff1916600117905580156124c2576000805461ff0019166101001790555b6124cb87613ad1565b6124d3613b09565b6001600160a01b0384163b61253f5760405162461bcd60e51b815260206004820152602c60248201527f4c656e646572436f6d6d69746d656e74466f72776172646572206d757374206260448201526b1948184818dbdb9d1c9858dd60a21b6064820152608401610ea7565b60a980546001600160a01b0319166001600160a01b038681169190911790915586163b6125b85760405162461bcd60e51b815260206004820152602160248201527f4d61726b65745265676973747279206d757374206265206120636f6e747261636044820152601d60fa1b6064820152608401610ea7565b609e80546001600160a01b0319166001600160a01b038881169190911790915585163b6126335760405162461bcd60e51b8152602060048201526024808201527f52657075746174696f6e4d616e61676572206d757374206265206120636f6e746044820152631c9858dd60e21b6064820152608401610ea7565b609f80546001600160a01b0319166001600160a01b038781169190911790915583163b6126ae5760405162461bcd60e51b8152602060048201526024808201527f436f6c6c61746572616c4d616e61676572206d757374206265206120636f6e746044820152631c9858dd60e21b6064820152608401610ea7565b60aa80546001600160a01b0319166001600160a01b0385161790556126d282613b38565b8015612718576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b600081815260a66020526040902080546060919061273e9061541e565b80601f016020809104026020016040519081016040528092919081815260200182805461276a9061541e565b80156127b75780601f1061278c576101008083540402835291602001916127b7565b820191906000526020600020905b81548152906001019060200180831161279a57829003601f168201915b50505050509050806040516020016127cf91906156f2565b604051602081830303815290604052805190602001207fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b1415611d9c57600082815260986020908152604090912060040154906110eb908290613bd8565b6040805180820190915260098152683932b830bca637b0b760b91b6020820152819060036000838152609860205260409020600c015460ff16600581111561287a5761287a615071565b1461289c5781816040516347bc33cb60e11b8152600401610ea7929190615476565b600083815260986020908152604080832060ac909252822054829182916128c89190429060ff16613242565b9250925092506128f3866040518060400160405280858152602001848152508386611b6b91906154c5565b505050505050565b600082815260a760205260408120546001600160a01b03838116911614806110eb57505060a9546001600160a01b03908116911614919050565b604080518082019091526000808252602082015260036000838152609860205260409020600c015460ff16600581111561297157612971615071565b1461297b57919050565b600082815260986020908152604080832060ac90925282205482916129a491429060ff16613242565b908552602085015250919392505050565b6129bd6134b1565b6129c5612b88565b611758613d74565b600054600890610100900460ff161580156129ef575060005460ff8083169116105b612a0b5760405162461bcd60e51b8152600401610ea7906156a4565b6000805461ffff191660ff831617610100179055612a276134b1565b612a3082613b38565b6000805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b612a7e6134b1565b60655461ffff82811691161415612a925750565b6065805461ffff83811661ffff198316811790935560408051938452911660208301819052917f4810ece076cee6c6042808956f3f65dad1bc72b75181341d7bed810d39deda0f9101612a6a565b6000610b8282600061334c565b612af56134b1565b6001600160a01b038116612b5a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610ea7565b611c2e816136d4565b612b6b6134b1565b612b73613dd3565b611758613e22565b606060006110eb83613e5f565b60655462010000900460ff16156117585760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610ea7565b600080612be08961327f565b609e5460405163066e751360e01b8152600481018c90526001600160a01b0380841660248301529293506000929091169063066e751390604401604080518083038186803b158015612c3157600080fd5b505afa158015612c45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c69919061565b565b50905080612cb15760405162461bcd60e51b81526020600482015260156024820152742737ba103b32b934b334b2b2103137b93937bbb2b960591b6044820152606401610ea7565b609e54604051631cc672df60e01b8152600481018c90526001600160a01b0390911690631cc672df9060240160206040518083038186803b158015612cf557600080fd5b505afa158015612d09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d2d91906155dc565b15612d6d5760405162461bcd60e51b815260206004820152601060248201526f13585c9ad95d081a5cc818db1bdcd95960821b6044820152606401610ea7565b609754600081815260986020526040902080546001600160a01b0319166001600160a01b03858116919091178255919450908516612db55780546001600160a01b0316612db7565b845b6001820180546001600160a01b03199081166001600160a01b0393841617909155600383018d90556005830180549091168e8316179055600682018b90556009820180546fffffffff0000000000000000ffffffff1916600160601b63ffffffff8d81169190910263ffffffff1916919091174291909116179055609e5460405163a5630f1960e01b8152600481018e905291169063a5630f1990602401604080518083038186803b158015612e6c57600080fd5b505afa158015612e80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea4919061571b565b609754600090815260ac602052604081208054600b86019291849160ff191660018381811115612ed657612ed6615071565b021790555081546101009190910a63ffffffff8181021990921694909116029290921790915550600b8101805465ffff000000001916600160201b61ffff8b1602179055609e546040516311bed5bb60e01b8152600481018d90526001600160a01b03909116906311bed5bb9060240160206040518083038186803b158015612f5e57600080fd5b505afa158015612f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f96919061574a565b609754600090815260a1602052604090819020805463ffffffff191663ffffffff9390931692909217909155609e54905163082fc54d60e01b8152600481018d90526001600160a01b039091169063082fc54d9060240160206040518083038186803b15801561300557600080fd5b505afa158015613019573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303d919061574a565b609754600090815260a2602052604090819020805463ffffffff191663ffffffff9390931692909217909155609e54905163d6e794dd60e01b8152600481018d90526001600160a01b039091169063d6e794dd9060240160206040518083038186803b1580156130ac57600080fd5b505afa1580156130c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e49190615767565b600c8201805461ff00191661010083600181111561310457613104615071565b0217905550600c810154609754600090815260ac6020526040902054600b8301546131469260ff61010090910481169216908d908d9063ffffffff168d613eb9565b600a820155609754600090815260a660205260409020613167908888614cf8565b50600c8101805460ff1916600117905560405161318a9088908890602001615784565b60408051808303601f19018152908290528051602091820120835460975460018601546001600160a01b0390811686529294929091169290917ff887b1f393f43fb94c5d50483df4bd410ffbf286128c5f24ff56c580ac7f731c910160405180910390a480546001600160a01b0316600090815260996020908152604082206097805482546001810184559285529284209091019190915580549161322e83615794565b919050555050505098975050505050505050565b60008060006132618661325488613a0d565b63ffffffff168787613f57565b92509250925093509350939050565b600061327a6140fe565b905090565b600061328d82610a5b613270565b156133225760131936013560601c6132ca8160a860006132ab613270565b6001600160a01b0316815260208101919091526040016000209061332a565b610b825760405162461bcd60e51b8152602060048201526024808201527f53656e646572206d75737420617070726f7665206d61726b657420666f727761604482015263393232b960e11b6064820152608401610ea7565b610b82613270565b6001600160a01b038116600090815260018301602052604081205415156110eb565b60008281526098602052604081206003600c82015460ff16600581111561337557613375615071565b14613384576000915050610b82565b600084815260a1602052604090205463ffffffff166133a7576000915050610b82565b600084815260a1602052604090205463ffffffff166133c585611da1565b6133cf85426154dd565b6133d991906154dd565b63ffffffff1611949350505050565b60408051808201909152600981526818d85b98d95b109a5960ba1b6020820152819060016000838152609860205260409020600c015460ff16600581111561343257613432615071565b146134545781816040516347bc33cb60e11b8152600401610ea792919061560e565b600083815260986020526040808220600c01805460ff191660021790555184917fa0633b09ac3029a6746aa27d4db1407f5f287a10c41a6b2ad2859f4da9b2680b91a2505050565b60006110eb836001600160a01b038416614143565b6134b9613270565b6001600160a01b03166134d46033546001600160a01b031690565b6001600160a01b0316146117585760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610ea7565b60008183111561353957600080fd5b60008061355161354c62015180876157c5565b614192565b50909250905060008061356a61354c62015180886157c5565b5090925090508261357c85600c6157d9565b8261358885600c6157d9565b61359291906154c5565b61359c91906155f7565b6135a691906155f7565b979650505050505050565b60006135c361354c62015180846157c5565b949350505050565b60008080806135e061354c62015180886157c5565b919450925090506135f185836154c5565b9150600c6136006001846155f7565b61360a91906157c5565b61361490846154c5565b9250600c6136236001846155f7565b61362d91906157f8565b6136389060016154c5565b915060006136468484614306565b905080821115613654578091505b61366162015180886157f8565b6201518061367086868661438c565b61367a91906157d9565b61368491906154c5565b94508685101561369357600080fd5b5050505092915050565b600082156136cb57816136b16001856155f7565b6136bb91906157c5565b6136c69060016154c5565b6110eb565b50600092915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000848152609860209081526040822090850151855191929161374991906154c5565b609f54835460405163c7312e4760e01b81526001600160a01b039182166004820152602481018a905292935060009291169063c7312e4790604401602060405180830381600087803b15801561379e57600080fd5b505af11580156137b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137d6919061580c565b90508482106138aa57600c8301805460ff1916600417905582546001600160a01b0316600090815260a06020526040902085925061381490886144c9565b50831561387a5760aa54604051632e1a7d4d60e01b8152600481018990526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b15801561386157600080fd5b505af1158015613875573d6000803e3d6000fd5b505050505b60405187907f9a7851747cd7ffb3fe0a32caf3da48b31f27cebe131267051640f8b72fc4718690600090a26138d6565b60405187907f68ca97895fe2d09eab47e752271728ade667e72dda27e68c20eaa191a9c2187d90600090a25b60006138e188611cf7565b90506139096138f3856003015461327f565b60058601546001600160a01b0316908386613a65565b865160078501805460009061391f9084906154c5565b9091555050602087015160088501805460009061393d9084906154c5565b909155505060098401805463ffffffff60401b1916600160401b4263ffffffff1602179055600082600281111561397657613976615071565b14611b7257609f54845460405163c7312e4760e01b81526001600160a01b039182166004820152602481018b905291169063c7312e4790604401602060405180830381600087803b1580156139ca57600080fd5b505af11580156139de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a02919061580c565b505050505050505050565b6009810154600090600160401b900463ffffffff1615613a3e576009820154600160401b900463ffffffff16610b82565b5060090154600160201b900463ffffffff1690565b60006110eb838361ffff1660026144d5565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052613abf9085906144f4565b50505050565b60006110eb8383614143565b600054610100900460ff16613af85760405162461bcd60e51b8152600401610ea790615829565b613b006145cb565b611c2e816145fa565b600054610100900460ff16613b305760405162461bcd60e51b8152600401610ea790615829565b61175861462a565b600054610100900460ff16613b5f5760405162461bcd60e51b8152600401610ea790615829565b6001600160a01b0381163b613bb65760405162461bcd60e51b815260206004820181905260248201527f4c656e6465724d616e61676572206d757374206265206120636f6e74726163746044820152606401610ea7565b60ab80546001600160a01b0319166001600160a01b0392909216919091179055565b60606000613be78360026157d9565b613bf29060026154c5565b67ffffffffffffffff811115613c0a57613c0a615874565b6040519080825280601f01601f191660200182016040528015613c34576020820181803683370190505b509050600360fc1b81600081518110613c4f57613c4f61588a565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613c7e57613c7e61588a565b60200101906001600160f81b031916908160001a9053506000613ca28460026157d9565b613cad9060016154c5565b90505b6001811115613d25576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613ce157613ce161588a565b1a60f81b828281518110613cf757613cf761588a565b60200101906001600160f81b031916908160001a90535060049490941c93613d1e816158a0565b9050613cb0565b5083156110eb5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610ea7565b613d7c612b88565b6065805462ff00001916620100001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613db6613270565b6040516001600160a01b03909116815260200160405180910390a1565b60655462010000900460ff166117585760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610ea7565b613e2a613dd3565b6065805462ff0000191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa613db6613270565b606081600001805480602002602001604051908101604052809291908181526020018280548015611152576020028201919060005260206000209081548152602001906001019080831161113e5750505050509050919050565b6000806001876001811115613ed057613ed0615071565b14613edf576301e13380613ee5565b6301da9c005b63ffffffff1690506001886001811115613f0157613f01615071565b1415613f3c57613f34613f2163ffffffff808716908490600a9061465f16565b600a613f2d8987613a53565b91906144d5565b915050613f4d565b613f498686868685614682565b9150505b9695505050505050565b6007840154600685015460009182918291613f71916155f7565b925060006001856001811115613f8957613f89615071565b14613f98576301e13380613f9e565b6301da9c005b63ffffffff1690506000613fd089600a0160010160049054906101000a900461ffff1686613a5390919063ffffffff16565b90506000613fde89896155f7565b905082613feb82846157d9565b613ff591906157c5565b60098b015490945060009061401790600160201b900463ffffffff168a6158b7565b60098c01546140339190600160601b900463ffffffff166158b7565b600b8c015490915060009063ffffffff1682128061405e5750600a8c015461405b878a6154c5565b11155b90506001600c8d0154610100900460ff16600181111561408057614080615071565b1415614095578015614090578796505b6140ef565b6000816140a657600a8d01546140b0565b6140b0878a6154c5565b600b8e015490915060009063ffffffff166140cb86846157d9565b6140d591906157c5565b90506140ea6140e489836155f7565b8b6147b3565b985050505b50505050509450945094915050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633141561413e575060131936013560601c90565b503390565b600081815260018301602052604081205461418a57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b82565b506000610b82565b60008080838162253d8c6141a98362010bd96158f6565b6141b391906158f6565b9050600062023ab16141c6836004615937565b6141d091906159bc565b905060046141e18262023ab1615937565b6141ec9060036158f6565b6141f691906159bc565b61420090836158b7565b9150600062164b096142138460016158f6565b61421f90610fa0615937565b61422991906159bc565b90506004614239826105b5615937565b61424391906159bc565b61424d90846158b7565b61425890601f6158f6565b9250600061098f61426a856050615937565b61427491906159bc565b9050600060506142868361098f615937565b61429091906159bc565b61429a90866158b7565b90506142a7600b836159bc565b94506142b485600c615937565b6142bf8360026158f6565b6142c991906158b7565b915084836142d86031876158b7565b6142e3906064615937565b6142ed91906158f6565b6142f791906158f6565b9a919950975095505050505050565b600081600114806143175750816003145b806143225750816005145b8061432d5750816007145b806143385750816008145b80614343575081600a145b8061434e575081600c145b1561435b5750601f610b82565b8160021461436b5750601e610b82565b614374836147c9565b61437f57601c614382565b601d5b60ff169392505050565b60006107b284101561439d57600080fd5b838383600062253d8c60046064600c6143b7600e886158b7565b6143c191906159bc565b6143cd886113246158f6565b6143d791906158f6565b6143e191906159bc565b6143ec906003615937565b6143f691906159bc565b600c80614404600e886158b7565b61440e91906159bc565b61441990600c615937565b6144246002886158b7565b61442e91906158b7565b61443a9061016f615937565b61444491906159bc565b6004600c614453600e896158b7565b61445d91906159bc565b614469896112c06158f6565b61447391906158f6565b61447f906105b5615937565b61448991906159bc565b614495617d4b876158b7565b61449f91906158f6565b6144a991906158f6565b6144b391906158b7565b6144bd91906158b7565b98975050505050505050565b60006110eb8383614805565b60006144e0826148f8565b6144ea84866157d9565b6110e891906157c5565b6000614549826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166149109092919063ffffffff16565b8051909150156145c6578080602001905181019061456791906155dc565b6145c65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ea7565b505050565b600054610100900460ff166145f25760405162461bcd60e51b8152600401610ea790615829565b61175861491f565b600054610100900460ff166146215760405162461bcd60e51b8152600401610ea790615829565b611c2e81612a76565b600054610100900460ff166146515760405162461bcd60e51b8152600401610ea790615829565b6065805462ff000019169055565b60008261466e575060006110eb565b82614678836148f8565b6144ea90866157d9565b60008363ffffffff168563ffffffff1610156146ec5760405162461bcd60e51b815260206004820152602360248201527f504d543a206379636c65206475726174696f6e203c206c6f616e20647572617460448201526234b7b760e91b6064820152608401610ea7565b61ffff83166147155761470e868563ffffffff168763ffffffff166001614956565b90506147aa565b600061472d8663ffffffff168663ffffffff1661369d565b9050670de0b6b3a7640000600061475d8561475763ffffffff8a166147518a6149a7565b906149cb565b906149ff565b905060006147758461476f84866154c5565b90614a2f565b90506000614787826147518d866149cb565b9050600061479585846155f7565b90506147a182826149ff565b96505050505050505b95945050505050565b60008183106147c257816110eb565b5090919050565b60006147d66004836157f8565b1580156147ec57506147e96064836157f8565b15155b80610b8257506147fe610190836157f8565b1592915050565b600081815260018301602052604081205480156148ee5760006148296001836155f7565b855490915060009061483d906001906155f7565b90508181146148a257600086600001828154811061485d5761485d61588a565b90600052602060002001549050808760000184815481106148805761488061588a565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806148b3576148b36159ea565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b82565b6000915050610b82565b600061490582600a615ae4565b610b829060646157d9565b60606110e88484600085614a47565b600054610100900460ff166149465760405162461bcd60e51b8152600401610ea790615829565b611758614951613270565b6136d4565b600080614964868686614b17565b9050600183600281111561497a5761497a615071565b148015614997575060008480614992576149926157af565b868809115b156147aa57613f4d6001826154c5565b6000610b826127106149c561ffff8516670de0b6b3a7640000614bc7565b90614bd3565b60006110eb670de0b6b3a76400006149c56149e68686614bc7565b6149f96002670de0b6b3a76400006157c5565b90614bdf565b600080614a0d6002846157c5565b90506135c3836149c5614a2887670de0b6b3a7640000614bc7565b8490614bdf565b60006110eb8383670de0b6b3a76400006149cb614beb565b606082471015614aa85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ea7565b600080866001600160a01b03168587604051614ac491906156f2565b60006040518083038185875af1925050503d8060008114614b01576040519150601f19603f3d011682016040523d82523d6000602084013e614b06565b606091505b50915091506135a687838387614c5d565b600080806000198587098587029250828110838203039150508060001415614b5257838281614b4857614b486157af565b04925050506110eb565b808411614b5e57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b60006110eb82846157d9565b60006110eb82846157c5565b60006110eb82846154c5565b6000614bf86002856157f8565b614c025782614c04565b845b9050614c116002856157c5565b93505b83156135c357614c2885868463ffffffff16565b9450614c356002856157f8565b15614c4b57614c4881868463ffffffff16565b90505b614c566002856157c5565b9350614c14565b60608315614cc9578251614cc2576001600160a01b0385163b614cc25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ea7565b50816135c3565b6135c38383815115614cde5781518083602001fd5b8060405162461bcd60e51b8152600401610ea79190614ff7565b828054614d049061541e565b90600052602060002090601f016020900481019282614d265760008555614d6c565b82601f10614d3f5782800160ff19823516178555614d6c565b82800160010185558215614d6c579182015b82811115614d6c578235825591602001919060010190614d51565b50614d78929150614d7c565b5090565b5b80821115614d785760008155600101614d7d565b6001600160a01b0381168114611c2e57600080fd5b600060208284031215614db857600080fd5b81356110eb81614d91565b6020808252825182820181905260009190848201906040850190845b81811015614dfb57835183529284019291840191600101614ddf565b50909695505050505050565b63ffffffff81168114611c2e57600080fd5b61ffff81168114611c2e57600080fd5b60008083601f840112614e3b57600080fd5b50813567ffffffffffffffff811115614e5357600080fd5b602083019150836020828501011115614e6b57600080fd5b9250929050565b60008060008060008060008060e0898b031215614e8e57600080fd5b8835614e9981614d91565b975060208901359650604089013595506060890135614eb781614e07565b94506080890135614ec781614e19565b935060a089013567ffffffffffffffff811115614ee357600080fd5b614eef8b828c01614e29565b90945092505060c0890135614f0381614d91565b809150509295985092959890939650565b60008060408385031215614f2757600080fd5b8235614f3281614d91565b91506020830135614f4281614d91565b809150509250929050565b600060208284031215614f5f57600080fd5b5035919050565b60008060408385031215614f7957600080fd5b50508035926020909101359150565b815181526020808301519082015260408101610b82565b60005b83811015614fba578181015183820152602001614fa2565b83811115613abf5750506000910152565b60008151808452614fe3816020860160208601614f9f565b601f01601f19169290920160200192915050565b6020815260006110eb6020830184614fcb565b6000806040838503121561501d57600080fd5b823591506020830135614f4281614d91565b60008060006060848603121561504457600080fd5b83359250602084013561505681614d91565b9150604084013561506681614d91565b809150509250925092565b634e487b7160e01b600052602160045260246000fd5b60028110611c2e57611c2e615071565b602081016150a483615087565b91905290565b600080604083850312156150bd57600080fd5b82356150c881614d91565b946020939093013593505050565b600681106150e6576150e6615071565b9052565b6150e681615087565b60006102408201905060018060a01b03808c168352808b166020840152808a1660408401528860608401528760808401528087511660a084015250602086015160c0830152604086015161515460e084018280518252602090810151910152565b50606086015163ffffffff9081166101208401526080870151811661014084015260a08701511661016083015260c086015161519961018084018263ffffffff169052565b5084516101a0830152602085015163ffffffff166101c0830152604085015161ffff166101e08301526151d06102008301856150d6565b6151de6102208301846150ea565b9a9950505050505050505050565b6000806000806000806000806000806101008b8d03121561520c57600080fd5b8a3561521781614d91565b995060208b0135985060408b0135975060608b013561523581614e07565b965060808b013561524581614e19565b955060a08b013567ffffffffffffffff8082111561526257600080fd5b61526e8e838f01614e29565b909750955060c08d0135915061528382614d91565b90935060e08c0135908082111561529957600080fd5b818d0191508d601f8301126152ad57600080fd5b8135818111156152bc57600080fd5b8e60208260071b85010111156152d157600080fd5b6020830194508093505050509295989b9194979a5092959850565b60008060008060008060c0878903121561530557600080fd5b863561531081614e19565b9550602087013561532081614d91565b9450604087013561533081614d91565b9350606087013561534081614d91565b9250608087013561535081614d91565b915060a087013561536081614d91565b809150509295509295509295565b60208101610b8282846150d6565b6001600160a01b038881168252878116602083015260408201879052851660608201526080810184905263ffffffff831660a082015260e081016144bd60c08301846150d6565b6000602082840312156153d557600080fd5b81356110eb81614e19565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff808316818516808303821115615415576154156153e0565b01949350505050565b600181811c9082168061543257607f821691505b6020821081141561545357634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561546b57600080fd5b81516110eb81614d91565b82815260606020820152600061548f6060830184614fcb565b8281036040938401526015815274131bd85b881b5d5cdd081899481858d8d95c1d1959605a1b6020820152919091019392505050565b600082198211156154d8576154d86153e0565b500190565b600063ffffffff838116908316818110156154fa576154fa6153e0565b039392505050565b600063ffffffff80831681851681830481118215151615615525576155256153e0565b02949350505050565b60038110611c2e57600080fd5b838152604060208083018290528282018490526000919060609081850187855b888110156155bd57813561556e8161552e565b6003811061557e5761557e615071565b8352818401358484015285820135868401528482013561559d81614d91565b6001600160a01b031683860152608092830192919091019060010161555b565b50909998505050505050505050565b80518015158114611d9c57600080fd5b6000602082840312156155ee57600080fd5b6110eb826155cc565b600082821015615609576156096153e0565b500390565b8281526060602082015260006156276060830184614fcb565b8281036040938401526013815272426964206d7573742062652070656e64696e6760681b6020820152919091019392505050565b6000806040838503121561566e57600080fd5b615677836155cc565b9150602083015190509250929050565b60006020828403121561569957600080fd5b81516110eb81614e19565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60008251615704818460208701614f9f565b9190910192915050565b60028110611c2e57600080fd5b6000806040838503121561572e57600080fd5b825161573981614e07565b6020840151909250614f428161570e565b60006020828403121561575c57600080fd5b81516110eb81614e07565b60006020828403121561577957600080fd5b81516110eb8161570e565b8183823760009101908152919050565b60006000198214156157a8576157a86153e0565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826157d4576157d46157af565b500490565b60008160001904831182151516156157f3576157f36153e0565b500290565b600082615807576158076157af565b500690565b60006020828403121561581e57600080fd5b81516110eb8161552e565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000816158af576158af6153e0565b506000190190565b60008083128015600160ff1b8501841216156158d5576158d56153e0565b6001600160ff1b03840183138116156158f0576158f06153e0565b50500390565b600080821280156001600160ff1b0384900385131615615918576159186153e0565b600160ff1b8390038412811615615931576159316153e0565b50500190565b60006001600160ff1b038184138284138082168684048611161561595d5761595d6153e0565b600160ff1b600087128281168783058912161561597c5761597c6153e0565b60008712925087820587128484161615615998576159986153e0565b878505871281841616156159ae576159ae6153e0565b505050929093029392505050565b6000826159cb576159cb6157af565b600160ff1b8214600019841416156159e5576159e56153e0565b500590565b634e487b7160e01b600052603160045260246000fd5b600181815b80851115615a3b578160001904821115615a2157615a216153e0565b80851615615a2e57918102915b93841c9390800290615a05565b509250929050565b600082615a5257506001610b82565b81615a5f57506000610b82565b8160018114615a755760028114615a7f57615a9b565b6001915050610b82565b60ff841115615a9057615a906153e0565b50506001821b610b82565b5060208310610133831016604e8410600b8410161715615abe575081810a610b82565b615ac88383615a00565b8060001904821115615adc57615adc6153e0565b029392505050565b60006110eb8383615a4356fea2646970667358221220601d7ad2dd26562b57f361d813bcf96b18591a58e63db1b5a719ee8be9c1d1d064736f6c63430008090033", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103d05760003560e01c80636b868afb116101ff578063b0e21e8a1161011a578063dbf62489116100ad578063e8cbab091161007c578063e8cbab0914610b1d578063ecb96fe614610b30578063f2fde38b14610b43578063f93b6be514610b5657600080fd5b8063dbf6248914610a73578063e0d3d58d14610a7b578063e41c22f214610af7578063e4467f3514610b0a57600080fd5b8063bf77ffae116100e9578063bf77ffae14610a07578063d4eda4cf14610a3a578063d87569cc14610a4d578063d974cc5714610a6057600080fd5b8063b0e21e8a146109c2578063ba6d5b15146109d8578063ba971206146109eb578063bde644fb146109f457600080fd5b80638da5cb5b11610192578063a10905ea11610161578063a10905ea1461095b578063a51e2bad1461096e578063a8cb5d6814610981578063ab65ee95146109af57600080fd5b80638da5cb5b14610904578063930fbae1146109155780639703ef35146109355780639a11e3391461094857600080fd5b80637bbd53d7116101ce5780637bbd53d7146108c25780638288da8a146108d55780638a700b53146108e85780638ac47319146108fb57600080fd5b80636b868afb146108815780636c6ca79c14610894578063706a43c3146108a7578063715018a6146108ba57600080fd5b806323be345c116102ef5780634423c5f111610282578063572b6c0511610251578063572b6c05146107f75780635c975abb146108375780636aedfe68146108485780636b76c0851461085b57600080fd5b80634423c5f1146106ac5780634a06f6ea146107c857806354fd4d50146107db57806356a837f4146107e457600080fd5b80633819bcdc116102be5780633819bcdc146106335780633ef0a2f71461064657806340910c701461066f5780634148f94c1461069257600080fd5b806323be345c146105bd5780632519dc79146105d05780632e9332d4146105f0578063367358911461060357600080fd5b80631420a266116103675780631c960764116103365780631c9607641461057a5780631d123633146105845780631fff59d914610597578063206c54c7146105aa57600080fd5b80631420a266146104fb578063145730331461051057806318520f051461055457806319b353de1461056757600080fd5b80631042b85f116103a35780631042b85f1461046d578063106182231461048d5780631253c546146104a0578063127caa88146104c057600080fd5b8063054de0ff146103d557806306f33a92146103fe578063089487b51461041f578063093f56171461044a575b600080fd5b6103e86103e3366004614da6565b610b5e565b6040516103f59190614dc3565b60405180910390f35b61041161040c366004614e72565b610b88565b6040519081526020016103f5565b61041161042d366004614f14565b60a360209081526000928352604080842090915290825290205481565b61045d610458366004614f4d565b610baf565b60405190151581526020016103f5565b61048061047b366004614f66565b610c04565b6040516103f59190614f88565b61045d61049b366004614f4d565b610c9d565b6104b36104ae366004614f4d565b610d33565b6040516103f59190614ff7565b6104e66104ce366004614f4d565b60a26020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016103f5565b61050e61050936600461500a565b610dcd565b005b61053c61051e366004614f4d565b6000908152609860205260409020600501546001600160a01b031690565b6040516001600160a01b0390911681526020016103f5565b61050e610562366004614f4d565b610f29565b61045d61057536600461502f565b6110b3565b6104e66201518081565b6103e8610592366004614da6565b6110f2565b61045d6105a5366004614f4d565b61115e565b61050e6105b8366004614f4d565b61116d565b60aa5461053c906001600160a01b031681565b6104116105de366004614da6565b60a46020526000908152604090205481565b61050e6105fe36600461500a565b6112de565b610626610611366004614f4d565b60ac6020526000908152604090205460ff1681565b6040516103f59190615097565b6104116106413660046150aa565b6113c1565b61053c610654366004614f4d565b6000908152609860205260409020546001600160a01b031690565b61041161067d366004614f4d565b60009081526098602052604090206003015490565b61069a600981565b60405160ff90911681526020016103f5565b6107b36106ba366004614f4d565b60986020908152600091825260409182902080546001820154600283015460038401546004850154875160e08101895260058701546001600160a01b0390811682526006880154828a01528951808b018b52600789015481526008890154818b0152828b0152600988015463ffffffff808216606080860191909152600160201b80840483166080870152600160401b8404831660a0870152600160601b909304821660c08601528c519081018d52600a8b01548152600b8b01549182169b81019b909b520461ffff1699890199909952600c909601549488169793841696939092169490939192909160ff8082169161010090041689565b6040516103f5999897969594939291906150f3565b60ab5461053c906001600160a01b031681565b61041160a55481565b61050e6107f2366004614da6565b6113f2565b61045d610805366004614da6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b60655462010000900460ff1661045d565b610480610856366004614f66565b61141c565b6104e6610869366004614f4d565b60a16020526000908152604090205463ffffffff1681565b609f5461053c906001600160a01b031681565b6104806108a2366004614f4d565b6114b5565b6104e66108b5366004614f4d565b611535565b61050e611746565b6104116108d03660046151ec565b61175a565b61050e6108e3366004614f4d565b611875565b61050e6108f6366004614f66565b611a60565b61041160975481565b6033546001600160a01b031661053c565b610411610923366004614da6565b609a6020526000908152604090205481565b61050e610943366004614f4d565b611b7c565b61050e610956366004614f4d565b611c31565b61053c610969366004614f4d565b611cf7565b6104e661097c366004614f4d565b611da1565b61099461098f366004614f4d565b611db8565b604080519384526020840192909252908201526060016103f5565b61050e6109bd3660046152ec565b612449565b60655460405161ffff90911681526020016103f5565b60a95461053c906001600160a01b031681565b610411609b5481565b6104b3610a02366004614f4d565b612721565b610a2d610a15366004614f4d565b6000908152609860205260409020600c015460ff1690565b6040516103f5919061536e565b61050e610a48366004614f4d565b612830565b61045d610a5b36600461500a565b6128fb565b610480610a6e366004614f4d565b612935565b61050e6129b5565b610ae4610a89366004614f4d565b6000908152609860205260409020805460028201546003830154600584015460068501546009860154600c909601546001600160a01b0395861697948616969395909216939092600160201b900463ffffffff169160ff1690565b6040516103f5979695949392919061537c565b61050e610b05366004614da6565b6129cd565b61050e610b183660046153c3565b612a76565b61045d610b2b366004614f4d565b612ae0565b609e5461053c906001600160a01b031681565b61050e610b51366004614da6565b612aed565b61050e612b63565b6001600160a01b038116600090815260a060205260409020606090610b8290612b7b565b92915050565b6000610b92612b88565b610ba28989898989898989612bd4565b9998505050505050505050565b600060036000838152609860205260409020600c015460ff166005811115610bd957610bd9615071565b14610be657506000919050565b610bef82611535565b63ffffffff164263ffffffff16119050919050565b604080518082019091526000808252602082015260008381526098602052604090206003600c82015460ff166005811115610c4157610c41615071565b141580610c5f57506009810154600160201b900463ffffffff168311155b15610c6a5750610b82565b600084815260ac60205260408120548190610c8b908490879060ff16613242565b91865250602085015250505092915050565b60008181526098602052604081206001600c82015460ff166005811115610cc657610cc6615071565b14610cd45750600092915050565b600083815260a2602052604090205463ffffffff16610cf65750600092915050565b600083815260a260205260409020546009820154610d1d9163ffffffff90811691166153f6565b63ffffffff164263ffffffff1611915050919050565b60a66020526000908152604090208054610d4c9061541e565b80601f0160208091040260200160405190810160405280929190818152602001828054610d789061541e565b8015610dc55780601f10610d9a57610100808354040283529160200191610dc5565b820191906000526020600020905b815481529060010190602001808311610da857829003601f168201915b505050505081565b610dd5613270565b609e54604051633d36902960e01b8152600481018590526001600160a01b039283169290911690633d3690299060240160206040518083038186803b158015610e1d57600080fd5b505afa158015610e31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e559190615459565b6001600160a01b031614610eb05760405162461bcd60e51b815260206004820152601f60248201527f43616c6c6572206d75737420626520746865206d61726b6574206f776e65720060448201526064015b60405180910390fd5b600082815260a76020526040902080546001600160a01b0319166001600160a01b038316179055817fa593acf9edc343669c7fc50d2caa3911326adef438361f0fa911be85c9e296a482610f02613270565b604080516001600160a01b0393841681529290911660208301520160405180910390a25050565b60408051808201909152600c81526b18db185a5b531bd85b93919560a21b6020820152819060036000838152609860205260409020600c015460ff166005811115610f7657610f76615071565b14610f985781816040516347bc33cb60e11b8152600401610ea7929190615476565b610fa0612b88565b60008381526098602052604081206003810154909190610fbf9061327f565b60028301549091506001600160a01b038083169116146110215760405162461bcd60e51b815260206004820152601960248201527f6f6e6c79206c656e6465722063616e20636c61696d204e4654000000000000006044820152606401610ea7565b60ab5460405163096c998360e41b8152600481018790526001600160a01b038381166024830152909116906396c9983090604401600060405180830381600087803b15801561106f57600080fd5b505af1158015611083573d6000803e3d6000fd5b505060ab54600290940180546001600160a01b0319166001600160a01b0390951694909417909355505050505050565b60006110bf84846128fb565b80156110e857506001600160a01b038316600090815260a8602052604090206110e8908361332a565b90505b9392505050565b6001600160a01b03811660009081526099602090815260409182902080548351818402810184019094528084526060939283018282801561115257602002820191906000526020600020905b81548152602001906001019080831161113e575b50505050509050919050565b6000610b82826201518061334c565b609e5460008281526098602052604090819020600301549051633d36902960e01b81526001600160a01b0390921691633d369029916111b29160040190815260200190565b60206040518083038186803b1580156111ca57600080fd5b505afa1580156111de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112029190615459565b6001600160a01b0316611213613270565b6001600160a01b0316146112a7576040516347bc33cb60e11b8152600481018290526060602482015260146064820152731b585c9ad95d13dddb995c90d85b98d95b109a5960621b608482015260a06044820152602160a48201527f4f6e6c7920746865206d61726b6574206f776e65722063616e2063616e63656c60c4820152602160f81b60e482015261010401610ea7565b6112b0816133e8565b60405181907ff3f271d754f5264e0d143bf9be577d6eba153b0d833bd3a127d7b1a280bb13f190600090a250565b6112e882826128fb565b6113445760405162461bcd60e51b815260206004820152602760248201527f466f72776172646572206d757374206265207472757374656420627920746865604482015266081b585c9ad95d60ca1b6064820152608401610ea7565b61136d61134f613270565b6001600160a01b038316600090815260a8602052604090209061349c565b50806001600160a01b0316827f65d6b5305e8c0e58e88454a1aeecae0f55975222338b25abd0997b4d305056a16113a2613270565b6040516001600160a01b03909116815260200160405180910390a35050565b609960205281600052604060002081815481106113dd57600080fd5b90600052602060002001600091509150505481565b6113fa6134b1565b609f80546001600160a01b0319166001600160a01b0392909216919091179055565b604080518082018252600080825260208083018290528582526098905291909120600c81015460039060ff16600581111561145957611459615071565b14158061147757506009810154600160201b900463ffffffff168311155b156114825750610b82565b600084815260ac602052604081205481906114a3908490879060ff16613242565b90865260208601525050505092915050565b604080518082019091526000808252602082015260036000838152609860205260409020600c015460ff1660058111156114f1576114f1615071565b146114fb57919050565b600082815260986020908152604080832060ac909252822054829161152491429060ff16613242565b918552506020840152509092915050565b6000818152609860205260408120600c81015460039060ff16600581111561155f5761155f615071565b1461156a5750919050565b600061157584611da1565b90506001600085815260ac602052604090205460ff16600181111561159c5761159c615071565b141561163c5760098201546000906115c59063ffffffff600160201b909104811690841661352a565b60098401549091506115e390600160201b900463ffffffff166135b1565b6115f28363ffffffff166135b1565b111561160a576116036002826154c5565b9050611618565b6116156001826154c5565b90505b600983015461163490600160201b900463ffffffff16826135cb565b9350506116fc565b600084815260ac602052604081205460ff16600181111561165f5761165f615071565b14156116fc57600b82015460098301546116899163ffffffff90811691600160201b9004166153f6565b60098301549093506000906116ab90600160201b900463ffffffff16836154dd565b905063ffffffff8116156116fa57600b8301546000906116d49063ffffffff808516911661369d565b600b8501549091506116ec9063ffffffff1682615502565b6116f690866153f6565b9450505b505b60098201546000906117249063ffffffff600160601b8204811691600160201b9004166153f6565b90508063ffffffff168463ffffffff16111561173e578093505b505050919050565b61174e6134b1565b61175860006136d4565b565b6000611764612b88565b6117748b8b8b8b8b8b8b8b612bd4565b60aa54604051631532dc4560e01b81529192506000916001600160a01b0390911690631532dc45906117ae9085908890889060040161553b565b602060405180830381600087803b1580156117c857600080fd5b505af11580156117dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061180091906155dc565b90506001811515146118665760405162461bcd60e51b815260206004820152602960248201527f436f6c6c61746572616c2062616c616e636520636f756c64206e6f74206265206044820152681d985b1a59185d195960ba1b6064820152608401610ea7565b509a9950505050505050505050565b60408051808201909152600d81526c3634b8bab4b230ba32a637b0b760991b6020820152819060036000838152609860205260409020600c015460ff1660058111156118c3576118c3615071565b146118e55781816040516347bc33cb60e11b8152600401610ea7929190615476565b6118ee8361115e565b61193a5760405162461bcd60e51b815260206004820152601b60248201527f4c6f616e206d757374206265206c697175696461746561626c652e00000000006044820152606401610ea7565b600083815260986020908152604080832060ac9092528220549091908190611968908490429060ff16613242565b925050915061199986604051806040016040528085815260200184815250838561199291906154c5565b6000613726565b600c8301805460ff1916600517905560038301546000906119b99061327f565b60aa5460405163f0472c4960e01b8152600481018a90526001600160a01b03808416602483015292935091169063f0472c4990604401600060405180830381600087803b158015611a0957600080fd5b505af1158015611a1d573d6000803e3d6000fd5b50506040516001600160a01b03841692508991507f73de9acc561f27528ab0a3b5dd63fefb4e59f95575891299a6f862a78779817690600090a350505050505050565b6040805180820190915260098152683932b830bca637b0b760b91b6020820152829060036000838152609860205260409020600c015460ff166005811115611aaa57611aaa615071565b14611acc5781816040516347bc33cb60e11b8152600401610ea7929190615476565b600084815260986020908152604080832060ac90925282205482918291611af89190429060ff16613242565b919450925090506000611b0b82846154c5565b905080871015611b3e5760405162dd9d0f60e61b8152600481018990526024810188905260448101829052606401610ea7565b611b72886040518060400160405280858b611b5991906155f7565b8152602001859052611b6b85886154c5565b6001613726565b5050505050505050565b600081815260986020526040902080546003909101546001600160a01b0390911690611ba79061327f565b6001600160a01b031614611c25576040516347bc33cb60e11b81526004810182905260606024820152600960648201526818d85b98d95b109a5960ba1b608482015260a06044820152601e60a48201527f4f6e6c792074686520626964206f776e65722063616e2063616e63656c21000060c482015260e401610ea7565b611c2e816133e8565b50565b6040805180820190915260098152683932b830bca637b0b760b91b6020820152819060036000838152609860205260409020600c015460ff166005811115611c7b57611c7b615071565b14611c9d5781816040516347bc33cb60e11b8152600401610ea7929190615476565b600083815260986020908152604080832060ac9092528220548291611cc691429060ff16613242565b9250509150611cf0856040518060400160405280858152602001848152508385611b6b91906154c5565b5050505050565b60008181526098602052604090206002015460ab546001600160a01b039182169116811415611d9c5760ab546040516331a9108f60e11b8152600481018490526001600160a01b0390911690636352211e9060240160206040518083038186803b158015611d6457600080fd5b505afa158015611d78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b829190615459565b919050565b6000818152609860205260408120610b8290613a0d565b6000806000836040518060400160405280600f81526020016e1b195b99195c9058d8d95c1d109a59608a1b81525060016005811115611df957611df9615071565b6000838152609860205260409020600c015460ff166005811115611e1f57611e1f615071565b14611e415781816040516347bc33cb60e11b8152600401610ea792919061560e565b611e49612b88565b60008681526098602052604081206003810154909190611e689061327f565b609e546003840154604051633ef19a9b60e01b815260048101919091526001600160a01b03808416602483015292935060009290911690633ef19a9b90604401604080518083038186803b158015611ebf57600080fd5b505afa158015611ed3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ef7919061565b565b50905080611f3d5760405162461bcd60e51b81526020600482015260136024820152722737ba103b32b934b334b2b2103632b73232b960691b6044820152606401610ea7565b609e546003840154604051631cc672df60e01b81526001600160a01b0390921691631cc672df91611f749160040190815260200190565b60206040518083038186803b158015611f8c57600080fd5b505afa158015611fa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc491906155dc565b156120045760405162461bcd60e51b815260206004820152601060248201526f13585c9ad95d081a5cc818db1bdcd95960821b6044820152606401610ea7565b61200d89610c9d565b1561204c5760405162461bcd60e51b815260206004820152600f60248201526e109a59081a185cc8195e1c1a5c9959608a1b6044820152606401610ea7565b6009830180546bffffffffffffffff000000001916600160201b4263ffffffff1690810263ffffffff60401b191691909117600160401b91909102179055600c830180546003919060ff191660018302179055506002830180546001600160a01b0319166001600160a01b038481169190911790915560aa546040516346f0b08b60e11b8152600481018c9052911690638de1611690602401600060405180830381600087803b1580156120ff57600080fd5b505af1158015612113573d6000803e3d6000fd5b5050505061213261212760655461ffff1690565b600685015490613a53565b609e54600385015460405163028ba63960e21b8152929a506121c0926001600160a01b0390921691630a2e98e4916121709160040190815260200190565b60206040518083038186803b15801561218857600080fd5b505afa15801561219c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121279190615687565b9650868884600501600101546121d691906155f7565b6121e091906155f7565b955061220e826121f86033546001600160a01b031690565b60058601546001600160a01b031691908b613a65565b609e5460038401546040516332209bcb60e11b81526122b19285926001600160a01b039091169163644137969161224b9160040190815260200190565b60206040518083038186803b15801561226357600080fd5b505afa158015612277573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229b9190615459565b60058601546001600160a01b031691908a613a65565b600183015460058401546122d4916001600160a01b039182169185911689613a65565b600683015460058401546001600160a01b03908116600090815260a360209081526040808320938716835292905290812080549091906123159084906154c5565b9091555050600683015460058401546001600160a01b0316600090815260a460205260408120805490919061234b9084906154c5565b909155505082546001600160a01b0316600090815260a060205260409020612373908a613ac5565b506040516001600160a01b038316908a907fde9d3bfa8771df6761c0afac2375c88c70a3aa30478e1bd15363294033b470ed90600090a3604051671c1c9bdd1bd8dbdb60c21b81528890600801604051908190038120908b907f476a21a61ac4a7da250e040733aa10facd2eeee584b2c009d178c3de3d8a12dc90600090a46040516a6d61726b6574706c61636560a81b81528790600b01604051908190038120908b907f476a21a61ac4a7da250e040733aa10facd2eeee584b2c009d178c3de3d8a12dc90600090a450505050509193909250565b600054610100900460ff16158080156124695750600054600160ff909116105b806124835750303b158015612483575060005460ff166001145b61249f5760405162461bcd60e51b8152600401610ea7906156a4565b6000805460ff1916600117905580156124c2576000805461ff0019166101001790555b6124cb87613ad1565b6124d3613b09565b6001600160a01b0384163b61253f5760405162461bcd60e51b815260206004820152602c60248201527f4c656e646572436f6d6d69746d656e74466f72776172646572206d757374206260448201526b1948184818dbdb9d1c9858dd60a21b6064820152608401610ea7565b60a980546001600160a01b0319166001600160a01b038681169190911790915586163b6125b85760405162461bcd60e51b815260206004820152602160248201527f4d61726b65745265676973747279206d757374206265206120636f6e747261636044820152601d60fa1b6064820152608401610ea7565b609e80546001600160a01b0319166001600160a01b038881169190911790915585163b6126335760405162461bcd60e51b8152602060048201526024808201527f52657075746174696f6e4d616e61676572206d757374206265206120636f6e746044820152631c9858dd60e21b6064820152608401610ea7565b609f80546001600160a01b0319166001600160a01b038781169190911790915583163b6126ae5760405162461bcd60e51b8152602060048201526024808201527f436f6c6c61746572616c4d616e61676572206d757374206265206120636f6e746044820152631c9858dd60e21b6064820152608401610ea7565b60aa80546001600160a01b0319166001600160a01b0385161790556126d282613b38565b8015612718576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b600081815260a66020526040902080546060919061273e9061541e565b80601f016020809104026020016040519081016040528092919081815260200182805461276a9061541e565b80156127b75780601f1061278c576101008083540402835291602001916127b7565b820191906000526020600020905b81548152906001019060200180831161279a57829003601f168201915b50505050509050806040516020016127cf91906156f2565b604051602081830303815290604052805190602001207fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b1415611d9c57600082815260986020908152604090912060040154906110eb908290613bd8565b6040805180820190915260098152683932b830bca637b0b760b91b6020820152819060036000838152609860205260409020600c015460ff16600581111561287a5761287a615071565b1461289c5781816040516347bc33cb60e11b8152600401610ea7929190615476565b600083815260986020908152604080832060ac909252822054829182916128c89190429060ff16613242565b9250925092506128f3866040518060400160405280858152602001848152508386611b6b91906154c5565b505050505050565b600082815260a760205260408120546001600160a01b03838116911614806110eb57505060a9546001600160a01b03908116911614919050565b604080518082019091526000808252602082015260036000838152609860205260409020600c015460ff16600581111561297157612971615071565b1461297b57919050565b600082815260986020908152604080832060ac90925282205482916129a491429060ff16613242565b908552602085015250919392505050565b6129bd6134b1565b6129c5612b88565b611758613d74565b600054600890610100900460ff161580156129ef575060005460ff8083169116105b612a0b5760405162461bcd60e51b8152600401610ea7906156a4565b6000805461ffff191660ff831617610100179055612a276134b1565b612a3082613b38565b6000805461ff001916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050565b612a7e6134b1565b60655461ffff82811691161415612a925750565b6065805461ffff83811661ffff198316811790935560408051938452911660208301819052917f4810ece076cee6c6042808956f3f65dad1bc72b75181341d7bed810d39deda0f9101612a6a565b6000610b8282600061334c565b612af56134b1565b6001600160a01b038116612b5a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610ea7565b611c2e816136d4565b612b6b6134b1565b612b73613dd3565b611758613e22565b606060006110eb83613e5f565b60655462010000900460ff16156117585760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610ea7565b600080612be08961327f565b609e5460405163066e751360e01b8152600481018c90526001600160a01b0380841660248301529293506000929091169063066e751390604401604080518083038186803b158015612c3157600080fd5b505afa158015612c45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c69919061565b565b50905080612cb15760405162461bcd60e51b81526020600482015260156024820152742737ba103b32b934b334b2b2103137b93937bbb2b960591b6044820152606401610ea7565b609e54604051631cc672df60e01b8152600481018c90526001600160a01b0390911690631cc672df9060240160206040518083038186803b158015612cf557600080fd5b505afa158015612d09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d2d91906155dc565b15612d6d5760405162461bcd60e51b815260206004820152601060248201526f13585c9ad95d081a5cc818db1bdcd95960821b6044820152606401610ea7565b609754600081815260986020526040902080546001600160a01b0319166001600160a01b03858116919091178255919450908516612db55780546001600160a01b0316612db7565b845b6001820180546001600160a01b03199081166001600160a01b0393841617909155600383018d90556005830180549091168e8316179055600682018b90556009820180546fffffffff0000000000000000ffffffff1916600160601b63ffffffff8d81169190910263ffffffff1916919091174291909116179055609e5460405163a5630f1960e01b8152600481018e905291169063a5630f1990602401604080518083038186803b158015612e6c57600080fd5b505afa158015612e80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea4919061571b565b609754600090815260ac602052604081208054600b86019291849160ff191660018381811115612ed657612ed6615071565b021790555081546101009190910a63ffffffff8181021990921694909116029290921790915550600b8101805465ffff000000001916600160201b61ffff8b1602179055609e546040516311bed5bb60e01b8152600481018d90526001600160a01b03909116906311bed5bb9060240160206040518083038186803b158015612f5e57600080fd5b505afa158015612f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f96919061574a565b609754600090815260a1602052604090819020805463ffffffff191663ffffffff9390931692909217909155609e54905163082fc54d60e01b8152600481018d90526001600160a01b039091169063082fc54d9060240160206040518083038186803b15801561300557600080fd5b505afa158015613019573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303d919061574a565b609754600090815260a2602052604090819020805463ffffffff191663ffffffff9390931692909217909155609e54905163d6e794dd60e01b8152600481018d90526001600160a01b039091169063d6e794dd9060240160206040518083038186803b1580156130ac57600080fd5b505afa1580156130c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e49190615767565b600c8201805461ff00191661010083600181111561310457613104615071565b0217905550600c810154609754600090815260ac6020526040902054600b8301546131469260ff61010090910481169216908d908d9063ffffffff168d613eb9565b600a820155609754600090815260a660205260409020613167908888614cf8565b50600c8101805460ff1916600117905560405161318a9088908890602001615784565b60408051808303601f19018152908290528051602091820120835460975460018601546001600160a01b0390811686529294929091169290917ff887b1f393f43fb94c5d50483df4bd410ffbf286128c5f24ff56c580ac7f731c910160405180910390a480546001600160a01b0316600090815260996020908152604082206097805482546001810184559285529284209091019190915580549161322e83615794565b919050555050505098975050505050505050565b60008060006132618661325488613a0d565b63ffffffff168787613f57565b92509250925093509350939050565b600061327a6140fe565b905090565b600061328d82610a5b613270565b156133225760131936013560601c6132ca8160a860006132ab613270565b6001600160a01b0316815260208101919091526040016000209061332a565b610b825760405162461bcd60e51b8152602060048201526024808201527f53656e646572206d75737420617070726f7665206d61726b657420666f727761604482015263393232b960e11b6064820152608401610ea7565b610b82613270565b6001600160a01b038116600090815260018301602052604081205415156110eb565b60008281526098602052604081206003600c82015460ff16600581111561337557613375615071565b14613384576000915050610b82565b600084815260a1602052604090205463ffffffff166133a7576000915050610b82565b600084815260a1602052604090205463ffffffff166133c585611da1565b6133cf85426154dd565b6133d991906154dd565b63ffffffff1611949350505050565b60408051808201909152600981526818d85b98d95b109a5960ba1b6020820152819060016000838152609860205260409020600c015460ff16600581111561343257613432615071565b146134545781816040516347bc33cb60e11b8152600401610ea792919061560e565b600083815260986020526040808220600c01805460ff191660021790555184917fa0633b09ac3029a6746aa27d4db1407f5f287a10c41a6b2ad2859f4da9b2680b91a2505050565b60006110eb836001600160a01b038416614143565b6134b9613270565b6001600160a01b03166134d46033546001600160a01b031690565b6001600160a01b0316146117585760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610ea7565b60008183111561353957600080fd5b60008061355161354c62015180876157c5565b614192565b50909250905060008061356a61354c62015180886157c5565b5090925090508261357c85600c6157d9565b8261358885600c6157d9565b61359291906154c5565b61359c91906155f7565b6135a691906155f7565b979650505050505050565b60006135c361354c62015180846157c5565b949350505050565b60008080806135e061354c62015180886157c5565b919450925090506135f185836154c5565b9150600c6136006001846155f7565b61360a91906157c5565b61361490846154c5565b9250600c6136236001846155f7565b61362d91906157f8565b6136389060016154c5565b915060006136468484614306565b905080821115613654578091505b61366162015180886157f8565b6201518061367086868661438c565b61367a91906157d9565b61368491906154c5565b94508685101561369357600080fd5b5050505092915050565b600082156136cb57816136b16001856155f7565b6136bb91906157c5565b6136c69060016154c5565b6110eb565b50600092915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000848152609860209081526040822090850151855191929161374991906154c5565b609f54835460405163c7312e4760e01b81526001600160a01b039182166004820152602481018a905292935060009291169063c7312e4790604401602060405180830381600087803b15801561379e57600080fd5b505af11580156137b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137d6919061580c565b90508482106138aa57600c8301805460ff1916600417905582546001600160a01b0316600090815260a06020526040902085925061381490886144c9565b50831561387a5760aa54604051632e1a7d4d60e01b8152600481018990526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b15801561386157600080fd5b505af1158015613875573d6000803e3d6000fd5b505050505b60405187907f9a7851747cd7ffb3fe0a32caf3da48b31f27cebe131267051640f8b72fc4718690600090a26138d6565b60405187907f68ca97895fe2d09eab47e752271728ade667e72dda27e68c20eaa191a9c2187d90600090a25b60006138e188611cf7565b90506139096138f3856003015461327f565b60058601546001600160a01b0316908386613a65565b865160078501805460009061391f9084906154c5565b9091555050602087015160088501805460009061393d9084906154c5565b909155505060098401805463ffffffff60401b1916600160401b4263ffffffff1602179055600082600281111561397657613976615071565b14611b7257609f54845460405163c7312e4760e01b81526001600160a01b039182166004820152602481018b905291169063c7312e4790604401602060405180830381600087803b1580156139ca57600080fd5b505af11580156139de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a02919061580c565b505050505050505050565b6009810154600090600160401b900463ffffffff1615613a3e576009820154600160401b900463ffffffff16610b82565b5060090154600160201b900463ffffffff1690565b60006110eb838361ffff1660026144d5565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052613abf9085906144f4565b50505050565b60006110eb8383614143565b600054610100900460ff16613af85760405162461bcd60e51b8152600401610ea790615829565b613b006145cb565b611c2e816145fa565b600054610100900460ff16613b305760405162461bcd60e51b8152600401610ea790615829565b61175861462a565b600054610100900460ff16613b5f5760405162461bcd60e51b8152600401610ea790615829565b6001600160a01b0381163b613bb65760405162461bcd60e51b815260206004820181905260248201527f4c656e6465724d616e61676572206d757374206265206120636f6e74726163746044820152606401610ea7565b60ab80546001600160a01b0319166001600160a01b0392909216919091179055565b60606000613be78360026157d9565b613bf29060026154c5565b67ffffffffffffffff811115613c0a57613c0a615874565b6040519080825280601f01601f191660200182016040528015613c34576020820181803683370190505b509050600360fc1b81600081518110613c4f57613c4f61588a565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613c7e57613c7e61588a565b60200101906001600160f81b031916908160001a9053506000613ca28460026157d9565b613cad9060016154c5565b90505b6001811115613d25576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613ce157613ce161588a565b1a60f81b828281518110613cf757613cf761588a565b60200101906001600160f81b031916908160001a90535060049490941c93613d1e816158a0565b9050613cb0565b5083156110eb5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610ea7565b613d7c612b88565b6065805462ff00001916620100001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613db6613270565b6040516001600160a01b03909116815260200160405180910390a1565b60655462010000900460ff166117585760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610ea7565b613e2a613dd3565b6065805462ff0000191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa613db6613270565b606081600001805480602002602001604051908101604052809291908181526020018280548015611152576020028201919060005260206000209081548152602001906001019080831161113e5750505050509050919050565b6000806001876001811115613ed057613ed0615071565b14613edf576301e13380613ee5565b6301da9c005b63ffffffff1690506001886001811115613f0157613f01615071565b1415613f3c57613f34613f2163ffffffff808716908490600a9061465f16565b600a613f2d8987613a53565b91906144d5565b915050613f4d565b613f498686868685614682565b9150505b9695505050505050565b6007840154600685015460009182918291613f71916155f7565b925060006001856001811115613f8957613f89615071565b14613f98576301e13380613f9e565b6301da9c005b63ffffffff1690506000613fd089600a0160010160049054906101000a900461ffff1686613a5390919063ffffffff16565b90506000613fde89896155f7565b905082613feb82846157d9565b613ff591906157c5565b60098b015490945060009061401790600160201b900463ffffffff168a6158b7565b60098c01546140339190600160601b900463ffffffff166158b7565b600b8c015490915060009063ffffffff1682128061405e5750600a8c015461405b878a6154c5565b11155b90506001600c8d0154610100900460ff16600181111561408057614080615071565b1415614095578015614090578796505b6140ef565b6000816140a657600a8d01546140b0565b6140b0878a6154c5565b600b8e015490915060009063ffffffff166140cb86846157d9565b6140d591906157c5565b90506140ea6140e489836155f7565b8b6147b3565b985050505b50505050509450945094915050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633141561413e575060131936013560601c90565b503390565b600081815260018301602052604081205461418a57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b82565b506000610b82565b60008080838162253d8c6141a98362010bd96158f6565b6141b391906158f6565b9050600062023ab16141c6836004615937565b6141d091906159bc565b905060046141e18262023ab1615937565b6141ec9060036158f6565b6141f691906159bc565b61420090836158b7565b9150600062164b096142138460016158f6565b61421f90610fa0615937565b61422991906159bc565b90506004614239826105b5615937565b61424391906159bc565b61424d90846158b7565b61425890601f6158f6565b9250600061098f61426a856050615937565b61427491906159bc565b9050600060506142868361098f615937565b61429091906159bc565b61429a90866158b7565b90506142a7600b836159bc565b94506142b485600c615937565b6142bf8360026158f6565b6142c991906158b7565b915084836142d86031876158b7565b6142e3906064615937565b6142ed91906158f6565b6142f791906158f6565b9a919950975095505050505050565b600081600114806143175750816003145b806143225750816005145b8061432d5750816007145b806143385750816008145b80614343575081600a145b8061434e575081600c145b1561435b5750601f610b82565b8160021461436b5750601e610b82565b614374836147c9565b61437f57601c614382565b601d5b60ff169392505050565b60006107b284101561439d57600080fd5b838383600062253d8c60046064600c6143b7600e886158b7565b6143c191906159bc565b6143cd886113246158f6565b6143d791906158f6565b6143e191906159bc565b6143ec906003615937565b6143f691906159bc565b600c80614404600e886158b7565b61440e91906159bc565b61441990600c615937565b6144246002886158b7565b61442e91906158b7565b61443a9061016f615937565b61444491906159bc565b6004600c614453600e896158b7565b61445d91906159bc565b614469896112c06158f6565b61447391906158f6565b61447f906105b5615937565b61448991906159bc565b614495617d4b876158b7565b61449f91906158f6565b6144a991906158f6565b6144b391906158b7565b6144bd91906158b7565b98975050505050505050565b60006110eb8383614805565b60006144e0826148f8565b6144ea84866157d9565b6110e891906157c5565b6000614549826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166149109092919063ffffffff16565b8051909150156145c6578080602001905181019061456791906155dc565b6145c65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ea7565b505050565b600054610100900460ff166145f25760405162461bcd60e51b8152600401610ea790615829565b61175861491f565b600054610100900460ff166146215760405162461bcd60e51b8152600401610ea790615829565b611c2e81612a76565b600054610100900460ff166146515760405162461bcd60e51b8152600401610ea790615829565b6065805462ff000019169055565b60008261466e575060006110eb565b82614678836148f8565b6144ea90866157d9565b60008363ffffffff168563ffffffff1610156146ec5760405162461bcd60e51b815260206004820152602360248201527f504d543a206379636c65206475726174696f6e203c206c6f616e20647572617460448201526234b7b760e91b6064820152608401610ea7565b61ffff83166147155761470e868563ffffffff168763ffffffff166001614956565b90506147aa565b600061472d8663ffffffff168663ffffffff1661369d565b9050670de0b6b3a7640000600061475d8561475763ffffffff8a166147518a6149a7565b906149cb565b906149ff565b905060006147758461476f84866154c5565b90614a2f565b90506000614787826147518d866149cb565b9050600061479585846155f7565b90506147a182826149ff565b96505050505050505b95945050505050565b60008183106147c257816110eb565b5090919050565b60006147d66004836157f8565b1580156147ec57506147e96064836157f8565b15155b80610b8257506147fe610190836157f8565b1592915050565b600081815260018301602052604081205480156148ee5760006148296001836155f7565b855490915060009061483d906001906155f7565b90508181146148a257600086600001828154811061485d5761485d61588a565b90600052602060002001549050808760000184815481106148805761488061588a565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806148b3576148b36159ea565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b82565b6000915050610b82565b600061490582600a615ae4565b610b829060646157d9565b60606110e88484600085614a47565b600054610100900460ff166149465760405162461bcd60e51b8152600401610ea790615829565b611758614951613270565b6136d4565b600080614964868686614b17565b9050600183600281111561497a5761497a615071565b148015614997575060008480614992576149926157af565b868809115b156147aa57613f4d6001826154c5565b6000610b826127106149c561ffff8516670de0b6b3a7640000614bc7565b90614bd3565b60006110eb670de0b6b3a76400006149c56149e68686614bc7565b6149f96002670de0b6b3a76400006157c5565b90614bdf565b600080614a0d6002846157c5565b90506135c3836149c5614a2887670de0b6b3a7640000614bc7565b8490614bdf565b60006110eb8383670de0b6b3a76400006149cb614beb565b606082471015614aa85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ea7565b600080866001600160a01b03168587604051614ac491906156f2565b60006040518083038185875af1925050503d8060008114614b01576040519150601f19603f3d011682016040523d82523d6000602084013e614b06565b606091505b50915091506135a687838387614c5d565b600080806000198587098587029250828110838203039150508060001415614b5257838281614b4857614b486157af565b04925050506110eb565b808411614b5e57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b60006110eb82846157d9565b60006110eb82846157c5565b60006110eb82846154c5565b6000614bf86002856157f8565b614c025782614c04565b845b9050614c116002856157c5565b93505b83156135c357614c2885868463ffffffff16565b9450614c356002856157f8565b15614c4b57614c4881868463ffffffff16565b90505b614c566002856157c5565b9350614c14565b60608315614cc9578251614cc2576001600160a01b0385163b614cc25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ea7565b50816135c3565b6135c38383815115614cde5781518083602001fd5b8060405162461bcd60e51b8152600401610ea79190614ff7565b828054614d049061541e565b90600052602060002090601f016020900481019282614d265760008555614d6c565b82601f10614d3f5782800160ff19823516178555614d6c565b82800160010185558215614d6c579182015b82811115614d6c578235825591602001919060010190614d51565b50614d78929150614d7c565b5090565b5b80821115614d785760008155600101614d7d565b6001600160a01b0381168114611c2e57600080fd5b600060208284031215614db857600080fd5b81356110eb81614d91565b6020808252825182820181905260009190848201906040850190845b81811015614dfb57835183529284019291840191600101614ddf565b50909695505050505050565b63ffffffff81168114611c2e57600080fd5b61ffff81168114611c2e57600080fd5b60008083601f840112614e3b57600080fd5b50813567ffffffffffffffff811115614e5357600080fd5b602083019150836020828501011115614e6b57600080fd5b9250929050565b60008060008060008060008060e0898b031215614e8e57600080fd5b8835614e9981614d91565b975060208901359650604089013595506060890135614eb781614e07565b94506080890135614ec781614e19565b935060a089013567ffffffffffffffff811115614ee357600080fd5b614eef8b828c01614e29565b90945092505060c0890135614f0381614d91565b809150509295985092959890939650565b60008060408385031215614f2757600080fd5b8235614f3281614d91565b91506020830135614f4281614d91565b809150509250929050565b600060208284031215614f5f57600080fd5b5035919050565b60008060408385031215614f7957600080fd5b50508035926020909101359150565b815181526020808301519082015260408101610b82565b60005b83811015614fba578181015183820152602001614fa2565b83811115613abf5750506000910152565b60008151808452614fe3816020860160208601614f9f565b601f01601f19169290920160200192915050565b6020815260006110eb6020830184614fcb565b6000806040838503121561501d57600080fd5b823591506020830135614f4281614d91565b60008060006060848603121561504457600080fd5b83359250602084013561505681614d91565b9150604084013561506681614d91565b809150509250925092565b634e487b7160e01b600052602160045260246000fd5b60028110611c2e57611c2e615071565b602081016150a483615087565b91905290565b600080604083850312156150bd57600080fd5b82356150c881614d91565b946020939093013593505050565b600681106150e6576150e6615071565b9052565b6150e681615087565b60006102408201905060018060a01b03808c168352808b166020840152808a1660408401528860608401528760808401528087511660a084015250602086015160c0830152604086015161515460e084018280518252602090810151910152565b50606086015163ffffffff9081166101208401526080870151811661014084015260a08701511661016083015260c086015161519961018084018263ffffffff169052565b5084516101a0830152602085015163ffffffff166101c0830152604085015161ffff166101e08301526151d06102008301856150d6565b6151de6102208301846150ea565b9a9950505050505050505050565b6000806000806000806000806000806101008b8d03121561520c57600080fd5b8a3561521781614d91565b995060208b0135985060408b0135975060608b013561523581614e07565b965060808b013561524581614e19565b955060a08b013567ffffffffffffffff8082111561526257600080fd5b61526e8e838f01614e29565b909750955060c08d0135915061528382614d91565b90935060e08c0135908082111561529957600080fd5b818d0191508d601f8301126152ad57600080fd5b8135818111156152bc57600080fd5b8e60208260071b85010111156152d157600080fd5b6020830194508093505050509295989b9194979a5092959850565b60008060008060008060c0878903121561530557600080fd5b863561531081614e19565b9550602087013561532081614d91565b9450604087013561533081614d91565b9350606087013561534081614d91565b9250608087013561535081614d91565b915060a087013561536081614d91565b809150509295509295509295565b60208101610b8282846150d6565b6001600160a01b038881168252878116602083015260408201879052851660608201526080810184905263ffffffff831660a082015260e081016144bd60c08301846150d6565b6000602082840312156153d557600080fd5b81356110eb81614e19565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff808316818516808303821115615415576154156153e0565b01949350505050565b600181811c9082168061543257607f821691505b6020821081141561545357634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561546b57600080fd5b81516110eb81614d91565b82815260606020820152600061548f6060830184614fcb565b8281036040938401526015815274131bd85b881b5d5cdd081899481858d8d95c1d1959605a1b6020820152919091019392505050565b600082198211156154d8576154d86153e0565b500190565b600063ffffffff838116908316818110156154fa576154fa6153e0565b039392505050565b600063ffffffff80831681851681830481118215151615615525576155256153e0565b02949350505050565b60038110611c2e57600080fd5b838152604060208083018290528282018490526000919060609081850187855b888110156155bd57813561556e8161552e565b6003811061557e5761557e615071565b8352818401358484015285820135868401528482013561559d81614d91565b6001600160a01b031683860152608092830192919091019060010161555b565b50909998505050505050505050565b80518015158114611d9c57600080fd5b6000602082840312156155ee57600080fd5b6110eb826155cc565b600082821015615609576156096153e0565b500390565b8281526060602082015260006156276060830184614fcb565b8281036040938401526013815272426964206d7573742062652070656e64696e6760681b6020820152919091019392505050565b6000806040838503121561566e57600080fd5b615677836155cc565b9150602083015190509250929050565b60006020828403121561569957600080fd5b81516110eb81614e19565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60008251615704818460208701614f9f565b9190910192915050565b60028110611c2e57600080fd5b6000806040838503121561572e57600080fd5b825161573981614e07565b6020840151909250614f428161570e565b60006020828403121561575c57600080fd5b81516110eb81614e07565b60006020828403121561577957600080fd5b81516110eb8161570e565b8183823760009101908152919050565b60006000198214156157a8576157a86153e0565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826157d4576157d46157af565b500490565b60008160001904831182151516156157f3576157f36153e0565b500290565b600082615807576158076157af565b500690565b60006020828403121561581e57600080fd5b81516110eb8161552e565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000816158af576158af6153e0565b506000190190565b60008083128015600160ff1b8501841216156158d5576158d56153e0565b6001600160ff1b03840183138116156158f0576158f06153e0565b50500390565b600080821280156001600160ff1b0384900385131615615918576159186153e0565b600160ff1b8390038412811615615931576159316153e0565b50500190565b60006001600160ff1b038184138284138082168684048611161561595d5761595d6153e0565b600160ff1b600087128281168783058912161561597c5761597c6153e0565b60008712925087820587128484161615615998576159986153e0565b878505871281841616156159ae576159ae6153e0565b505050929093029392505050565b6000826159cb576159cb6157af565b600160ff1b8214600019841416156159e5576159e56153e0565b500590565b634e487b7160e01b600052603160045260246000fd5b600181815b80851115615a3b578160001904821115615a2157615a216153e0565b80851615615a2e57918102915b93841c9390800290615a05565b509250929050565b600082615a5257506001610b82565b81615a5f57506000610b82565b8160018114615a755760028114615a7f57615a9b565b6001915050610b82565b60ff841115615a9057615a906153e0565b50506001821b610b82565b5060208310610133831016604e8410600b8410161715615abe575081810a610b82565b615ac88383615a00565b8060001904821115615adc57615adc6153e0565b029392505050565b60006110eb8383615a4356fea2646970667358221220601d7ad2dd26562b57f361d813bcf96b18591a58e63db1b5a719ee8be9c1d1d064736f6c63430008090033", @@ -2158,7 +2158,7 @@ "storageLayout": { "storage": [ { - "astId": 138, + "astId": 326, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_initialized", "offset": 0, @@ -2166,7 +2166,7 @@ "type": "t_uint8" }, { - "astId": 141, + "astId": 329, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_initializing", "offset": 1, @@ -2174,7 +2174,7 @@ "type": "t_bool" }, { - "astId": 2108, + "astId": 2613, "contract": "contracts/TellerV2.sol:TellerV2", "label": "__gap", "offset": 0, @@ -2198,7 +2198,7 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 15099, + "astId": 19201, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_protocolFee", "offset": 0, @@ -2206,7 +2206,7 @@ "type": "t_uint16" }, { - "astId": 321, + "astId": 509, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_paused", "offset": 2, @@ -2214,7 +2214,7 @@ "type": "t_bool" }, { - "astId": 426, + "astId": 614, "contract": "contracts/TellerV2.sol:TellerV2", "label": "__gap", "offset": 0, @@ -2222,7 +2222,7 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 18675, + "astId": 22973, "contract": "contracts/TellerV2.sol:TellerV2", "label": "bidId", "offset": 0, @@ -2230,15 +2230,15 @@ "type": "t_uint256" }, { - "astId": 18680, + "astId": 22978, "contract": "contracts/TellerV2.sol:TellerV2", "label": "bids", "offset": 0, "slot": "152", - "type": "t_mapping(t_uint256,t_struct(Bid)18647_storage)" + "type": "t_mapping(t_uint256,t_struct(Bid)22945_storage)" }, { - "astId": 18685, + "astId": 22983, "contract": "contracts/TellerV2.sol:TellerV2", "label": "borrowerBids", "offset": 0, @@ -2246,7 +2246,7 @@ "type": "t_mapping(t_address,t_array(t_uint256)dyn_storage)" }, { - "astId": 18689, + "astId": 22987, "contract": "contracts/TellerV2.sol:TellerV2", "label": "__lenderVolumeFilled", "offset": 0, @@ -2254,7 +2254,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 18691, + "astId": 22989, "contract": "contracts/TellerV2.sol:TellerV2", "label": "__totalVolumeFilled", "offset": 0, @@ -2262,39 +2262,39 @@ "type": "t_uint256" }, { - "astId": 18694, + "astId": 22992, "contract": "contracts/TellerV2.sol:TellerV2", "label": "__lendingTokensSet", "offset": 0, "slot": "156", - "type": "t_struct(AddressSet)8906_storage" + "type": "t_struct(AddressSet)12647_storage" }, { - "astId": 18697, + "astId": 22995, "contract": "contracts/TellerV2.sol:TellerV2", "label": "marketRegistry", "offset": 0, "slot": "158", - "type": "t_contract(IMarketRegistry)19485" + "type": "t_contract(IMarketRegistry)24479" }, { - "astId": 18700, + "astId": 22998, "contract": "contracts/TellerV2.sol:TellerV2", "label": "reputationManager", "offset": 0, "slot": "159", - "type": "t_contract(IReputationManager)19544" + "type": "t_contract(IReputationManager)24538" }, { - "astId": 18705, + "astId": 23003, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_borrowerBidsActive", "offset": 0, "slot": "160", - "type": "t_mapping(t_address,t_struct(UintSet)9063_storage)" + "type": "t_mapping(t_address,t_struct(UintSet)12804_storage)" }, { - "astId": 18709, + "astId": 23007, "contract": "contracts/TellerV2.sol:TellerV2", "label": "bidDefaultDuration", "offset": 0, @@ -2302,7 +2302,7 @@ "type": "t_mapping(t_uint256,t_uint32)" }, { - "astId": 18713, + "astId": 23011, "contract": "contracts/TellerV2.sol:TellerV2", "label": "bidExpirationTime", "offset": 0, @@ -2310,7 +2310,7 @@ "type": "t_mapping(t_uint256,t_uint32)" }, { - "astId": 18719, + "astId": 23017, "contract": "contracts/TellerV2.sol:TellerV2", "label": "lenderVolumeFilled", "offset": 0, @@ -2318,7 +2318,7 @@ "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" }, { - "astId": 18723, + "astId": 23021, "contract": "contracts/TellerV2.sol:TellerV2", "label": "totalVolumeFilled", "offset": 0, @@ -2326,7 +2326,7 @@ "type": "t_mapping(t_address,t_uint256)" }, { - "astId": 18725, + "astId": 23023, "contract": "contracts/TellerV2.sol:TellerV2", "label": "version", "offset": 0, @@ -2334,7 +2334,7 @@ "type": "t_uint256" }, { - "astId": 18729, + "astId": 23027, "contract": "contracts/TellerV2.sol:TellerV2", "label": "uris", "offset": 0, @@ -2342,7 +2342,7 @@ "type": "t_mapping(t_uint256,t_string_storage)" }, { - "astId": 18736, + "astId": 23034, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_trustedMarketForwarders", "offset": 0, @@ -2350,15 +2350,15 @@ "type": "t_mapping(t_uint256,t_address)" }, { - "astId": 18741, + "astId": 23039, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_approvedForwarderSenders", "offset": 0, "slot": "168", - "type": "t_mapping(t_address,t_struct(AddressSet)8906_storage)" + "type": "t_mapping(t_address,t_struct(AddressSet)12647_storage)" }, { - "astId": 18746, + "astId": 23044, "contract": "contracts/TellerV2.sol:TellerV2", "label": "lenderCommitmentForwarder", "offset": 0, @@ -2366,28 +2366,28 @@ "type": "t_address" }, { - "astId": 18752, + "astId": 23050, "contract": "contracts/TellerV2.sol:TellerV2", "label": "collateralManager", "offset": 0, "slot": "170", - "type": "t_contract(ICollateralManager)18950" + "type": "t_contract(ICollateralManager)23934" }, { - "astId": 18758, + "astId": 23056, "contract": "contracts/TellerV2.sol:TellerV2", "label": "lenderManager", "offset": 0, "slot": "171", - "type": "t_contract(ILenderManager)19264" + "type": "t_contract(ILenderManager)24258" }, { - "astId": 18763, + "astId": 23061, "contract": "contracts/TellerV2.sol:TellerV2", "label": "bidPaymentCycleType", "offset": 0, "slot": "172", - "type": "t_mapping(t_uint256,t_enum(PaymentCycleType)21562)" + "type": "t_mapping(t_uint256,t_enum(PaymentCycleType)26941)" } ], "types": { @@ -2430,42 +2430,42 @@ "label": "bytes32", "numberOfBytes": "32" }, - "t_contract(ERC20)5030": { + "t_contract(ERC20)6884": { "encoding": "inplace", "label": "contract ERC20", "numberOfBytes": "20" }, - "t_contract(ICollateralManager)18950": { + "t_contract(ICollateralManager)23934": { "encoding": "inplace", "label": "contract ICollateralManager", "numberOfBytes": "20" }, - "t_contract(ILenderManager)19264": { + "t_contract(ILenderManager)24258": { "encoding": "inplace", "label": "contract ILenderManager", "numberOfBytes": "20" }, - "t_contract(IMarketRegistry)19485": { + "t_contract(IMarketRegistry)24479": { "encoding": "inplace", "label": "contract IMarketRegistry", "numberOfBytes": "20" }, - "t_contract(IReputationManager)19544": { + "t_contract(IReputationManager)24538": { "encoding": "inplace", "label": "contract IReputationManager", "numberOfBytes": "20" }, - "t_enum(BidState)18619": { + "t_enum(BidState)22917": { "encoding": "inplace", "label": "enum BidState", "numberOfBytes": "1" }, - "t_enum(PaymentCycleType)21562": { + "t_enum(PaymentCycleType)26941": { "encoding": "inplace", "label": "enum PaymentCycleType", "numberOfBytes": "1" }, - "t_enum(PaymentType)21559": { + "t_enum(PaymentType)26938": { "encoding": "inplace", "label": "enum PaymentType", "numberOfBytes": "1" @@ -2484,19 +2484,19 @@ "numberOfBytes": "32", "value": "t_mapping(t_address,t_uint256)" }, - "t_mapping(t_address,t_struct(AddressSet)8906_storage)": { + "t_mapping(t_address,t_struct(AddressSet)12647_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct EnumerableSet.AddressSet)", "numberOfBytes": "32", - "value": "t_struct(AddressSet)8906_storage" + "value": "t_struct(AddressSet)12647_storage" }, - "t_mapping(t_address,t_struct(UintSet)9063_storage)": { + "t_mapping(t_address,t_struct(UintSet)12804_storage)": { "encoding": "mapping", "key": "t_address", "label": "mapping(address => struct EnumerableSet.UintSet)", "numberOfBytes": "32", - "value": "t_struct(UintSet)9063_storage" + "value": "t_struct(UintSet)12804_storage" }, "t_mapping(t_address,t_uint256)": { "encoding": "mapping", @@ -2519,12 +2519,12 @@ "numberOfBytes": "32", "value": "t_address" }, - "t_mapping(t_uint256,t_enum(PaymentCycleType)21562)": { + "t_mapping(t_uint256,t_enum(PaymentCycleType)26941)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => enum PaymentCycleType)", "numberOfBytes": "32", - "value": "t_enum(PaymentCycleType)21562" + "value": "t_enum(PaymentCycleType)26941" }, "t_mapping(t_uint256,t_string_storage)": { "encoding": "mapping", @@ -2533,12 +2533,12 @@ "numberOfBytes": "32", "value": "t_string_storage" }, - "t_mapping(t_uint256,t_struct(Bid)18647_storage)": { + "t_mapping(t_uint256,t_struct(Bid)22945_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct Bid)", "numberOfBytes": "32", - "value": "t_struct(Bid)18647_storage" + "value": "t_struct(Bid)22945_storage" }, "t_mapping(t_uint256,t_uint32)": { "encoding": "mapping", @@ -2552,27 +2552,27 @@ "label": "string", "numberOfBytes": "32" }, - "t_struct(AddressSet)8906_storage": { + "t_struct(AddressSet)12647_storage": { "encoding": "inplace", "label": "struct EnumerableSet.AddressSet", "members": [ { - "astId": 8905, + "astId": 12646, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_inner", "offset": 0, "slot": "0", - "type": "t_struct(Set)8591_storage" + "type": "t_struct(Set)12332_storage" } ], "numberOfBytes": "64" }, - "t_struct(Bid)18647_storage": { + "t_struct(Bid)22945_storage": { "encoding": "inplace", "label": "struct Bid", "members": [ { - "astId": 18626, + "astId": 22924, "contract": "contracts/TellerV2.sol:TellerV2", "label": "borrower", "offset": 0, @@ -2580,7 +2580,7 @@ "type": "t_address" }, { - "astId": 18628, + "astId": 22926, "contract": "contracts/TellerV2.sol:TellerV2", "label": "receiver", "offset": 0, @@ -2588,7 +2588,7 @@ "type": "t_address" }, { - "astId": 18630, + "astId": 22928, "contract": "contracts/TellerV2.sol:TellerV2", "label": "lender", "offset": 0, @@ -2596,7 +2596,7 @@ "type": "t_address" }, { - "astId": 18632, + "astId": 22930, "contract": "contracts/TellerV2.sol:TellerV2", "label": "marketplaceId", "offset": 0, @@ -2604,7 +2604,7 @@ "type": "t_uint256" }, { - "astId": 18634, + "astId": 22932, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_metadataURI", "offset": 0, @@ -2612,54 +2612,54 @@ "type": "t_bytes32" }, { - "astId": 18637, + "astId": 22935, "contract": "contracts/TellerV2.sol:TellerV2", "label": "loanDetails", "offset": 0, "slot": "5", - "type": "t_struct(LoanDetails)18664_storage" + "type": "t_struct(LoanDetails)22962_storage" }, { - "astId": 18640, + "astId": 22938, "contract": "contracts/TellerV2.sol:TellerV2", "label": "terms", "offset": 0, "slot": "10", - "type": "t_struct(Terms)18671_storage" + "type": "t_struct(Terms)22969_storage" }, { - "astId": 18643, + "astId": 22941, "contract": "contracts/TellerV2.sol:TellerV2", "label": "state", "offset": 0, "slot": "12", - "type": "t_enum(BidState)18619" + "type": "t_enum(BidState)22917" }, { - "astId": 18646, + "astId": 22944, "contract": "contracts/TellerV2.sol:TellerV2", "label": "paymentType", "offset": 1, "slot": "12", - "type": "t_enum(PaymentType)21559" + "type": "t_enum(PaymentType)26938" } ], "numberOfBytes": "416" }, - "t_struct(LoanDetails)18664_storage": { + "t_struct(LoanDetails)22962_storage": { "encoding": "inplace", "label": "struct LoanDetails", "members": [ { - "astId": 18650, + "astId": 22948, "contract": "contracts/TellerV2.sol:TellerV2", "label": "lendingToken", "offset": 0, "slot": "0", - "type": "t_contract(ERC20)5030" + "type": "t_contract(ERC20)6884" }, { - "astId": 18652, + "astId": 22950, "contract": "contracts/TellerV2.sol:TellerV2", "label": "principal", "offset": 0, @@ -2667,15 +2667,15 @@ "type": "t_uint256" }, { - "astId": 18655, + "astId": 22953, "contract": "contracts/TellerV2.sol:TellerV2", "label": "totalRepaid", "offset": 0, "slot": "2", - "type": "t_struct(Payment)18624_storage" + "type": "t_struct(Payment)22922_storage" }, { - "astId": 18657, + "astId": 22955, "contract": "contracts/TellerV2.sol:TellerV2", "label": "timestamp", "offset": 0, @@ -2683,7 +2683,7 @@ "type": "t_uint32" }, { - "astId": 18659, + "astId": 22957, "contract": "contracts/TellerV2.sol:TellerV2", "label": "acceptedTimestamp", "offset": 4, @@ -2691,7 +2691,7 @@ "type": "t_uint32" }, { - "astId": 18661, + "astId": 22959, "contract": "contracts/TellerV2.sol:TellerV2", "label": "lastRepaidTimestamp", "offset": 8, @@ -2699,7 +2699,7 @@ "type": "t_uint32" }, { - "astId": 18663, + "astId": 22961, "contract": "contracts/TellerV2.sol:TellerV2", "label": "loanDuration", "offset": 12, @@ -2709,12 +2709,12 @@ ], "numberOfBytes": "160" }, - "t_struct(Payment)18624_storage": { + "t_struct(Payment)22922_storage": { "encoding": "inplace", "label": "struct Payment", "members": [ { - "astId": 18621, + "astId": 22919, "contract": "contracts/TellerV2.sol:TellerV2", "label": "principal", "offset": 0, @@ -2722,7 +2722,7 @@ "type": "t_uint256" }, { - "astId": 18623, + "astId": 22921, "contract": "contracts/TellerV2.sol:TellerV2", "label": "interest", "offset": 0, @@ -2732,12 +2732,12 @@ ], "numberOfBytes": "64" }, - "t_struct(Set)8591_storage": { + "t_struct(Set)12332_storage": { "encoding": "inplace", "label": "struct EnumerableSet.Set", "members": [ { - "astId": 8586, + "astId": 12327, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_values", "offset": 0, @@ -2745,7 +2745,7 @@ "type": "t_array(t_bytes32)dyn_storage" }, { - "astId": 8590, + "astId": 12331, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_indexes", "offset": 0, @@ -2755,12 +2755,12 @@ ], "numberOfBytes": "64" }, - "t_struct(Terms)18671_storage": { + "t_struct(Terms)22969_storage": { "encoding": "inplace", "label": "struct Terms", "members": [ { - "astId": 18666, + "astId": 22964, "contract": "contracts/TellerV2.sol:TellerV2", "label": "paymentCycleAmount", "offset": 0, @@ -2768,7 +2768,7 @@ "type": "t_uint256" }, { - "astId": 18668, + "astId": 22966, "contract": "contracts/TellerV2.sol:TellerV2", "label": "paymentCycle", "offset": 0, @@ -2776,7 +2776,7 @@ "type": "t_uint32" }, { - "astId": 18670, + "astId": 22968, "contract": "contracts/TellerV2.sol:TellerV2", "label": "APR", "offset": 4, @@ -2786,17 +2786,17 @@ ], "numberOfBytes": "64" }, - "t_struct(UintSet)9063_storage": { + "t_struct(UintSet)12804_storage": { "encoding": "inplace", "label": "struct EnumerableSet.UintSet", "members": [ { - "astId": 9062, + "astId": 12803, "contract": "contracts/TellerV2.sol:TellerV2", "label": "_inner", "offset": 0, "slot": "0", - "type": "t_struct(Set)8591_storage" + "type": "t_struct(Set)12332_storage" } ], "numberOfBytes": "64" diff --git a/packages/contracts/deployments/goerli/TellerV2_Proxy.json b/packages/contracts/deployments/goerli/TellerV2_Proxy.json index 192da5a06..dd3a034c8 100644 --- a/packages/contracts/deployments/goerli/TellerV2_Proxy.json +++ b/packages/contracts/deployments/goerli/TellerV2_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0x195c6608705546725DF0629dd60690Cf2b367734", + "address": "0x3a8C417a743A60ECfF3988C34783D65362b62915", "abi": [ { "inputs": [ @@ -146,51 +146,51 @@ "type": "receive" } ], - "transactionHash": "0xd41be29c0f527a0634980e9213d5f3aed9933a3ea7f9d1a228126bb9c88ce247", + "transactionHash": "0xdf1feb299ed55e26ff48be18210ad2466797877462fc58cf754ca4836b4321d8", "receipt": { "to": null, - "from": "0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5", - "contractAddress": "0x195c6608705546725DF0629dd60690Cf2b367734", - "transactionIndex": 2, - "gasUsed": "720430", - "logsBloom": "0x00000000000000000000000000000000400000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000080000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000100000000000000010000000000000000000000000000020000000020000000000000000000008000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc20069c2a1a975c8617087e9007fedc7776971dd561b25fa1f583cee1dd70b02", - "transactionHash": "0xd41be29c0f527a0634980e9213d5f3aed9933a3ea7f9d1a228126bb9c88ce247", + "from": "0x5a5B978142C8F08Dd013901b50892baC49f3b700", + "contractAddress": "0x3a8C417a743A60ECfF3988C34783D65362b62915", + "transactionIndex": 11, + "gasUsed": "720722", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000002000000000000000000000000000000200000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000010000000000000000000000000000000000000000000820000000000040000000000000000000000400000000000000000000000000010000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xfc8618a13778c40afe3c1a511bccda6b52f71eede2f1b8488c3c45f1155a84ee", + "transactionHash": "0xdf1feb299ed55e26ff48be18210ad2466797877462fc58cf754ca4836b4321d8", "logs": [ { - "transactionIndex": 2, - "blockNumber": 8538452, - "transactionHash": "0xd41be29c0f527a0634980e9213d5f3aed9933a3ea7f9d1a228126bb9c88ce247", - "address": "0x195c6608705546725DF0629dd60690Cf2b367734", + "transactionIndex": 11, + "blockNumber": 8688915, + "transactionHash": "0xdf1feb299ed55e26ff48be18210ad2466797877462fc58cf754ca4836b4321d8", + "address": "0x3a8C417a743A60ECfF3988C34783D65362b62915", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x000000000000000000000000d6c3196e29ba5a267ca242e4c2b16cb65361c1f2" + "0x000000000000000000000000f67b9f261853393d2791d151159d3e2c575c1574" ], "data": "0x", "logIndex": 0, - "blockHash": "0xc20069c2a1a975c8617087e9007fedc7776971dd561b25fa1f583cee1dd70b02" + "blockHash": "0xfc8618a13778c40afe3c1a511bccda6b52f71eede2f1b8488c3c45f1155a84ee" }, { - "transactionIndex": 2, - "blockNumber": 8538452, - "transactionHash": "0xd41be29c0f527a0634980e9213d5f3aed9933a3ea7f9d1a228126bb9c88ce247", - "address": "0x195c6608705546725DF0629dd60690Cf2b367734", + "transactionIndex": 11, + "blockNumber": 8688915, + "transactionHash": "0xdf1feb299ed55e26ff48be18210ad2466797877462fc58cf754ca4836b4321d8", + "address": "0x3a8C417a743A60ECfF3988C34783D65362b62915", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000005956c8158bde236d8e3638362ff7555c329a839b", + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34dbcc2cbca28377e4a2079896a21ef5bfa68cc", "logIndex": 1, - "blockHash": "0xc20069c2a1a975c8617087e9007fedc7776971dd561b25fa1f583cee1dd70b02" + "blockHash": "0xfc8618a13778c40afe3c1a511bccda6b52f71eede2f1b8488c3c45f1155a84ee" } ], - "blockNumber": 8538452, - "cumulativeGasUsed": "762430", + "blockNumber": 8688915, + "cumulativeGasUsed": "951722", "status": 1, "byzantium": true }, "args": [ - "0xd6C3196E29ba5a267CA242E4C2B16cb65361c1f2", - "0x5956c8158bde236d8e3638362ff7555C329A839B", + "0xf67B9F261853393d2791d151159D3e2C575C1574", + "0xC34dbCc2cBCa28377e4A2079896a21ef5Bfa68Cc", "0x" ], "numDeployments": 1, diff --git a/packages/contracts/deployments/goerli/solcInputs/05370541c71c17418e30623d45438913.json b/packages/contracts/deployments/goerli/solcInputs/05370541c71c17418e30623d45438913.json new file mode 100644 index 000000000..b0da894fe --- /dev/null +++ b/packages/contracts/deployments/goerli/solcInputs/05370541c71c17418e30623d45438913.json @@ -0,0 +1,50 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n constructor(address implementation_) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "contracts/escrow/CollateralUpgradeableBeacon.sol": { + "content": "\n\npragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\";\n\ncontract CollateralUpgradeableBeacon is UpgradeableBeacon {\n\n\nconstructor(address _impl) UpgradeableBeacon(_impl) {}\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/packages/contracts/deployments/goerli/solcInputs/060a0e06ef3f72cfc1caa979d18de7ca.json b/packages/contracts/deployments/goerli/solcInputs/060a0e06ef3f72cfc1caa979d18de7ca.json deleted file mode 100644 index 42c84c122..000000000 --- a/packages/contracts/deployments/goerli/solcInputs/060a0e06ef3f72cfc1caa979d18de7ca.json +++ /dev/null @@ -1,329 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/CollateralManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n// Interfaces\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\";\nimport \"./interfaces/ICollateralManager.sol\";\nimport { Collateral, CollateralType, ICollateralEscrowV1 } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\nimport \"./interfaces/ITellerV2.sol\";\n\ncontract CollateralManager is OwnableUpgradeable, ICollateralManager {\n /* Storage */\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n ITellerV2 public tellerV2;\n address private collateralEscrowBeacon; // The address of the escrow contract beacon\n mapping(uint256 => address) public _escrows; // bidIds -> collateralEscrow\n // bidIds -> validated collateral info\n mapping(uint256 => CollateralInfo) internal _bidCollaterals;\n struct CollateralInfo {\n EnumerableSetUpgradeable.AddressSet collateralAddresses;\n mapping(address => Collateral) collateralInfo;\n }\n\n /* Events */\n event CollateralEscrowDeployed(uint256 _bidId, address _collateralEscrow);\n event CollateralCommitted(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n );\n event CollateralClaimed(uint256 _bidId);\n event CollateralDeposited(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n );\n event CollateralWithdrawn(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId,\n address _recipient\n );\n\n /* Modifiers */\n modifier onlyTellerV2() {\n require(_msgSender() == address(tellerV2), \"Sender not authorized\");\n _;\n }\n\n /* External Functions */\n\n /**\n * @notice Initializes the collateral manager.\n * @param _collateralEscrowBeacon The address of the escrow implementation.\n * @param _tellerV2 The address of the protocol.\n */\n function initialize(address _collateralEscrowBeacon, address _tellerV2)\n external\n initializer\n {\n collateralEscrowBeacon = _collateralEscrowBeacon;\n tellerV2 = ITellerV2(_tellerV2);\n __Ownable_init_unchained();\n }\n\n /**\n * @notice Sets the address of the Beacon contract used for the collateral escrow contracts.\n * @param _collateralEscrowBeacon The address of the Beacon contract.\n */\n function setCollateralEscrowBeacon(address _collateralEscrowBeacon)\n external\n reinitializer(2)\n {\n collateralEscrowBeacon = _collateralEscrowBeacon;\n }\n\n /**\n * @notice Checks to see if a bid is backed by collateral.\n * @param _bidId The id of the bid to check.\n */\n\n function isBidCollateralBacked(uint256 _bidId) public returns (bool) {\n return _bidCollaterals[_bidId].collateralAddresses.length() > 0;\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral assets.\n * @return validation_ Boolean indicating if the collateral balances were validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral[] calldata _collateralInfo\n ) public returns (bool validation_) {\n address borrower = tellerV2.getLoanBorrower(_bidId);\n (validation_, ) = checkBalances(borrower, _collateralInfo);\n if (validation_) {\n for (uint256 i; i < _collateralInfo.length; i++) {\n Collateral memory info = _collateralInfo[i];\n _commitCollateral(_bidId, info);\n }\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral calldata _collateralInfo\n ) public returns (bool validation_) {\n address borrower = tellerV2.getLoanBorrower(_bidId);\n validation_ = _checkBalance(borrower, _collateralInfo);\n if (validation_) {\n _commitCollateral(_bidId, _collateralInfo);\n }\n }\n\n /**\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\n * @param _bidId The id of the associated bid.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function revalidateCollateral(uint256 _bidId)\n external\n returns (bool validation_)\n {\n Collateral[] memory collateralInfos = getCollateralInfo(_bidId);\n address borrower = tellerV2.getLoanBorrower(_bidId);\n (validation_, ) = _checkBalances(borrower, collateralInfos, true);\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral assets.\n */\n function checkBalances(\n address _borrowerAddress,\n Collateral[] calldata _collateralInfo\n ) public returns (bool validated_, bool[] memory checks_) {\n return _checkBalances(_borrowerAddress, _collateralInfo, false);\n }\n\n /**\n * @notice Deploys a new collateral escrow and deposits collateral.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function deployAndDeposit(uint256 _bidId) external onlyTellerV2 {\n if (isBidCollateralBacked(_bidId)) {\n (address proxyAddress, ) = _deployEscrow(_bidId);\n _escrows[_bidId] = proxyAddress;\n\n for (\n uint256 i;\n i < _bidCollaterals[_bidId].collateralAddresses.length();\n i++\n ) {\n _deposit(\n _bidId,\n _bidCollaterals[_bidId].collateralInfo[\n _bidCollaterals[_bidId].collateralAddresses.at(i)\n ]\n );\n }\n\n emit CollateralEscrowDeployed(_bidId, proxyAddress);\n }\n }\n\n /**\n * @notice Gets the address of a deployed escrow.\n * @notice _bidId The bidId to return the escrow for.\n * @return The address of the escrow.\n */\n function getEscrow(uint256 _bidId) external view returns (address) {\n return _escrows[_bidId];\n }\n\n /**\n * @notice Gets the collateral info for a given bid id.\n * @param _bidId The bidId to return the collateral info for.\n * @return infos_ The stored collateral info.\n */\n function getCollateralInfo(uint256 _bidId)\n public\n view\n returns (Collateral[] memory infos_)\n {\n CollateralInfo storage collateral = _bidCollaterals[_bidId];\n address[] memory collateralAddresses = collateral\n .collateralAddresses\n .values();\n infos_ = new Collateral[](collateralAddresses.length);\n for (uint256 i; i < collateralAddresses.length; i++) {\n infos_[i] = collateral.collateralInfo[collateralAddresses[i]];\n }\n }\n\n /**\n * @notice Withdraws deposited collateral from the created escrow of a bid that has been successfully repaid.\n * @param _bidId The id of the bid to withdraw collateral for.\n */\n function withdraw(uint256 _bidId) external {\n BidState bidState = tellerV2.getBidState(_bidId);\n if (bidState == BidState.PAID) {\n _withdraw(_bidId, tellerV2.getLoanBorrower(_bidId));\n } else if (tellerV2.isLoanDefaulted(_bidId)) {\n _withdraw(_bidId, tellerV2.getLoanLender(_bidId));\n emit CollateralClaimed(_bidId);\n } else {\n revert(\"collateral cannot be withdrawn\");\n }\n }\n\n /**\n * @notice Sends the deposited collateral to a liquidator of a bid.\n * @notice Can only be called by the protocol.\n * @param _bidId The id of the liquidated bid.\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\n */\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\n external\n onlyTellerV2\n {\n if (isBidCollateralBacked(_bidId)) {\n BidState bidState = tellerV2.getBidState(_bidId);\n require(\n bidState == BidState.LIQUIDATED,\n \"Loan has not been liquidated\"\n );\n _withdraw(_bidId, _liquidatorAddress);\n }\n }\n\n /* Internal Functions */\n\n /**\n * @notice Deploys a new collateral escrow.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function _deployEscrow(uint256 _bidId)\n internal\n returns (address proxyAddress_, address borrower_)\n {\n proxyAddress_ = _escrows[_bidId];\n // Get bid info\n borrower_ = tellerV2.getLoanBorrower(_bidId);\n if (proxyAddress_ == address(0)) {\n require(borrower_ != address(0), \"Bid does not exist\");\n\n BeaconProxy proxy = new BeaconProxy(\n collateralEscrowBeacon,\n abi.encodeWithSelector(\n ICollateralEscrowV1.initialize.selector,\n _bidId\n )\n );\n proxyAddress_ = address(proxy);\n }\n }\n\n function _deposit(uint256 _bidId, Collateral memory collateralInfo)\n public\n payable\n {\n require(collateralInfo._amount > 0, \"Collateral not validated\");\n (address escrowAddress, address borrower) = _deployEscrow(_bidId);\n ICollateralEscrowV1 collateralEscrow = ICollateralEscrowV1(\n escrowAddress\n );\n // Pull collateral from borrower & deposit into escrow\n if (collateralInfo._collateralType == CollateralType.ERC20) {\n IERC20Upgradeable(collateralInfo._collateralAddress).transferFrom(\n borrower,\n address(this),\n collateralInfo._amount\n );\n IERC20Upgradeable(collateralInfo._collateralAddress).approve(\n escrowAddress,\n collateralInfo._amount\n );\n collateralEscrow.depositToken(\n collateralInfo._collateralAddress,\n collateralInfo._amount\n );\n } else if (collateralInfo._collateralType == CollateralType.ERC721) {\n IERC721Upgradeable(collateralInfo._collateralAddress).transferFrom(\n borrower,\n address(this),\n collateralInfo._tokenId\n );\n IERC721Upgradeable(collateralInfo._collateralAddress).approve(\n escrowAddress,\n collateralInfo._tokenId\n );\n collateralEscrow.depositAsset(\n CollateralType.ERC721,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n } else if (collateralInfo._collateralType == CollateralType.ERC1155) {\n bytes memory data;\n IERC1155Upgradeable(collateralInfo._collateralAddress)\n .safeTransferFrom(\n borrower,\n address(this),\n collateralInfo._tokenId,\n collateralInfo._amount,\n data\n );\n IERC1155Upgradeable(collateralInfo._collateralAddress)\n .setApprovalForAll(escrowAddress, true);\n collateralEscrow.depositAsset(\n CollateralType.ERC1155,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n }\n emit CollateralDeposited(\n _bidId,\n collateralInfo._collateralType,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n }\n\n /**\n * @notice Withdraws collateral to a given receiver's address.\n * @param _bidId The id of the bid to withdraw collateral for.\n * @param _receiver The address to withdraw the collateral to.\n */\n function _withdraw(uint256 _bidId, address _receiver) internal {\n for (\n uint256 i;\n i < _bidCollaterals[_bidId].collateralAddresses.length();\n i++\n ) {\n // Get collateral info\n Collateral storage collateralInfo = _bidCollaterals[_bidId]\n .collateralInfo[\n _bidCollaterals[_bidId].collateralAddresses.at(i)\n ];\n // Withdraw collateral from escrow and send it to bid lender\n ICollateralEscrowV1(_escrows[_bidId]).withdraw(\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n _receiver\n );\n emit CollateralWithdrawn(\n _bidId,\n collateralInfo._collateralType,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId,\n _receiver\n );\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function _commitCollateral(\n uint256 _bidId,\n Collateral memory _collateralInfo\n ) internal {\n CollateralInfo storage collateral = _bidCollaterals[_bidId];\n collateral.collateralAddresses.add(_collateralInfo._collateralAddress);\n collateral.collateralInfo[\n _collateralInfo._collateralAddress\n ] = _collateralInfo;\n emit CollateralCommitted(\n _bidId,\n _collateralInfo._collateralType,\n _collateralInfo._collateralAddress,\n _collateralInfo._amount,\n _collateralInfo._tokenId\n );\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral assets.\n */\n function _checkBalances(\n address _borrowerAddress,\n Collateral[] memory _collateralInfo,\n bool _shortCircut\n ) internal returns (bool validated_, bool[] memory checks_) {\n checks_ = new bool[](_collateralInfo.length);\n validated_ = true;\n for (uint256 i; i < _collateralInfo.length; i++) {\n bool isValidated = _checkBalance(\n _borrowerAddress,\n _collateralInfo[i]\n );\n checks_[i] = isValidated;\n if (!isValidated) {\n validated_ = false;\n if (_shortCircut) {\n return (validated_, checks_);\n }\n }\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's single collateral balance.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balances were validated.\n */\n function _checkBalance(\n address _borrowerAddress,\n Collateral memory _collateralInfo\n ) internal returns (bool) {\n CollateralType collateralType = _collateralInfo._collateralType;\n if (collateralType == CollateralType.ERC20) {\n return\n _collateralInfo._amount <=\n IERC20Upgradeable(_collateralInfo._collateralAddress).balanceOf(\n _borrowerAddress\n );\n }\n if (collateralType == CollateralType.ERC721) {\n return\n _borrowerAddress ==\n IERC721Upgradeable(_collateralInfo._collateralAddress).ownerOf(\n _collateralInfo._tokenId\n );\n }\n if (collateralType == CollateralType.ERC1155) {\n return\n _collateralInfo._amount <=\n IERC1155Upgradeable(_collateralInfo._collateralAddress)\n .balanceOf(_borrowerAddress, _collateralInfo._tokenId);\n }\n return false;\n }\n\n // On NFT Received handlers\n\n function onERC721Received(address, address, uint256, bytes calldata)\n external\n pure\n returns (bytes4)\n {\n return\n bytes4(\n keccak256(\"onERC721Received(address,address,uint256,bytes)\")\n );\n }\n\n function onERC1155Received(\n address,\n address,\n uint256 id,\n uint256 value,\n bytes calldata\n ) external returns (bytes4) {\n return\n bytes4(\n keccak256(\n \"onERC1155Received(address,address,uint256,uint256,bytes)\"\n )\n );\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata _ids,\n uint256[] calldata _values,\n bytes calldata\n ) external returns (bytes4) {\n require(\n _ids.length == 1,\n \"Only allowed one asset batch transfer per transaction.\"\n );\n return\n bytes4(\n keccak256(\n \"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"\n )\n );\n }\n}\n" - }, - "contracts/interfaces/ICollateralManager.sol": { - "content": "// SPDX-Licence-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nimport { Collateral } from \"./escrow/ICollateralEscrowV1.sol\";\n\ninterface ICollateralManager {\n /**\n * @notice Checks the validity of a borrower's collateral balance.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validation_);\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral calldata _collateralInfo\n ) external returns (bool validation_);\n\n function checkBalances(\n address _borrowerAddress,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validated_, bool[] memory checks_);\n\n /**\n * @notice Deploys a new collateral escrow.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function deployAndDeposit(uint256 _bidId) external;\n\n /**\n * @notice Gets the address of a deployed escrow.\n * @notice _bidId The bidId to return the escrow for.\n * @return The address of the escrow.\n */\n function getEscrow(uint256 _bidId) external view returns (address);\n\n /**\n * @notice Gets the collateral info for a given bid id.\n * @param _bidId The bidId to return the collateral info for.\n * @return The stored collateral info.\n */\n function getCollateralInfo(uint256 _bidId)\n external\n view\n returns (Collateral[] memory);\n\n /**\n * @notice Withdraws deposited collateral from the created escrow of a bid.\n * @param _bidId The id of the bid to withdraw collateral for.\n */\n function withdraw(uint256 _bidId) external;\n\n /**\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\n * @param _bidId The id of the associated bid.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function revalidateCollateral(uint256 _bidId) external returns (bool);\n\n /**\n * @notice Sends the deposited collateral to a liquidator of a bid.\n * @notice Can only be called by the protocol.\n * @param _bidId The id of the liquidated bid.\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\n */\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\n external;\n}\n" - }, - "contracts/interfaces/escrow/ICollateralEscrowV1.sol": { - "content": "// SPDX-Licence-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nenum CollateralType {\n ERC20,\n ERC721,\n ERC1155\n}\n\nstruct Collateral {\n CollateralType _collateralType;\n uint256 _amount;\n uint256 _tokenId;\n address _collateralAddress;\n}\n\ninterface ICollateralEscrowV1 {\n /**\n * @notice Deposits a collateral ERC20 token into the escrow.\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositToken(address _collateralAddress, uint256 _amount) external;\n\n /**\n * @notice Deposits a collateral asset into the escrow.\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositAsset(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) external payable;\n\n /**\n * @notice Withdraws a collateral asset from the escrow.\n * @param _collateralAddress The address of the collateral contract.\n * @param _amount The amount to withdraw.\n * @param _recipient The address to send the assets to.\n */\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) external;\n\n function getBid() external view returns (uint256);\n\n function initialize(uint256 _bidId) external;\n}\n" - }, - "contracts/interfaces/ITellerV2.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Payment, BidState } from \"../TellerV2Storage.sol\";\nimport { Collateral } from \"./escrow/ICollateralEscrowV1.sol\";\n\ninterface ITellerV2 {\n /**\n * @notice Function for a borrower to create a bid for a loan.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) external returns (uint256 bidId_);\n\n /**\n * @notice Function for a borrower to create a bid for a loan with Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) external returns (uint256 bidId_);\n\n /**\n * @notice Function for a lender to accept a proposed loan bid.\n * @param _bidId The id of the loan bid to accept.\n */\n function lenderAcceptBid(uint256 _bidId)\n external\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n );\n\n function calculateAmountDue(uint256 _bidId)\n external\n view\n returns (Payment memory due);\n\n /**\n * @notice Function for users to make the minimum amount due for an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanMinimum(uint256 _bidId) external;\n\n /**\n * @notice Function for users to repay an active loan in full.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanFull(uint256 _bidId) external;\n\n /**\n * @notice Function for users to make a payment towards an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _amount The amount of the payment.\n */\n function repayLoan(uint256 _bidId, uint256 _amount) external;\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isPaymentLate(uint256 _bidId) external view returns (bool);\n\n function getBidState(uint256 _bidId) external view returns (BidState);\n\n function getBorrowerActiveLoanIds(address _borrower)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @notice Returns the borrower address for a given bid.\n * @param _bidId The id of the bid/loan to get the borrower for.\n * @return borrower_ The address of the borrower associated with the bid.\n */\n function getLoanBorrower(uint256 _bidId)\n external\n view\n returns (address borrower_);\n\n /**\n * @notice Returns the lender address for a given bid.\n * @param _bidId The id of the bid/loan to get the lender for.\n * @return lender_ The address of the lender associated with the bid.\n */\n function getLoanLender(uint256 _bidId)\n external\n view\n returns (address lender_);\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_);\n\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^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 *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSetUpgradeable {\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 // 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) {\n // 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 if (lastIndex != toDeleteIndex) {\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] = valueIndex; // Replace lastValue's index to valueIndex\n }\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 return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 in 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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n" - }, - "contracts/TellerV2Storage.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport { IMarketRegistry } from \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/IReputationManager.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./interfaces/ICollateralManager.sol\";\nimport { PaymentType, PaymentCycleType } from \"./libraries/V2Calculations.sol\";\nimport \"./interfaces/ILenderManager.sol\";\n\nenum BidState {\n NONEXISTENT,\n PENDING,\n CANCELLED,\n ACCEPTED,\n PAID,\n LIQUIDATED\n}\n\n/**\n * @notice Represents a total amount for a payment.\n * @param principal Amount that counts towards the principal.\n * @param interest Amount that counts toward interest.\n */\nstruct Payment {\n uint256 principal;\n uint256 interest;\n}\n\n/**\n * @notice Details about a loan request.\n * @param borrower Account address who is requesting a loan.\n * @param receiver Account address who will receive the loan amount.\n * @param lender Account address who accepted and funded the loan request.\n * @param marketplaceId ID of the marketplace the bid was submitted to.\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\n * @param loanDetails Struct of the specific loan details.\n * @param terms Struct of the loan request terms.\n * @param state Represents the current state of the loan.\n */\nstruct Bid {\n address borrower;\n address receiver;\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\n uint256 marketplaceId;\n bytes32 _metadataURI; // DEPRECATED\n LoanDetails loanDetails;\n Terms terms;\n BidState state;\n PaymentType paymentType;\n}\n\n/**\n * @notice Details about the loan.\n * @param lendingToken The token address for the loan.\n * @param principal The amount of tokens initially lent out.\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\n * @param loanDuration The duration of the loan.\n */\nstruct LoanDetails {\n ERC20 lendingToken;\n uint256 principal;\n Payment totalRepaid;\n uint32 timestamp;\n uint32 acceptedTimestamp;\n uint32 lastRepaidTimestamp;\n uint32 loanDuration;\n}\n\n/**\n * @notice Information on the terms of a loan request\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\n */\nstruct Terms {\n uint256 paymentCycleAmount;\n uint32 paymentCycle;\n uint16 APR;\n}\n\nabstract contract TellerV2Storage_G0 {\n /** Storage Variables */\n\n // Current number of bids.\n uint256 public bidId = 0;\n\n // Mapping of bidId to bid information.\n mapping(uint256 => Bid) public bids;\n\n // Mapping of borrowers to borrower requests.\n mapping(address => uint256[]) public borrowerBids;\n\n // Mapping of volume filled by lenders.\n mapping(address => uint256) public _lenderVolumeFilled; // DEPRECIATED\n\n // Volume filled by all lenders.\n uint256 public _totalVolumeFilled; // DEPRECIATED\n\n // List of allowed lending tokens\n EnumerableSet.AddressSet internal lendingTokensSet;\n\n IMarketRegistry public marketRegistry;\n IReputationManager public reputationManager;\n\n // Mapping of borrowers to borrower requests.\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\n\n mapping(uint256 => uint32) public bidDefaultDuration;\n mapping(uint256 => uint32) public bidExpirationTime;\n\n // Mapping of volume filled by lenders.\n // Asset address => Lender address => Volume amount\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\n\n // Volume filled by all lenders.\n // Asset address => Volume amount\n mapping(address => uint256) public totalVolumeFilled;\n\n uint256 public version;\n\n // Mapping of metadataURIs by bidIds.\n // Bid Id => metadataURI string\n mapping(uint256 => string) public uris;\n}\n\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\n // market ID => trusted forwarder\n mapping(uint256 => address) internal _trustedMarketForwarders;\n // trusted forwarder => set of pre-approved senders\n mapping(address => EnumerableSet.AddressSet)\n internal _approvedForwarderSenders;\n}\n\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\n address public lenderCommitmentForwarder;\n}\n\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\n ICollateralManager public collateralManager;\n}\n\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\n // Address of the lender manager contract\n ILenderManager public lenderManager;\n // BidId to payment cycle type (custom or monthly)\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\n}\n\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\n" - }, - "contracts/interfaces/IMarketRegistry.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../EAS/TellerAS.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ninterface IMarketRegistry {\n function initialize(TellerAS tellerAs) external;\n\n function isVerifiedLender(uint256 _marketId, address _lender)\n external\n view\n returns (bool, bytes32);\n\n function isMarketClosed(uint256 _marketId) external view returns (bool);\n\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\n external\n view\n returns (bool, bytes32);\n\n function getMarketOwner(uint256 _marketId) external view returns (address);\n\n function getMarketFeeRecipient(uint256 _marketId)\n external\n view\n returns (address);\n\n function getMarketURI(uint256 _marketId)\n external\n view\n returns (string memory);\n\n function getPaymentCycle(uint256 _marketId)\n external\n view\n returns (uint32, PaymentCycleType);\n\n function getPaymentDefaultDuration(uint256 _marketId)\n external\n view\n returns (uint32);\n\n function getBidExpirationTime(uint256 _marketId)\n external\n view\n returns (uint32);\n\n function getMarketplaceFee(uint256 _marketId)\n external\n view\n returns (uint16);\n\n function getPaymentType(uint256 _marketId)\n external\n view\n returns (PaymentType);\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) external returns (uint256 marketId_);\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) external returns (uint256 marketId_);\n}\n" - }, - "contracts/interfaces/IReputationManager.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum RepMark {\n Good,\n Delinquent,\n Default\n}\n\ninterface IReputationManager {\n function initialize(address protocolAddress) external;\n\n function getDelinquentLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getDefaultedLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getCurrentDelinquentLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getCurrentDefaultLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function updateAccountReputation(address _account) external;\n\n function updateAccountReputation(address _account, uint256 _bidId)\n external\n returns (RepMark);\n}\n" - }, - "contracts/libraries/V2Calculations.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n// Libraries\nimport \"./NumbersLib.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport { Bid } from \"../TellerV2Storage.sol\";\n\nenum PaymentType {\n EMI,\n Bullet\n}\n\nenum PaymentCycleType {\n Seconds,\n Monthly\n}\n\nlibrary V2Calculations {\n using NumbersLib for uint256;\n\n /**\n * @notice Returns the timestamp of the last payment made for a loan.\n * @param _bid The loan bid struct to get the timestamp for.\n */\n function lastRepaidTimestamp(Bid storage _bid)\n internal\n view\n returns (uint32)\n {\n return\n _bid.loanDetails.lastRepaidTimestamp == 0\n ? _bid.loanDetails.acceptedTimestamp\n : _bid.loanDetails.lastRepaidTimestamp;\n }\n\n /**\n * @notice Calculates the amount owed for a loan.\n * @param _bid The loan bid struct to get the owed amount for.\n * @param _timestamp The timestamp at which to get the owed amount at.\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\n */\n function calculateAmountOwed(\n Bid storage _bid,\n uint256 _timestamp,\n PaymentCycleType _paymentCycleType\n )\n internal\n view\n returns (\n uint256 owedPrincipal_,\n uint256 duePrincipal_,\n uint256 interest_\n )\n {\n // Total principal left to pay\n return\n calculateAmountOwed(\n _bid,\n lastRepaidTimestamp(_bid),\n _timestamp,\n _paymentCycleType\n );\n }\n\n function calculateAmountOwed(\n Bid storage _bid,\n uint256 _lastRepaidTimestamp,\n uint256 _timestamp,\n PaymentCycleType _paymentCycleType\n )\n internal\n view\n returns (\n uint256 owedPrincipal_,\n uint256 duePrincipal_,\n uint256 interest_\n )\n {\n owedPrincipal_ =\n _bid.loanDetails.principal -\n _bid.loanDetails.totalRepaid.principal;\n\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\n ? 360 days\n : 365 days;\n\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\n\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\n int256 durationLeftOnLoan = int256(\n uint256(_bid.loanDetails.loanDuration)\n ) -\n (int256(_timestamp) -\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\n bool isLastPaymentCycle = durationLeftOnLoan <\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\n\n if (_bid.paymentType == PaymentType.Bullet) {\n if (isLastPaymentCycle) {\n duePrincipal_ = owedPrincipal_;\n }\n } else {\n // Default to PaymentType.EMI\n // Max payable amount in a cycle\n // NOTE: the last cycle could have less than the calculated payment amount\n uint256 maxCycleOwed = isLastPaymentCycle\n ? owedPrincipal_ + interest_\n : _bid.terms.paymentCycleAmount;\n\n // Calculate accrued amount due since last repayment\n uint256 owedAmount = (maxCycleOwed * owedTime) /\n _bid.terms.paymentCycle;\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\n }\n }\n\n /**\n * @notice Calculates the amount owed for a loan for the next payment cycle.\n * @param _type The payment type of the loan.\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\n * @param _principal The starting amount that is owed on the loan.\n * @param _duration The length of the loan.\n * @param _paymentCycle The length of the loan's payment cycle.\n * @param _apr The annual percentage rate of the loan.\n */\n function calculatePaymentCycleAmount(\n PaymentType _type,\n PaymentCycleType _cycleType,\n uint256 _principal,\n uint32 _duration,\n uint32 _paymentCycle,\n uint16 _apr\n ) internal returns (uint256) {\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\n ? 360 days\n : 365 days;\n if (_type == PaymentType.Bullet) {\n return\n _principal.percent(_apr).percent(\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\n 10\n );\n }\n // Default to PaymentType.EMI\n return\n NumbersLib.pmt(\n _principal,\n _duration,\n _paymentCycle,\n _apr,\n daysInYear\n );\n }\n}\n" - }, - "contracts/interfaces/ILenderManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\n\nabstract contract ILenderManager is IERC721Upgradeable {\n /**\n * @notice Registers a new active lender for a loan, minting the nft.\n * @param _bidId The id for the loan to set.\n * @param _newLender The address of the new active lender.\n */\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\n}\n" - }, - "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^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 *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\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 // 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) {\n // 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 if (lastIndex != toDeleteIndex) {\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] = valueIndex; // Replace lastValue's index to valueIndex\n }\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 return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 in 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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * 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, IERC20Metadata {\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\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override 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 override 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 this function is\n * overridden;\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 override returns (uint8) {\n return 18;\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 * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\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 address owner = _msgSender();\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\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 address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This 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 * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(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(\n address owner,\n address spender,\n uint256 amount\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\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 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after 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 * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" - }, - "contracts/EAS/TellerAS.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../Types.sol\";\nimport \"../interfaces/IEAS.sol\";\nimport \"../interfaces/IASRegistry.sol\";\n\n/**\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\n */\ncontract TellerAS is IEAS {\n error AccessDenied();\n error AlreadyRevoked();\n error InvalidAttestation();\n error InvalidExpirationTime();\n error InvalidOffset();\n error InvalidRegistry();\n error InvalidSchema();\n error InvalidVerifier();\n error NotFound();\n error NotPayable();\n\n string public constant VERSION = \"0.8\";\n\n // A terminator used when concatenating and hashing multiple fields.\n string private constant HASH_TERMINATOR = \"@\";\n\n // The AS global registry.\n IASRegistry private immutable _asRegistry;\n\n // The EIP712 verifier used to verify signed attestations.\n IEASEIP712Verifier private immutable _eip712Verifier;\n\n // A mapping between attestations and their related attestations.\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\n\n // A mapping between an account and its received attestations.\n mapping(address => mapping(bytes32 => bytes32[]))\n private _receivedAttestations;\n\n // A mapping between an account and its sent attestations.\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\n\n // A mapping between a schema and its attestations.\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\n\n // The global mapping between attestations and their UUIDs.\n mapping(bytes32 => Attestation) private _db;\n\n // The global counter for the total number of attestations.\n uint256 private _attestationsCount;\n\n bytes32 private _lastUUID;\n\n /**\n * @dev Creates a new EAS instance.\n *\n * @param registry The address of the global AS registry.\n * @param verifier The address of the EIP712 verifier.\n */\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\n if (address(registry) == address(0x0)) {\n revert InvalidRegistry();\n }\n\n if (address(verifier) == address(0x0)) {\n revert InvalidVerifier();\n }\n\n _asRegistry = registry;\n _eip712Verifier = verifier;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getASRegistry() external view override returns (IASRegistry) {\n return _asRegistry;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getEIP712Verifier()\n external\n view\n override\n returns (IEASEIP712Verifier)\n {\n return _eip712Verifier;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getAttestationsCount() external view override returns (uint256) {\n return _attestationsCount;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data\n ) public payable virtual override returns (bytes32) {\n return\n _attest(\n recipient,\n schema,\n expirationTime,\n refUUID,\n data,\n msg.sender\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function attestByDelegation(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public payable virtual override returns (bytes32) {\n _eip712Verifier.attest(\n recipient,\n schema,\n expirationTime,\n refUUID,\n data,\n attester,\n v,\n r,\n s\n );\n\n return\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function revoke(bytes32 uuid) public virtual override {\n return _revoke(uuid, msg.sender);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function revokeByDelegation(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n _eip712Verifier.revoke(uuid, attester, v, r, s);\n\n _revoke(uuid, attester);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getAttestation(bytes32 uuid)\n external\n view\n override\n returns (Attestation memory)\n {\n return _db[uuid];\n }\n\n /**\n * @inheritdoc IEAS\n */\n function isAttestationValid(bytes32 uuid)\n public\n view\n override\n returns (bool)\n {\n return _db[uuid].uuid != 0;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function isAttestationActive(bytes32 uuid)\n public\n view\n override\n returns (bool)\n {\n return\n isAttestationValid(uuid) &&\n _db[uuid].expirationTime >= block.timestamp &&\n _db[uuid].revocationTime == 0;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getReceivedAttestationUUIDs(\n address recipient,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _receivedAttestations[recipient][schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _receivedAttestations[recipient][schema].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSentAttestationUUIDs(\n address attester,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _sentAttestations[attester][schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _sentAttestations[recipient][schema].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getRelatedAttestationUUIDs(\n bytes32 uuid,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _relatedAttestations[uuid],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\n external\n view\n override\n returns (uint256)\n {\n return _relatedAttestations[uuid].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSchemaAttestationUUIDs(\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _schemaAttestations[schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSchemaAttestationUUIDsCount(bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _schemaAttestations[schema].length;\n }\n\n /**\n * @dev Attests to a specific AS.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n *\n * @return The UUID of the new attestation.\n */\n function _attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester\n ) private returns (bytes32) {\n if (expirationTime <= block.timestamp) {\n revert InvalidExpirationTime();\n }\n\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\n if (asRecord.uuid == EMPTY_UUID) {\n revert InvalidSchema();\n }\n\n IASResolver resolver = asRecord.resolver;\n if (address(resolver) != address(0x0)) {\n if (msg.value != 0 && !resolver.isPayable()) {\n revert NotPayable();\n }\n\n if (\n !resolver.resolve{ value: msg.value }(\n recipient,\n asRecord.schema,\n data,\n expirationTime,\n attester\n )\n ) {\n revert InvalidAttestation();\n }\n }\n\n Attestation memory attestation = Attestation({\n uuid: EMPTY_UUID,\n schema: schema,\n recipient: recipient,\n attester: attester,\n time: block.timestamp,\n expirationTime: expirationTime,\n revocationTime: 0,\n refUUID: refUUID,\n data: data\n });\n\n _lastUUID = _getUUID(attestation);\n attestation.uuid = _lastUUID;\n\n _receivedAttestations[recipient][schema].push(_lastUUID);\n _sentAttestations[attester][schema].push(_lastUUID);\n _schemaAttestations[schema].push(_lastUUID);\n\n _db[_lastUUID] = attestation;\n _attestationsCount++;\n\n if (refUUID != 0) {\n if (!isAttestationValid(refUUID)) {\n revert NotFound();\n }\n\n _relatedAttestations[refUUID].push(_lastUUID);\n }\n\n emit Attested(recipient, attester, _lastUUID, schema);\n\n return _lastUUID;\n }\n\n function getLastUUID() external view returns (bytes32) {\n return _lastUUID;\n }\n\n /**\n * @dev Revokes an existing attestation to a specific AS.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n */\n function _revoke(bytes32 uuid, address attester) private {\n Attestation storage attestation = _db[uuid];\n if (attestation.uuid == EMPTY_UUID) {\n revert NotFound();\n }\n\n if (attestation.attester != attester) {\n revert AccessDenied();\n }\n\n if (attestation.revocationTime != 0) {\n revert AlreadyRevoked();\n }\n\n attestation.revocationTime = block.timestamp;\n\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\n }\n\n /**\n * @dev Calculates a UUID for a given attestation.\n *\n * @param attestation The input attestation.\n *\n * @return Attestation UUID.\n */\n function _getUUID(Attestation memory attestation)\n private\n view\n returns (bytes32)\n {\n return\n keccak256(\n abi.encodePacked(\n attestation.schema,\n attestation.recipient,\n attestation.attester,\n attestation.time,\n attestation.expirationTime,\n attestation.data,\n HASH_TERMINATOR,\n _attestationsCount\n )\n );\n }\n\n /**\n * @dev Returns a slice in an array of attestation UUIDs.\n *\n * @param uuids The array of attestation UUIDs.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function _sliceUUIDs(\n bytes32[] memory uuids,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) private pure returns (bytes32[] memory) {\n uint256 attestationsLength = uuids.length;\n if (attestationsLength == 0) {\n return new bytes32[](0);\n }\n\n if (start >= attestationsLength) {\n revert InvalidOffset();\n }\n\n uint256 len = length;\n if (attestationsLength < start + length) {\n len = attestationsLength - start;\n }\n\n bytes32[] memory res = new bytes32[](len);\n\n for (uint256 i = 0; i < len; ++i) {\n res[i] = uuids[\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\n ];\n }\n\n return res;\n }\n}\n" - }, - "contracts/Types.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// A representation of an empty/uninitialized UUID.\nbytes32 constant EMPTY_UUID = 0;\n" - }, - "contracts/interfaces/IEAS.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./IASRegistry.sol\";\nimport \"./IEASEIP712Verifier.sol\";\n\n/**\n * @title EAS - Ethereum Attestation Service interface\n */\ninterface IEAS {\n /**\n * @dev A struct representing a single attestation.\n */\n struct Attestation {\n // A unique identifier of the attestation.\n bytes32 uuid;\n // A unique identifier of the AS.\n bytes32 schema;\n // The recipient of the attestation.\n address recipient;\n // The attester/sender of the attestation.\n address attester;\n // The time when the attestation was created (Unix timestamp).\n uint256 time;\n // The time when the attestation expires (Unix timestamp).\n uint256 expirationTime;\n // The time when the attestation was revoked (Unix timestamp).\n uint256 revocationTime;\n // The UUID of the related attestation.\n bytes32 refUUID;\n // Custom attestation data.\n bytes data;\n }\n\n /**\n * @dev Triggered when an attestation has been made.\n *\n * @param recipient The recipient of the attestation.\n * @param attester The attesting account.\n * @param uuid The UUID the revoked attestation.\n * @param schema The UUID of the AS.\n */\n event Attested(\n address indexed recipient,\n address indexed attester,\n bytes32 uuid,\n bytes32 indexed schema\n );\n\n /**\n * @dev Triggered when an attestation has been revoked.\n *\n * @param recipient The recipient of the attestation.\n * @param attester The attesting account.\n * @param schema The UUID of the AS.\n * @param uuid The UUID the revoked attestation.\n */\n event Revoked(\n address indexed recipient,\n address indexed attester,\n bytes32 uuid,\n bytes32 indexed schema\n );\n\n /**\n * @dev Returns the address of the AS global registry.\n *\n * @return The address of the AS global registry.\n */\n function getASRegistry() external view returns (IASRegistry);\n\n /**\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\n *\n * @return The address of the EIP712 verifier used to verify signed attestations.\n */\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\n\n /**\n * @dev Returns the global counter for the total number of attestations.\n *\n * @return The global counter for the total number of attestations.\n */\n function getAttestationsCount() external view returns (uint256);\n\n /**\n * @dev Attests to a specific AS.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n *\n * @return The UUID of the new attestation.\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data\n ) external payable returns (bytes32);\n\n /**\n * @dev Attests to a specific AS using a provided EIP712 signature.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n *\n * @return The UUID of the new attestation.\n */\n function attestByDelegation(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external payable returns (bytes32);\n\n /**\n * @dev Revokes an existing attestation to a specific AS.\n *\n * @param uuid The UUID of the attestation to revoke.\n */\n function revoke(bytes32 uuid) external;\n\n /**\n * @dev Attests to a specific AS using a provided EIP712 signature.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function revokeByDelegation(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns an existing attestation by UUID.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return The attestation data members.\n */\n function getAttestation(bytes32 uuid)\n external\n view\n returns (Attestation memory);\n\n /**\n * @dev Checks whether an attestation exists.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return Whether an attestation exists.\n */\n function isAttestationValid(bytes32 uuid) external view returns (bool);\n\n /**\n * @dev Checks whether an attestation is active.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return Whether an attestation is active.\n */\n function isAttestationActive(bytes32 uuid) external view returns (bool);\n\n /**\n * @dev Returns all received attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getReceivedAttestationUUIDs(\n address recipient,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of received attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all sent attestation UUIDs.\n *\n * @param attester The attesting account.\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getSentAttestationUUIDs(\n address attester,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of sent attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all attestations related to a specific attestation.\n *\n * @param uuid The UUID of the attestation to retrieve.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getRelatedAttestationUUIDs(\n bytes32 uuid,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of related attestation UUIDs.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return The number of related attestations.\n */\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all per-schema attestation UUIDs.\n *\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getSchemaAttestationUUIDs(\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of per-schema attestation UUIDs.\n *\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getSchemaAttestationUUIDsCount(bytes32 schema)\n external\n view\n returns (uint256);\n}\n" - }, - "contracts/interfaces/IASRegistry.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./IASResolver.sol\";\n\n/**\n * @title The global AS registry interface.\n */\ninterface IASRegistry {\n /**\n * @title A struct representing a record for a submitted AS (Attestation Schema).\n */\n struct ASRecord {\n // A unique identifier of the AS.\n bytes32 uuid;\n // Optional schema resolver.\n IASResolver resolver;\n // Auto-incrementing index for reference, assigned by the registry itself.\n uint256 index;\n // Custom specification of the AS (e.g., an ABI).\n bytes schema;\n }\n\n /**\n * @dev Triggered when a new AS has been registered\n *\n * @param uuid The AS UUID.\n * @param index The AS index.\n * @param schema The AS schema.\n * @param resolver An optional AS schema resolver.\n * @param attester The address of the account used to register the AS.\n */\n event Registered(\n bytes32 indexed uuid,\n uint256 indexed index,\n bytes schema,\n IASResolver resolver,\n address attester\n );\n\n /**\n * @dev Submits and reserve a new AS\n *\n * @param schema The AS data schema.\n * @param resolver An optional AS schema resolver.\n *\n * @return The UUID of the new AS.\n */\n function register(bytes calldata schema, IASResolver resolver)\n external\n returns (bytes32);\n\n /**\n * @dev Returns an existing AS by UUID\n *\n * @param uuid The UUID of the AS to retrieve.\n *\n * @return The AS data members.\n */\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\n\n /**\n * @dev Returns the global counter for the total number of attestations\n *\n * @return The global counter for the total number of attestations.\n */\n function getASCount() external view returns (uint256);\n}\n" - }, - "contracts/interfaces/IEASEIP712Verifier.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n/**\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\n */\ninterface IEASEIP712Verifier {\n /**\n * @dev Returns the current nonce per-account.\n *\n * @param account The requested accunt.\n *\n * @return The current nonce.\n */\n function getNonce(address account) external view returns (uint256);\n\n /**\n * @dev Verifies signed attestation.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Verifies signed revocations.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function revoke(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" - }, - "contracts/interfaces/IASResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n/**\n * @title The interface of an optional AS resolver.\n */\ninterface IASResolver {\n /**\n * @dev Returns whether the resolver supports ETH transfers\n */\n function isPayable() external pure returns (bool);\n\n /**\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The AS data schema.\n * @param data The actual attestation data.\n * @param expirationTime The expiration time of the attestation.\n * @param msgSender The sender of the original attestation message.\n *\n * @return Whether the data is valid according to the scheme.\n */\n function resolve(\n address recipient,\n bytes calldata schema,\n bytes calldata data,\n uint256 expirationTime,\n address msgSender\n ) external payable returns (bool);\n}\n" - }, - "contracts/libraries/NumbersLib.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// Libraries\nimport { SafeCast } from \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport { Math } from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./WadRayMath.sol\";\n\n/**\n * @dev Utility library for uint256 numbers\n *\n * @author develop@teller.finance\n */\nlibrary NumbersLib {\n using WadRayMath for uint256;\n\n /**\n * @dev It represents 100% with 2 decimal places.\n */\n uint16 internal constant PCT_100 = 10000;\n\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\n return 100 * (10**decimals);\n }\n\n /**\n * @notice Returns a percentage value of a number.\n * @param self The number to get a percentage of.\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\n */\n function percent(uint256 self, uint16 percentage)\n internal\n pure\n returns (uint256)\n {\n return percent(self, percentage, 2);\n }\n\n /**\n * @notice Returns a percentage value of a number.\n * @param self The number to get a percentage of.\n * @param percentage The percentage value to calculate with.\n * @param decimals The number of decimals the percentage value is in.\n */\n function percent(uint256 self, uint256 percentage, uint256 decimals)\n internal\n pure\n returns (uint256)\n {\n return (self * percentage) / percentFactor(decimals);\n }\n\n /**\n * @notice it returns the absolute number of a specified parameter\n * @param self the number to be returned in it's absolute\n * @return the absolute number\n */\n function abs(int256 self) internal pure returns (uint256) {\n return self >= 0 ? uint256(self) : uint256(-1 * self);\n }\n\n /**\n * @notice Returns a ratio percentage of {num1} to {num2}.\n * @dev Returned value is type uint16.\n * @param num1 The number used to get the ratio for.\n * @param num2 The number used to get the ratio from.\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\n */\n function ratioOf(uint256 num1, uint256 num2)\n internal\n pure\n returns (uint16)\n {\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\n }\n\n /**\n * @notice Returns a ratio percentage of {num1} to {num2}.\n * @param num1 The number used to get the ratio for.\n * @param num2 The number used to get the ratio from.\n * @param decimals The number of decimals the percentage value is returned in.\n * @return Ratio percentage value.\n */\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\n internal\n pure\n returns (uint256)\n {\n if (num2 == 0) return 0;\n return (num1 * percentFactor(decimals)) / num2;\n }\n\n /**\n * @notice Calculates the payment amount for a cycle duration.\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\n * @param principal The starting amount that is owed on the loan.\n * @param loanDuration The length of the loan.\n * @param cycleDuration The length of the loan's payment cycle.\n * @param apr The annual percentage rate of the loan.\n */\n function pmt(\n uint256 principal,\n uint32 loanDuration,\n uint32 cycleDuration,\n uint16 apr,\n uint256 daysInYear\n ) internal pure returns (uint256) {\n require(\n loanDuration >= cycleDuration,\n \"PMT: cycle duration < loan duration\"\n );\n if (apr == 0)\n return\n Math.mulDiv(\n principal,\n cycleDuration,\n loanDuration,\n Math.Rounding.Up\n );\n\n // Number of payment cycles for the duration of the loan\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\n\n uint256 one = WadRayMath.wad();\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\n daysInYear\n );\n uint256 exp = (one + r).wadPow(n);\n uint256 numerator = principal.wadMul(r).wadMul(exp);\n uint256 denominator = exp - one;\n\n return numerator.wadDiv(denominator);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" - }, - "contracts/libraries/WadRayMath.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\n/**\n * @title WadRayMath library\n * @author Multiplier Finance\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\n */\nlibrary WadRayMath {\n using SafeMath for uint256;\n\n uint256 internal constant WAD = 1e18;\n uint256 internal constant halfWAD = WAD / 2;\n\n uint256 internal constant RAY = 1e27;\n uint256 internal constant halfRAY = RAY / 2;\n\n uint256 internal constant WAD_RAY_RATIO = 1e9;\n uint256 internal constant PCT_WAD_RATIO = 1e14;\n uint256 internal constant PCT_RAY_RATIO = 1e23;\n\n function ray() internal pure returns (uint256) {\n return RAY;\n }\n\n function wad() internal pure returns (uint256) {\n return WAD;\n }\n\n function halfRay() internal pure returns (uint256) {\n return halfRAY;\n }\n\n function halfWad() internal pure returns (uint256) {\n return halfWAD;\n }\n\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\n return halfWAD.add(a.mul(b)).div(WAD);\n }\n\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 halfB = b / 2;\n\n return halfB.add(a.mul(WAD)).div(b);\n }\n\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\n return halfRAY.add(a.mul(b)).div(RAY);\n }\n\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 halfB = b / 2;\n\n return halfB.add(a.mul(RAY)).div(b);\n }\n\n function rayToWad(uint256 a) internal pure returns (uint256) {\n uint256 halfRatio = WAD_RAY_RATIO / 2;\n\n return halfRatio.add(a).div(WAD_RAY_RATIO);\n }\n\n function rayToPct(uint256 a) internal pure returns (uint16) {\n uint256 halfRatio = PCT_RAY_RATIO / 2;\n\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\n return SafeCast.toUint16(val);\n }\n\n function wadToPct(uint256 a) internal pure returns (uint16) {\n uint256 halfRatio = PCT_WAD_RATIO / 2;\n\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\n return SafeCast.toUint16(val);\n }\n\n function wadToRay(uint256 a) internal pure returns (uint256) {\n return a.mul(WAD_RAY_RATIO);\n }\n\n function pctToRay(uint16 a) internal pure returns (uint256) {\n return uint256(a).mul(RAY).div(1e4);\n }\n\n function pctToWad(uint16 a) internal pure returns (uint256) {\n return uint256(a).mul(WAD).div(1e4);\n }\n\n /**\n * @dev calculates base^duration. The code uses the ModExp precompile\n * @return z base^duration, in ray\n */\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\n return _pow(x, n, RAY, rayMul);\n }\n\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\n return _pow(x, n, WAD, wadMul);\n }\n\n function _pow(\n uint256 x,\n uint256 n,\n uint256 p,\n function(uint256, uint256) internal pure returns (uint256) mul\n ) internal pure returns (uint256 z) {\n z = n % 2 != 0 ? x : p;\n\n for (n /= 2; n != 0; n /= 2) {\n x = mul(x, x);\n\n if (n % 2 != 0) {\n z = mul(z, x);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeCast.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\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 unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction 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 unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\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 unchecked {\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 /**\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 unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\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 unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\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 return a + b;\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 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 return a * b;\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.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\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 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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\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 * 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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a / b;\n }\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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" - }, - "contracts/tests/TellerV2_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../escrow/CollateralEscrowV1.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\";\nimport \"../LenderCommitmentForwarder.sol\";\nimport \"./resolvers/TestERC20Token.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"../CollateralManager.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\nimport { BidState, Payment } from \"../TellerV2Storage.sol\";\nimport \"../MetaForwarder.sol\";\nimport { LenderManager } from \"../LenderManager.sol\";\n\ncontract TellerV2_Test is Testable {\n TellerV2User private marketOwner;\n TellerV2User private borrower;\n TellerV2User private lender;\n\n TellerV2 tellerV2;\n\n WethMock wethMock;\n TestERC20Token daiMock;\n CollateralManager collateralManager;\n\n uint256 marketId1;\n uint256 collateralAmount = 10;\n\n function setup_beforeAll() public {\n // Deploy test tokens\n wethMock = new WethMock();\n daiMock = new TestERC20Token(\"Dai\", \"DAI\", 10000000, 18);\n\n // Deploy Escrow beacon\n CollateralEscrowV1 escrowImplementation = new CollateralEscrowV1();\n UpgradeableBeacon escrowBeacon = new UpgradeableBeacon(\n address(escrowImplementation)\n );\n\n // Deploy protocol\n tellerV2 = new TellerV2(address(0));\n\n // Deploy MarketRegistry & ReputationManager\n IMarketRegistry marketRegistry = IMarketRegistry(new MarketRegistry());\n IReputationManager reputationManager = IReputationManager(\n new ReputationManager()\n );\n reputationManager.initialize(address(tellerV2));\n\n // Deploy Collateral manager\n collateralManager = new CollateralManager();\n collateralManager.initialize(address(escrowBeacon), address(tellerV2));\n\n // Deploy Lender manager\n MetaForwarder metaforwarder = new MetaForwarder();\n metaforwarder.initialize();\n LenderManager lenderManager = new LenderManager((marketRegistry));\n lenderManager.initialize();\n lenderManager.transferOwnership(address(tellerV2));\n\n // Deploy LenderCommitmentForwarder\n LenderCommitmentForwarder lenderCommitmentForwarder = new LenderCommitmentForwarder(\n address(tellerV2),\n address(marketRegistry)\n );\n\n address[] memory lendingTokens = new address[](2);\n lendingTokens[0] = address(wethMock);\n lendingTokens[1] = address(daiMock);\n\n // Initialize protocol\n tellerV2.initialize(\n 50,\n address(marketRegistry),\n address(reputationManager),\n address(lenderCommitmentForwarder),\n lendingTokens,\n address(collateralManager),\n address(lenderManager)\n );\n\n // Instantiate users & balances\n marketOwner = new TellerV2User(address(tellerV2), wethMock);\n borrower = new TellerV2User(address(tellerV2), wethMock);\n lender = new TellerV2User(address(tellerV2), wethMock);\n\n uint256 balance = 50000;\n payable(address(borrower)).transfer(balance);\n payable(address(lender)).transfer(balance * 10);\n borrower.depositToWeth(balance);\n lender.depositToWeth(balance * 10);\n\n daiMock.transfer(address(lender), balance * 10);\n daiMock.transfer(address(borrower), balance);\n // Approve Teller V2 for the lender's dai\n lender.addAllowance(address(daiMock), address(tellerV2), balance * 10);\n\n // Create a market\n marketId1 = marketOwner.createMarket(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n \"uri://\"\n );\n }\n\n function submitCollateralBid() public returns (uint256 bidId_) {\n Collateral memory info;\n info._amount = collateralAmount;\n info._tokenId = 0;\n info._collateralType = CollateralType.ERC20;\n info._collateralAddress = address(wethMock);\n\n Collateral[] memory collateralInfo = new Collateral[](1);\n collateralInfo[0] = info;\n\n uint256 bal = wethMock.balanceOf(address(borrower));\n\n // Increase allowance\n // Approve the collateral manager for the borrower's weth\n borrower.addAllowance(\n address(wethMock),\n address(collateralManager),\n info._amount\n );\n\n bidId_ = borrower.submitCollateralBid(\n address(daiMock),\n marketId1,\n 100,\n 10000,\n 500,\n \"metadataUri://\",\n address(borrower),\n collateralInfo\n );\n }\n\n function acceptBid(uint256 _bidId) public {\n // Accept bid\n lender.acceptBid(_bidId);\n }\n\n function collateralEscrow_test() public {\n // Submit bid as borrower\n uint256 bidId = submitCollateralBid();\n // Accept bid as lender\n acceptBid(bidId);\n\n // Get newly created escrow\n address escrowAddress = collateralManager._escrows(bidId);\n CollateralEscrowV1 escrow = CollateralEscrowV1(escrowAddress);\n\n uint256 storedBidId = escrow.getBid();\n\n // Test that the created escrow has the same bidId and collateral stored\n Test.eq(bidId, storedBidId, \"Collateral escrow was not created\");\n\n uint256 escrowBalance = wethMock.balanceOf(escrowAddress);\n\n Test.eq(collateralAmount, escrowBalance, \"Collateral was not stored\");\n\n // Repay loan\n uint256 borrowerBalanceBefore = wethMock.balanceOf(address(borrower));\n Payment memory amountOwed = tellerV2.calculateAmountOwed(bidId);\n borrower.addAllowance(\n address(daiMock),\n address(tellerV2),\n amountOwed.principal + amountOwed.interest\n );\n borrower.repayLoanFull(bidId);\n\n // Check escrow balance\n uint256 escrowBalanceAfter = wethMock.balanceOf(escrowAddress);\n Test.eq(\n 0,\n escrowBalanceAfter,\n \"Collateral was not withdrawn from escrow on repayment\"\n );\n\n // Check borrower balance for collateral\n uint256 borrowerBalanceAfter = wethMock.balanceOf(address(borrower));\n Test.eq(\n collateralAmount,\n borrowerBalanceAfter - borrowerBalanceBefore,\n \"Collateral was not sent to borrower after repayment\"\n );\n }\n}\n\ncontract TellerV2User is User {\n WethMock public immutable wethMock;\n\n constructor(address _tellerV2, WethMock _wethMock) User(_tellerV2) {\n wethMock = _wethMock;\n }\n\n function depositToWeth(uint256 amount) public {\n wethMock.deposit{ value: amount }();\n }\n}\n" - }, - "contracts/tests/Testable.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\nabstract contract Testable {\n receive() external payable {}\n}\n" - }, - "contracts/TellerV2.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./ProtocolFee.sol\";\nimport \"./TellerV2Storage.sol\";\nimport \"./TellerV2Context.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/IReputationManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport { Collateral } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\nimport { BokkyPooBahsDateTimeLibrary as BPBDTL } from \"./libraries/DateTimeLib.sol\";\nimport { V2Calculations, PaymentCycleType } from \"./libraries/V2Calculations.sol\";\n\n/* Errors */\n/**\n * @notice This error is reverted when the action isn't allowed\n * @param bidId The id of the bid.\n * @param action The action string (i.e: 'repayLoan', 'cancelBid', 'etc)\n * @param message The message string to return to the user explaining why the tx was reverted\n */\nerror ActionNotAllowed(uint256 bidId, string action, string message);\n\n/**\n * @notice This error is reverted when repayment amount is less than the required minimum\n * @param bidId The id of the bid the borrower is attempting to repay.\n * @param payment The payment made by the borrower\n * @param minimumOwed The minimum owed value\n */\nerror PaymentNotMinimum(uint256 bidId, uint256 payment, uint256 minimumOwed);\n\ncontract TellerV2 is\n ITellerV2,\n OwnableUpgradeable,\n ProtocolFee,\n PausableUpgradeable,\n TellerV2Storage,\n TellerV2Context\n{\n using Address for address;\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /** Events */\n\n /**\n * @notice This event is emitted when a new bid is submitted.\n * @param bidId The id of the bid submitted.\n * @param borrower The address of the bid borrower.\n * @param metadataURI URI for additional bid information as part of loan bid.\n */\n event SubmittedBid(\n uint256 indexed bidId,\n address indexed borrower,\n address receiver,\n bytes32 indexed metadataURI\n );\n\n /**\n * @notice This event is emitted when a bid has been accepted by a lender.\n * @param bidId The id of the bid accepted.\n * @param lender The address of the accepted bid lender.\n */\n event AcceptedBid(uint256 indexed bidId, address indexed lender);\n\n /**\n * @notice This event is emitted when a previously submitted bid has been cancelled.\n * @param bidId The id of the cancelled bid.\n */\n event CancelledBid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when market owner has cancelled a pending bid in their market.\n * @param bidId The id of the bid funded.\n *\n * Note: The `CancelledBid` event will also be emitted.\n */\n event MarketOwnerCancelledBid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a payment is made towards an active loan.\n * @param bidId The id of the bid/loan to which the payment was made.\n */\n event LoanRepayment(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a loan has been fully repaid.\n * @param bidId The id of the bid/loan which was repaid.\n */\n event LoanRepaid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a loan has been fully repaid.\n * @param bidId The id of the bid/loan which was repaid.\n */\n event LoanLiquidated(uint256 indexed bidId, address indexed liquidator);\n\n /**\n * @notice This event is emitted when a fee has been paid related to a bid.\n * @param bidId The id of the bid.\n * @param feeType The name of the fee being paid.\n * @param amount The amount of the fee being paid.\n */\n event FeePaid(\n uint256 indexed bidId,\n string indexed feeType,\n uint256 indexed amount\n );\n\n /** Modifiers */\n\n /**\n * @notice This modifier is used to check if the state of a bid is pending, before running an action.\n * @param _bidId The id of the bid to check the state for.\n * @param _action The desired action to run on the bid.\n */\n modifier pendingBid(uint256 _bidId, string memory _action) {\n if (bids[_bidId].state != BidState.PENDING) {\n revert ActionNotAllowed(_bidId, _action, \"Bid must be pending\");\n }\n\n _;\n }\n\n /**\n * @notice This modifier is used to check if the state of a loan has been accepted, before running an action.\n * @param _bidId The id of the bid to check the state for.\n * @param _action The desired action to run on the bid.\n */\n modifier acceptedLoan(uint256 _bidId, string memory _action) {\n if (bids[_bidId].state != BidState.ACCEPTED) {\n revert ActionNotAllowed(_bidId, _action, \"Loan must be accepted\");\n }\n\n _;\n }\n\n /** Constant Variables **/\n\n uint8 public constant CURRENT_CODE_VERSION = 9;\n\n /** Constructor **/\n\n constructor(address trustedForwarder) TellerV2Context(trustedForwarder) {}\n\n /** External Functions **/\n\n /**\n * @notice Initializes the proxy.\n * @param _protocolFee The fee collected by the protocol for loan processing.\n * @param _marketRegistry The address of the market registry contract for the protocol.\n * @param _reputationManager The address of the reputation manager contract.\n * @param _lenderCommitmentForwarder The address of the lender commitment forwarder contract.\n * @param _lendingTokens The list of tokens allowed as lending assets on the protocol.\n * @param _collateralManager The address of the collateral manager contracts.\n * @param _lenderManager The address of the lender manager contract for loans on the protocol.\n */\n function initialize(\n uint16 _protocolFee,\n address _marketRegistry,\n address _reputationManager,\n address _lenderCommitmentForwarder,\n address[] calldata _lendingTokens,\n address _collateralManager,\n address _lenderManager\n ) external initializer {\n __ProtocolFee_init(_protocolFee);\n\n __Pausable_init();\n\n require(\n _lenderCommitmentForwarder.isContract(),\n \"LenderCommitmentForwarder must be a contract\"\n );\n lenderCommitmentForwarder = _lenderCommitmentForwarder;\n\n require(\n _marketRegistry.isContract(),\n \"MarketRegistry must be a contract\"\n );\n marketRegistry = IMarketRegistry(_marketRegistry);\n\n require(\n _reputationManager.isContract(),\n \"ReputationManager must be a contract\"\n );\n reputationManager = IReputationManager(_reputationManager);\n\n require(\n _collateralManager.isContract(),\n \"CollateralManager must be a contract\"\n );\n collateralManager = ICollateralManager(_collateralManager);\n\n _setLenderManager(_lenderManager);\n\n require(_lendingTokens.length > 0, \"No lending tokens specified\");\n for (uint256 i = 0; i < _lendingTokens.length; i++) {\n require(\n _lendingTokens[i].isContract(),\n \"lending token not contract\"\n );\n addLendingToken(_lendingTokens[i]);\n }\n }\n\n function setLenderManager(address _lenderManager)\n external\n reinitializer(8)\n onlyOwner\n {\n _setLenderManager(_lenderManager);\n }\n\n function _setLenderManager(address _lenderManager)\n internal\n onlyInitializing\n {\n require(\n _lenderManager.isContract(),\n \"LenderManager must be a contract\"\n );\n lenderManager = ILenderManager(_lenderManager);\n }\n\n /**\n * @notice Gets the metadataURI for a bidId.\n * @param _bidId The id of the bid to return the metadataURI for\n * @return metadataURI_ The metadataURI for the bid, as a string.\n */\n function getMetadataURI(uint256 _bidId)\n public\n view\n returns (string memory metadataURI_)\n {\n // Check uri mapping first\n metadataURI_ = uris[_bidId];\n // If the URI is not present in the mapping\n if (\n keccak256(abi.encodePacked(metadataURI_)) ==\n 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 // hardcoded constant of keccak256('')\n ) {\n // Return depreciated bytes32 uri as a string\n uint256 convertedURI = uint256(bids[_bidId]._metadataURI);\n metadataURI_ = StringsUpgradeable.toHexString(convertedURI, 32);\n }\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol to set a new reputation manager contract.\n * @param _reputationManager The new contract address.\n */\n function setReputationManager(address _reputationManager) public onlyOwner {\n reputationManager = IReputationManager(_reputationManager);\n }\n\n /**\n * @notice Function for a borrower to create a bid for a loan without Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public override whenNotPaused returns (uint256 bidId_) {\n bidId_ = _submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n /**\n * @notice Function for a borrower to create a bid for a loan with Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public override whenNotPaused returns (uint256 bidId_) {\n bidId_ = _submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n\n bool validation = collateralManager.commitCollateral(\n bidId_,\n _collateralInfo\n );\n\n require(\n validation == true,\n \"Collateral balance could not be validated\"\n );\n }\n\n function _submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) internal returns (uint256 bidId_) {\n address sender = _msgSenderForMarket(_marketplaceId);\n (bool isVerified, ) = marketRegistry.isVerifiedBorrower(\n _marketplaceId,\n sender\n );\n require(isVerified, \"Not verified borrower\");\n require(\n !marketRegistry.isMarketClosed(_marketplaceId),\n \"Market is closed\"\n );\n require(\n lendingTokensSet.contains(_lendingToken),\n \"Lending token not authorized\"\n );\n\n // Set response bid ID.\n bidId_ = bidId;\n\n // Create and store our bid into the mapping\n Bid storage bid = bids[bidId];\n bid.borrower = sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketplaceId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n // Set payment cycle type based on market setting (custom or monthly)\n (bid.terms.paymentCycle, bidPaymentCycleType[bidId]) = marketRegistry\n .getPaymentCycle(_marketplaceId);\n\n bid.terms.APR = _APR;\n\n bidDefaultDuration[bidId] = marketRegistry.getPaymentDefaultDuration(\n _marketplaceId\n );\n\n bidExpirationTime[bidId] = marketRegistry.getBidExpirationTime(\n _marketplaceId\n );\n\n bid.paymentType = marketRegistry.getPaymentType(_marketplaceId);\n\n bid.terms.paymentCycleAmount = V2Calculations\n .calculatePaymentCycleAmount(\n bid.paymentType,\n bidPaymentCycleType[bidId],\n _principal,\n _duration,\n bid.terms.paymentCycle,\n _APR\n );\n\n uris[bidId] = _metadataURI;\n bid.state = BidState.PENDING;\n\n emit SubmittedBid(\n bidId,\n bid.borrower,\n bid.receiver,\n keccak256(abi.encodePacked(_metadataURI))\n );\n\n // Store bid inside borrower bids mapping\n borrowerBids[bid.borrower].push(bidId);\n\n // Increment bid id counter\n bidId++;\n }\n\n /**\n * @notice Function for a borrower to cancel their pending bid.\n * @param _bidId The id of the bid to cancel.\n */\n function cancelBid(uint256 _bidId) external {\n if (\n _msgSenderForMarket(bids[_bidId].marketplaceId) !=\n bids[_bidId].borrower\n ) {\n revert ActionNotAllowed({\n bidId: _bidId,\n action: \"cancelBid\",\n message: \"Only the bid owner can cancel!\"\n });\n }\n _cancelBid(_bidId);\n }\n\n /**\n * @notice Function for a market owner to cancel a bid in the market.\n * @param _bidId The id of the bid to cancel.\n */\n function marketOwnerCancelBid(uint256 _bidId) external {\n if (\n _msgSender() !=\n marketRegistry.getMarketOwner(bids[_bidId].marketplaceId)\n ) {\n revert ActionNotAllowed({\n bidId: _bidId,\n action: \"marketOwnerCancelBid\",\n message: \"Only the market owner can cancel!\"\n });\n }\n _cancelBid(_bidId);\n emit MarketOwnerCancelledBid(_bidId);\n }\n\n /**\n * @notice Function for users to cancel a bid.\n * @param _bidId The id of the bid to be cancelled.\n */\n function _cancelBid(uint256 _bidId)\n internal\n pendingBid(_bidId, \"cancelBid\")\n {\n // Set the bid state to CANCELLED\n bids[_bidId].state = BidState.CANCELLED;\n\n // Emit CancelledBid event\n emit CancelledBid(_bidId);\n }\n\n /**\n * @notice Function for a lender to accept a proposed loan bid.\n * @param _bidId The id of the loan bid to accept.\n */\n function lenderAcceptBid(uint256 _bidId)\n external\n override\n pendingBid(_bidId, \"lenderAcceptBid\")\n whenNotPaused\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n // Retrieve bid\n Bid storage bid = bids[_bidId];\n\n address sender = _msgSenderForMarket(bid.marketplaceId);\n\n (bool isVerified, ) = marketRegistry.isVerifiedLender(\n bid.marketplaceId,\n sender\n );\n require(isVerified, \"Not verified lender\");\n\n require(\n !marketRegistry.isMarketClosed(bid.marketplaceId),\n \"Market is closed\"\n );\n\n require(!isLoanExpired(_bidId), \"Bid has expired\");\n\n // Set timestamp\n bid.loanDetails.acceptedTimestamp = uint32(block.timestamp);\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\n\n // Mark borrower's request as accepted\n bid.state = BidState.ACCEPTED;\n\n // Declare the bid acceptor as the lender of the bid\n bid.lender = sender;\n\n // Tell the collateral manager to deploy the escrow and pull funds from the borrower if applicable\n collateralManager.deployAndDeposit(_bidId);\n\n // Transfer funds to borrower from the lender\n amountToProtocol = bid.loanDetails.principal.percent(protocolFee());\n amountToMarketplace = bid.loanDetails.principal.percent(\n marketRegistry.getMarketplaceFee(bid.marketplaceId)\n );\n amountToBorrower =\n bid.loanDetails.principal -\n amountToProtocol -\n amountToMarketplace;\n //transfer fee to protocol\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n owner(),\n amountToProtocol\n );\n\n //transfer fee to marketplace\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n marketRegistry.getMarketFeeRecipient(bid.marketplaceId),\n amountToMarketplace\n );\n\n //transfer funds to borrower\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n bid.receiver,\n amountToBorrower\n );\n\n // Record volume filled by lenders\n lenderVolumeFilled[address(bid.loanDetails.lendingToken)][sender] += bid\n .loanDetails\n .principal;\n totalVolumeFilled[address(bid.loanDetails.lendingToken)] += bid\n .loanDetails\n .principal;\n\n // Add borrower's active bid\n _borrowerBidsActive[bid.borrower].add(_bidId);\n\n // Emit AcceptedBid\n emit AcceptedBid(_bidId, sender);\n\n emit FeePaid(_bidId, \"protocol\", amountToProtocol);\n emit FeePaid(_bidId, \"marketplace\", amountToMarketplace);\n }\n\n function claimLoanNFT(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"claimLoanNFT\")\n whenNotPaused\n {\n // Retrieve bid\n Bid storage bid = bids[_bidId];\n\n address sender = _msgSenderForMarket(bid.marketplaceId);\n require(sender == bid.lender, \"only lender can claim NFT\");\n // mint an NFT with the lender manager\n lenderManager.registerLoan(_bidId, sender);\n // set lender address to the lender manager so we know to check the owner of the NFT for the true lender\n bid.lender = address(lenderManager);\n }\n\n /**\n * @notice Function for users to make the minimum amount due for an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanMinimum(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (\n uint256 owedPrincipal,\n uint256 duePrincipal,\n uint256 interest\n ) = V2Calculations.calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: duePrincipal, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n /**\n * @notice Function for users to repay an active loan in full.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanFull(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: owedPrincipal, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n // function that the borrower (ideally) sends to repay the loan\n /**\n * @notice Function for users to make a payment towards an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _amount The amount of the payment.\n */\n function repayLoan(uint256 _bidId, uint256 _amount)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (\n uint256 owedPrincipal,\n uint256 duePrincipal,\n uint256 interest\n ) = V2Calculations.calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n uint256 minimumOwed = duePrincipal + interest;\n\n // If amount is less than minimumOwed, we revert\n if (_amount < minimumOwed) {\n revert PaymentNotMinimum(_bidId, _amount, minimumOwed);\n }\n\n _repayLoan(\n _bidId,\n Payment({ principal: _amount - interest, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol implement an emergency stop mechanism.\n */\n function pauseProtocol() public virtual onlyOwner whenNotPaused {\n _pause();\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol undo a previously implemented emergency stop.\n */\n function unpauseProtocol() public virtual onlyOwner whenPaused {\n _unpause();\n }\n\n //TODO: add an incentive for liquidator\n /**\n * @notice Function for users to liquidate a defaulted loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function liquidateLoanFull(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"liquidateLoan\")\n {\n require(isLoanDefaulted(_bidId), \"Loan must be defaulted.\");\n\n Bid storage bid = bids[_bidId];\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bid,\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: owedPrincipal, interest: interest }),\n owedPrincipal + interest,\n false\n );\n\n bid.state = BidState.LIQUIDATED;\n\n // If loan is backed by collateral, withdraw and send to the liquidator\n address liquidator = _msgSenderForMarket(bid.marketplaceId);\n collateralManager.liquidateCollateral(_bidId, liquidator);\n\n emit LoanLiquidated(_bidId, liquidator);\n }\n\n /**\n * @notice Internal function to make a loan payment.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _payment The Payment struct with payments amounts towards principal and interest respectively.\n * @param _owedAmount The total amount owed on the loan.\n */\n function _repayLoan(\n uint256 _bidId,\n Payment memory _payment,\n uint256 _owedAmount,\n bool _shouldWithdrawCollateral\n ) internal {\n Bid storage bid = bids[_bidId];\n uint256 paymentAmount = _payment.principal + _payment.interest;\n\n RepMark mark = reputationManager.updateAccountReputation(\n bid.borrower,\n _bidId\n );\n\n // Check if we are sending a payment or amount remaining\n if (paymentAmount >= _owedAmount) {\n paymentAmount = _owedAmount;\n bid.state = BidState.PAID;\n\n // Remove borrower's active bid\n _borrowerBidsActive[bid.borrower].remove(_bidId);\n\n // If loan is is being liquidated and backed by collateral, withdraw and send to borrower\n if (_shouldWithdrawCollateral) {\n collateralManager.withdraw(_bidId);\n }\n\n emit LoanRepaid(_bidId);\n } else {\n emit LoanRepayment(_bidId);\n }\n\n address lender = getLoanLender(_bidId);\n\n // Send payment to the lender\n bid.loanDetails.lendingToken.safeTransferFrom(\n _msgSenderForMarket(bid.marketplaceId),\n lender,\n paymentAmount\n );\n\n // update our mappings\n bid.loanDetails.totalRepaid.principal += _payment.principal;\n bid.loanDetails.totalRepaid.interest += _payment.interest;\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\n\n // If the loan is paid in full and has a mark, we should update the current reputation\n if (mark != RepMark.Good) {\n reputationManager.updateAccountReputation(bid.borrower, _bidId);\n }\n }\n\n /**\n * @notice Calculates the total amount owed for a bid.\n * @param _bidId The id of the loan bid to calculate the owed amount for.\n */\n function calculateAmountOwed(uint256 _bidId)\n public\n view\n returns (Payment memory owed)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return owed;\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n owed.principal = owedPrincipal;\n owed.interest = interest;\n }\n\n /**\n * @notice Calculates the total amount owed for a loan bid at a specific timestamp.\n * @param _bidId The id of the loan bid to calculate the owed amount for.\n * @param _timestamp The timestamp at which to calculate the loan owed amount at.\n */\n function calculateAmountOwed(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory owed)\n {\n Bid storage bid = bids[_bidId];\n if (\n bid.state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return owed;\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n owed.principal = owedPrincipal;\n owed.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Returns the next due date for a loan payment.\n * @param _bidId The id of the loan bid.\n */\n function calculateNextDueDate(uint256 _bidId)\n public\n view\n returns (uint32 dueDate_)\n {\n Bid storage bid = bids[_bidId];\n if (bids[_bidId].state != BidState.ACCEPTED) return dueDate_;\n\n uint32 lastRepaidTimestamp = lastRepaidTimestamp(_bidId);\n\n // Calculate due date if payment cycle is set to monthly\n if (bidPaymentCycleType[_bidId] == PaymentCycleType.Monthly) {\n // Calculate the cycle number the last repayment was made\n uint256 lastPaymentCycle = BPBDTL.diffMonths(\n bid.loanDetails.acceptedTimestamp,\n lastRepaidTimestamp\n );\n if (\n BPBDTL.getDay(lastRepaidTimestamp) >\n BPBDTL.getDay(bid.loanDetails.acceptedTimestamp)\n ) {\n lastPaymentCycle += 2;\n } else {\n lastPaymentCycle += 1;\n }\n\n dueDate_ = uint32(\n BPBDTL.addMonths(\n bid.loanDetails.acceptedTimestamp,\n lastPaymentCycle\n )\n );\n } else if (bidPaymentCycleType[_bidId] == PaymentCycleType.Seconds) {\n // Start with the original due date being 1 payment cycle since bid was accepted\n dueDate_ =\n bid.loanDetails.acceptedTimestamp +\n bid.terms.paymentCycle;\n // Calculate the cycle number the last repayment was made\n uint32 delta = lastRepaidTimestamp -\n bid.loanDetails.acceptedTimestamp;\n if (delta > 0) {\n uint32 repaymentCycle = uint32(\n Math.ceilDiv(delta, bid.terms.paymentCycle)\n );\n dueDate_ += (repaymentCycle * bid.terms.paymentCycle);\n }\n }\n\n uint32 endOfLoan = bid.loanDetails.acceptedTimestamp +\n bid.loanDetails.loanDuration;\n //if we are in the last payment cycle, the next due date is the end of loan duration\n if (dueDate_ > endOfLoan) {\n dueDate_ = endOfLoan;\n }\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isPaymentLate(uint256 _bidId) public view override returns (bool) {\n if (bids[_bidId].state != BidState.ACCEPTED) return false;\n return uint32(block.timestamp) > calculateNextDueDate(_bidId);\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanDefaulted(uint256 _bidId)\n public\n view\n override\n returns (bool)\n {\n Bid storage bid = bids[_bidId];\n\n // Make sure loan cannot be liquidated if it is not active\n if (bid.state != BidState.ACCEPTED) return false;\n\n if (bidDefaultDuration[_bidId] == 0) return false;\n\n return (uint32(block.timestamp) - lastRepaidTimestamp(_bidId) >\n bidDefaultDuration[_bidId]);\n }\n\n function getBidState(uint256 _bidId)\n external\n view\n override\n returns (BidState)\n {\n return bids[_bidId].state;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n external\n view\n override\n returns (uint256[] memory)\n {\n return _borrowerBidsActive[_borrower].values();\n }\n\n function getBorrowerLoanIds(address _borrower)\n external\n view\n returns (uint256[] memory)\n {\n return borrowerBids[_borrower];\n }\n\n /**\n * @notice Checks to see if a pending loan has expired so it is no longer able to be accepted.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanExpired(uint256 _bidId) public view returns (bool) {\n Bid storage bid = bids[_bidId];\n\n if (bid.state != BidState.PENDING) return false;\n if (bidExpirationTime[_bidId] == 0) return false;\n\n return (uint32(block.timestamp) >\n bid.loanDetails.timestamp + bidExpirationTime[_bidId]);\n }\n\n /**\n * @notice Returns the last repaid timestamp for a loan.\n * @param _bidId The id of the loan bid to get the timestamp for.\n */\n function lastRepaidTimestamp(uint256 _bidId) public view returns (uint32) {\n return V2Calculations.lastRepaidTimestamp(bids[_bidId]);\n }\n\n /**\n * @notice Returns the list of authorized tokens on the protocol.\n */\n function getLendingTokens() public view returns (address[] memory) {\n return lendingTokensSet.values();\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol add an authorized lending token.\n * @param _lendingToken The contract address of the lending token.\n */\n function addLendingToken(address _lendingToken) public onlyOwner {\n require(_lendingToken.isContract(), \"Incorrect lending token address\");\n lendingTokensSet.add(_lendingToken);\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol remove an authorized lending token.\n * @param _lendingToken The contract address of the lending token.\n */\n function removeLendingToken(address _lendingToken) public onlyOwner {\n lendingTokensSet.remove(_lendingToken);\n }\n\n /**\n * @notice Returns the borrower address for a given bid.\n * @param _bidId The id of the bid/loan to get the borrower for.\n * @return borrower_ The address of the borrower associated with the bid.\n */\n function getLoanBorrower(uint256 _bidId)\n public\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n /**\n * @notice Returns the lender address for a given bid. If the stored lender address is the `LenderManager` NFT address, return the `ownerOf` for the bid ID.\n * @param _bidId The id of the bid/loan to get the lender for.\n * @return lender_ The address of the lender associated with the bid.\n */\n function getLoanLender(uint256 _bidId)\n public\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n\n if (lender_ == address(lenderManager)) {\n return lenderManager.ownerOf(_bidId);\n }\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n /** OpenZeppelin Override Functions **/\n\n function _msgSender()\n internal\n view\n virtual\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\n returns (address sender)\n {\n sender = ERC2771ContextUpgradeable._msgSender();\n }\n\n function _msgData()\n internal\n view\n virtual\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\n returns (bytes calldata)\n {\n return ERC2771ContextUpgradeable._msgData();\n }\n}\n" - }, - "contracts/MarketRegistry.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// Contracts\nimport \"./EAS/TellerAS.sol\";\nimport \"./EAS/TellerASResolver.sol\";\n\n//must continue to use this so storage slots are not broken\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n// Interfaces\nimport \"./interfaces/IMarketRegistry.sol\";\n\n// Libraries\nimport { EnumerableSet } from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport { PaymentType } from \"./libraries/V2Calculations.sol\";\n\ncontract MarketRegistry is\n IMarketRegistry,\n Initializable,\n Context,\n TellerASResolver\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /** Constant Variables **/\n\n uint256 public constant CURRENT_CODE_VERSION = 8;\n\n /* Storage Variables */\n\n struct Marketplace {\n address owner;\n string metadataURI;\n uint16 marketplaceFeePercent; // 10000 is 100%\n bool lenderAttestationRequired;\n EnumerableSet.AddressSet verifiedLendersForMarket;\n mapping(address => bytes32) lenderAttestationIds;\n uint32 paymentCycleDuration; // unix time (seconds)\n uint32 paymentDefaultDuration; //unix time\n uint32 bidExpirationTime; //unix time\n bool borrowerAttestationRequired;\n EnumerableSet.AddressSet verifiedBorrowersForMarket;\n mapping(address => bytes32) borrowerAttestationIds;\n address feeRecipient;\n PaymentType paymentType;\n PaymentCycleType paymentCycleType;\n }\n\n bytes32 public lenderAttestationSchemaId;\n\n mapping(uint256 => Marketplace) internal markets;\n mapping(bytes32 => uint256) internal __uriToId; //DEPRECATED\n uint256 public marketCount;\n bytes32 private _attestingSchemaId;\n bytes32 public borrowerAttestationSchemaId;\n\n uint256 public version;\n\n mapping(uint256 => bool) private marketIsClosed;\n\n TellerAS public tellerAS;\n\n /* Modifiers */\n\n modifier ownsMarket(uint256 _marketId) {\n require(markets[_marketId].owner == _msgSender(), \"Not the owner\");\n _;\n }\n\n modifier withAttestingSchema(bytes32 schemaId) {\n _attestingSchemaId = schemaId;\n _;\n _attestingSchemaId = bytes32(0);\n }\n\n /* Events */\n\n event MarketCreated(address indexed owner, uint256 marketId);\n event SetMarketURI(uint256 marketId, string uri);\n event SetPaymentCycleDuration(uint256 marketId, uint32 duration); // DEPRECATED - used for subgraph reference\n event SetPaymentCycle(\n uint256 marketId,\n PaymentCycleType paymentCycleType,\n uint32 value\n );\n event SetPaymentDefaultDuration(uint256 marketId, uint32 duration);\n event SetBidExpirationTime(uint256 marketId, uint32 duration);\n event SetMarketFee(uint256 marketId, uint16 feePct);\n event LenderAttestation(uint256 marketId, address lender);\n event BorrowerAttestation(uint256 marketId, address borrower);\n event LenderRevocation(uint256 marketId, address lender);\n event BorrowerRevocation(uint256 marketId, address borrower);\n event MarketClosed(uint256 marketId);\n event LenderExitMarket(uint256 marketId, address lender);\n event BorrowerExitMarket(uint256 marketId, address borrower);\n event SetMarketOwner(uint256 marketId, address newOwner);\n event SetMarketFeeRecipient(uint256 marketId, address newRecipient);\n event SetMarketLenderAttestation(uint256 marketId, bool required);\n event SetMarketBorrowerAttestation(uint256 marketId, bool required);\n event SetMarketPaymentType(uint256 marketId, PaymentType paymentType);\n\n /* External Functions */\n\n function initialize(TellerAS _tellerAS) external initializer {\n tellerAS = _tellerAS;\n\n lenderAttestationSchemaId = tellerAS.getASRegistry().register(\n \"(uint256 marketId, address lenderAddress)\",\n this\n );\n borrowerAttestationSchemaId = tellerAS.getASRegistry().register(\n \"(uint256 marketId, address borrowerAddress)\",\n this\n );\n }\n\n /**\n * @notice Creates a new market.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _paymentType The payment type for loans in the market.\n * @param _uri URI string to get metadata details about the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @return marketId_ The market ID of the newly created market.\n */\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) external returns (uint256 marketId_) {\n marketId_ = _createMarket(\n _initialOwner,\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n _paymentCycleType,\n _uri\n );\n }\n\n /**\n * @notice Creates a new market.\n * @dev Uses the default EMI payment type.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _uri URI string to get metadata details about the market.\n * @return marketId_ The market ID of the newly created market.\n */\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) external returns (uint256 marketId_) {\n marketId_ = _createMarket(\n _initialOwner,\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n _uri\n );\n }\n\n /**\n * @notice Creates a new market.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _paymentType The payment type for loans in the market.\n * @param _uri URI string to get metadata details about the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @return marketId_ The market ID of the newly created market.\n */\n function _createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) internal returns (uint256 marketId_) {\n require(_initialOwner != address(0), \"Invalid owner address\");\n // Increment market ID counter\n marketId_ = ++marketCount;\n\n // Set the market owner\n markets[marketId_].owner = _initialOwner;\n\n // Initialize market settings\n _setMarketSettings(\n marketId_,\n _paymentCycleDuration,\n _paymentType,\n _paymentCycleType,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireBorrowerAttestation,\n _requireLenderAttestation,\n _uri\n );\n\n emit MarketCreated(_initialOwner, marketId_);\n }\n\n /**\n * @notice Closes a market so new bids cannot be added.\n * @param _marketId The market ID for the market to close.\n */\n\n function closeMarket(uint256 _marketId) public ownsMarket(_marketId) {\n if (!marketIsClosed[_marketId]) {\n marketIsClosed[_marketId] = true;\n\n emit MarketClosed(_marketId);\n }\n }\n\n /**\n * @notice Returns the status of a market being open or closed for new bids.\n * @param _marketId The market ID for the market to check.\n */\n function isMarketClosed(uint256 _marketId)\n public\n view\n override\n returns (bool)\n {\n return marketIsClosed[_marketId];\n }\n\n /**\n * @notice Adds a lender to a market.\n * @dev See {_attestStakeholder}.\n */\n function attestLender(\n uint256 _marketId,\n address _lenderAddress,\n uint256 _expirationTime\n ) external {\n _attestStakeholder(_marketId, _lenderAddress, _expirationTime, true);\n }\n\n /**\n * @notice Adds a lender to a market via delegated attestation.\n * @dev See {_attestStakeholderViaDelegation}.\n */\n function attestLender(\n uint256 _marketId,\n address _lenderAddress,\n uint256 _expirationTime,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _attestStakeholderViaDelegation(\n _marketId,\n _lenderAddress,\n _expirationTime,\n true,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Removes a lender from an market.\n * @dev See {_revokeStakeholder}.\n */\n function revokeLender(uint256 _marketId, address _lenderAddress) external {\n _revokeStakeholder(_marketId, _lenderAddress, true);\n }\n\n /**\n * @notice Removes a borrower from a market via delegated revocation.\n * @dev See {_revokeStakeholderViaDelegation}.\n */\n function revokeLender(\n uint256 _marketId,\n address _lenderAddress,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _revokeStakeholderViaDelegation(\n _marketId,\n _lenderAddress,\n true,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Allows a lender to voluntarily leave a market.\n * @param _marketId The market ID to leave.\n */\n function lenderExitMarket(uint256 _marketId) external {\n // Remove lender address from market set\n bool response = markets[_marketId].verifiedLendersForMarket.remove(\n _msgSender()\n );\n if (response) {\n emit LenderExitMarket(_marketId, _msgSender());\n }\n }\n\n /**\n * @notice Adds a borrower to a market.\n * @dev See {_attestStakeholder}.\n */\n function attestBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint256 _expirationTime\n ) external {\n _attestStakeholder(_marketId, _borrowerAddress, _expirationTime, false);\n }\n\n /**\n * @notice Adds a borrower to a market via delegated attestation.\n * @dev See {_attestStakeholderViaDelegation}.\n */\n function attestBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint256 _expirationTime,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _attestStakeholderViaDelegation(\n _marketId,\n _borrowerAddress,\n _expirationTime,\n false,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Removes a borrower from an market.\n * @dev See {_revokeStakeholder}.\n */\n function revokeBorrower(uint256 _marketId, address _borrowerAddress)\n external\n {\n _revokeStakeholder(_marketId, _borrowerAddress, false);\n }\n\n /**\n * @notice Removes a borrower from a market via delegated revocation.\n * @dev See {_revokeStakeholderViaDelegation}.\n */\n function revokeBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _revokeStakeholderViaDelegation(\n _marketId,\n _borrowerAddress,\n false,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Allows a borrower to voluntarily leave a market.\n * @param _marketId The market ID to leave.\n */\n function borrowerExitMarket(uint256 _marketId) external {\n // Remove borrower address from market set\n bool response = markets[_marketId].verifiedBorrowersForMarket.remove(\n _msgSender()\n );\n if (response) {\n emit BorrowerExitMarket(_marketId, _msgSender());\n }\n }\n\n /**\n * @notice Verifies an attestation is valid.\n * @dev This function must only be called by the `attestLender` function above.\n * @param recipient Lender's address who is being attested.\n * @param schema The schema used for the attestation.\n * @param data Data the must include the market ID and lender's address\n * @param\n * @param attestor Market owner's address who signed the attestation.\n * @return Boolean indicating the attestation was successful.\n */\n function resolve(\n address recipient,\n bytes calldata schema,\n bytes calldata data,\n uint256 /* expirationTime */,\n address attestor\n ) external payable override returns (bool) {\n bytes32 attestationSchemaId = keccak256(\n abi.encodePacked(schema, address(this))\n );\n (uint256 marketId, address lenderAddress) = abi.decode(\n data,\n (uint256, address)\n );\n return\n (_attestingSchemaId == attestationSchemaId &&\n recipient == lenderAddress &&\n attestor == markets[marketId].owner) ||\n attestor == address(this);\n }\n\n /**\n * @notice Transfers ownership of a marketplace.\n * @param _marketId The ID of a market.\n * @param _newOwner Address of the new market owner.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function transferMarketOwnership(uint256 _marketId, address _newOwner)\n public\n ownsMarket(_marketId)\n {\n markets[_marketId].owner = _newOwner;\n emit SetMarketOwner(_marketId, _newOwner);\n }\n\n /**\n * @notice Updates multiple market settings for a given market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleDuration Delinquency duration for new loans\n * @param _newPaymentType The payment type for the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @param _paymentDefaultDuration Default duration for new loans\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\n * @param _metadataURI A URI that points to a market's metadata.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function updateMarketSettings(\n uint256 _marketId,\n uint32 _paymentCycleDuration,\n PaymentType _newPaymentType,\n PaymentCycleType _paymentCycleType,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _borrowerAttestationRequired,\n bool _lenderAttestationRequired,\n string calldata _metadataURI\n ) public ownsMarket(_marketId) {\n _setMarketSettings(\n _marketId,\n _paymentCycleDuration,\n _newPaymentType,\n _paymentCycleType,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _borrowerAttestationRequired,\n _lenderAttestationRequired,\n _metadataURI\n );\n }\n\n /**\n * @notice Sets the fee recipient address for a market.\n * @param _marketId The ID of a market.\n * @param _recipient Address of the new fee recipient.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketFeeRecipient(uint256 _marketId, address _recipient)\n public\n ownsMarket(_marketId)\n {\n markets[_marketId].feeRecipient = _recipient;\n emit SetMarketFeeRecipient(_marketId, _recipient);\n }\n\n /**\n * @notice Sets the metadata URI for a market.\n * @param _marketId The ID of a market.\n * @param _uri A URI that points to a market's metadata.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketURI(uint256 _marketId, string calldata _uri)\n public\n ownsMarket(_marketId)\n {\n //We do string comparison by checking the hashes of the strings against one another\n if (\n keccak256(abi.encodePacked(_uri)) !=\n keccak256(abi.encodePacked(markets[_marketId].metadataURI))\n ) {\n markets[_marketId].metadataURI = _uri;\n\n emit SetMarketURI(_marketId, _uri);\n }\n }\n\n /**\n * @notice Sets the duration of new loans for this market before they turn delinquent.\n * @notice Changing this value does not change the terms of existing loans for this market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleType Cycle type (seconds or monthly)\n * @param _duration Delinquency duration for new loans\n */\n function setPaymentCycle(\n uint256 _marketId,\n PaymentCycleType _paymentCycleType,\n uint32 _duration\n ) public ownsMarket(_marketId) {\n require(\n (_paymentCycleType == PaymentCycleType.Seconds) ||\n (_paymentCycleType == PaymentCycleType.Monthly &&\n _duration == 0),\n \"monthly payment cycle duration cannot be set\"\n );\n Marketplace storage market = markets[_marketId];\n uint32 duration = _paymentCycleType == PaymentCycleType.Seconds\n ? _duration\n : 30 days;\n if (\n _paymentCycleType != market.paymentCycleType ||\n duration != market.paymentCycleDuration\n ) {\n markets[_marketId].paymentCycleType = _paymentCycleType;\n markets[_marketId].paymentCycleDuration = duration;\n\n emit SetPaymentCycle(_marketId, _paymentCycleType, duration);\n }\n }\n\n /**\n * @notice Sets the duration of new loans for this market before they turn defaulted.\n * @notice Changing this value does not change the terms of existing loans for this market.\n * @param _marketId The ID of a market.\n * @param _duration Default duration for new loans\n */\n function setPaymentDefaultDuration(uint256 _marketId, uint32 _duration)\n public\n ownsMarket(_marketId)\n {\n if (_duration != markets[_marketId].paymentDefaultDuration) {\n markets[_marketId].paymentDefaultDuration = _duration;\n\n emit SetPaymentDefaultDuration(_marketId, _duration);\n }\n }\n\n function setBidExpirationTime(uint256 _marketId, uint32 _duration)\n public\n ownsMarket(_marketId)\n {\n if (_duration != markets[_marketId].bidExpirationTime) {\n markets[_marketId].bidExpirationTime = _duration;\n\n emit SetBidExpirationTime(_marketId, _duration);\n }\n }\n\n /**\n * @notice Sets the fee for the market.\n * @param _marketId The ID of a market.\n * @param _newPercent The percentage fee in basis points.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketFeePercent(uint256 _marketId, uint16 _newPercent)\n public\n ownsMarket(_marketId)\n {\n require(_newPercent >= 0 && _newPercent <= 10000, \"invalid percent\");\n if (_newPercent != markets[_marketId].marketplaceFeePercent) {\n markets[_marketId].marketplaceFeePercent = _newPercent;\n emit SetMarketFee(_marketId, _newPercent);\n }\n }\n\n /**\n * @notice Set the payment type for the market.\n * @param _marketId The ID of the market.\n * @param _newPaymentType The payment type for the market.\n */\n function setMarketPaymentType(\n uint256 _marketId,\n PaymentType _newPaymentType\n ) public ownsMarket(_marketId) {\n if (_newPaymentType != markets[_marketId].paymentType) {\n markets[_marketId].paymentType = _newPaymentType;\n emit SetMarketPaymentType(_marketId, _newPaymentType);\n }\n }\n\n /**\n * @notice Enable/disables market whitelist for lenders.\n * @param _marketId The ID of a market.\n * @param _required Boolean indicating if the market requires whitelist.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setLenderAttestationRequired(uint256 _marketId, bool _required)\n public\n ownsMarket(_marketId)\n {\n if (_required != markets[_marketId].lenderAttestationRequired) {\n markets[_marketId].lenderAttestationRequired = _required;\n emit SetMarketLenderAttestation(_marketId, _required);\n }\n }\n\n /**\n * @notice Enable/disables market whitelist for borrowers.\n * @param _marketId The ID of a market.\n * @param _required Boolean indicating if the market requires whitelist.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setBorrowerAttestationRequired(uint256 _marketId, bool _required)\n public\n ownsMarket(_marketId)\n {\n if (_required != markets[_marketId].borrowerAttestationRequired) {\n markets[_marketId].borrowerAttestationRequired = _required;\n emit SetMarketBorrowerAttestation(_marketId, _required);\n }\n }\n\n /**\n * @notice Gets the data associated with a market.\n * @param _marketId The ID of a market.\n */\n function getMarketData(uint256 _marketId)\n public\n view\n returns (\n address owner,\n uint32 paymentCycleDuration,\n uint32 paymentDefaultDuration,\n uint32 loanExpirationTime,\n string memory metadataURI,\n uint16 marketplaceFeePercent,\n bool lenderAttestationRequired\n )\n {\n return (\n markets[_marketId].owner,\n markets[_marketId].paymentCycleDuration,\n markets[_marketId].paymentDefaultDuration,\n markets[_marketId].bidExpirationTime,\n markets[_marketId].metadataURI,\n markets[_marketId].marketplaceFeePercent,\n markets[_marketId].lenderAttestationRequired\n );\n }\n\n /**\n * @notice Gets the attestation requirements for a given market.\n * @param _marketId The ID of the market.\n */\n function getMarketAttestationRequirements(uint256 _marketId)\n public\n view\n returns (\n bool lenderAttestationRequired,\n bool borrowerAttestationRequired\n )\n {\n return (\n markets[_marketId].lenderAttestationRequired,\n markets[_marketId].borrowerAttestationRequired\n );\n }\n\n /**\n * @notice Gets the address of a market's owner.\n * @param _marketId The ID of a market.\n * @return The address of a market's owner.\n */\n function getMarketOwner(uint256 _marketId)\n public\n view\n override\n returns (address)\n {\n return markets[_marketId].owner;\n }\n\n /**\n * @notice Gets the fee recipient of a market.\n * @param _marketId The ID of a market.\n * @return The address of a market's fee recipient.\n */\n function getMarketFeeRecipient(uint256 _marketId)\n public\n view\n override\n returns (address)\n {\n address recipient = markets[_marketId].feeRecipient;\n\n if (recipient == address(0)) {\n return markets[_marketId].owner;\n }\n\n return recipient;\n }\n\n /**\n * @notice Gets the metadata URI of a market.\n * @param _marketId The ID of a market.\n * @return URI of a market's metadata.\n */\n function getMarketURI(uint256 _marketId)\n public\n view\n override\n returns (string memory)\n {\n return markets[_marketId].metadataURI;\n }\n\n /**\n * @notice Gets the loan delinquent duration of a market.\n * @param _marketId The ID of a market.\n * @return Duration of a loan until it is delinquent.\n * @return The type of payment cycle for loans in the market.\n */\n function getPaymentCycle(uint256 _marketId)\n public\n view\n override\n returns (uint32, PaymentCycleType)\n {\n return (\n markets[_marketId].paymentCycleDuration,\n markets[_marketId].paymentCycleType\n );\n }\n\n /**\n * @notice Gets the loan default duration of a market.\n * @param _marketId The ID of a market.\n * @return Duration of a loan repayment interval until it is default.\n */\n function getPaymentDefaultDuration(uint256 _marketId)\n public\n view\n override\n returns (uint32)\n {\n return markets[_marketId].paymentDefaultDuration;\n }\n\n /**\n * @notice Get the payment type of a market.\n * @param _marketId the ID of the market.\n * @return The type of payment for loans in the market.\n */\n function getPaymentType(uint256 _marketId)\n public\n view\n override\n returns (PaymentType)\n {\n return markets[_marketId].paymentType;\n }\n\n function getBidExpirationTime(uint256 marketId)\n public\n view\n override\n returns (uint32)\n {\n return markets[marketId].bidExpirationTime;\n }\n\n /**\n * @notice Gets the marketplace fee in basis points\n * @param _marketId The ID of a market.\n * @return fee in basis points\n */\n function getMarketplaceFee(uint256 _marketId)\n public\n view\n override\n returns (uint16 fee)\n {\n return markets[_marketId].marketplaceFeePercent;\n }\n\n /**\n * @notice Checks if a lender has been attested and added to a market.\n * @param _marketId The ID of a market.\n * @param _lenderAddress Address to check.\n * @return isVerified_ Boolean indicating if a lender has been added to a market.\n * @return uuid_ Bytes32 representing the UUID of the lender.\n */\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\n public\n view\n override\n returns (bool isVerified_, bytes32 uuid_)\n {\n return\n _isVerified(\n _lenderAddress,\n markets[_marketId].lenderAttestationRequired,\n markets[_marketId].lenderAttestationIds,\n markets[_marketId].verifiedLendersForMarket\n );\n }\n\n /**\n * @notice Checks if a borrower has been attested and added to a market.\n * @param _marketId The ID of a market.\n * @param _borrowerAddress Address of the borrower to check.\n * @return isVerified_ Boolean indicating if a borrower has been added to a market.\n * @return uuid_ Bytes32 representing the UUID of the borrower.\n */\n function isVerifiedBorrower(uint256 _marketId, address _borrowerAddress)\n public\n view\n override\n returns (bool isVerified_, bytes32 uuid_)\n {\n return\n _isVerified(\n _borrowerAddress,\n markets[_marketId].borrowerAttestationRequired,\n markets[_marketId].borrowerAttestationIds,\n markets[_marketId].verifiedBorrowersForMarket\n );\n }\n\n /**\n * @notice Gets addresses of all attested lenders.\n * @param _marketId The ID of a market.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return Array of addresses that have been added to a market.\n */\n function getAllVerifiedLendersForMarket(\n uint256 _marketId,\n uint256 _page,\n uint256 _perPage\n ) public view returns (address[] memory) {\n EnumerableSet.AddressSet storage set = markets[_marketId]\n .verifiedLendersForMarket;\n\n return _getStakeholdersForMarket(set, _page, _perPage);\n }\n\n /**\n * @notice Gets addresses of all attested borrowers.\n * @param _marketId The ID of the market.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return Array of addresses that have been added to a market.\n */\n function getAllVerifiedBorrowersForMarket(\n uint256 _marketId,\n uint256 _page,\n uint256 _perPage\n ) public view returns (address[] memory) {\n EnumerableSet.AddressSet storage set = markets[_marketId]\n .verifiedBorrowersForMarket;\n return _getStakeholdersForMarket(set, _page, _perPage);\n }\n\n /**\n * @notice Sets multiple market settings for a given market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleDuration Delinquency duration for new loans\n * @param _newPaymentType The payment type for the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @param _paymentDefaultDuration Default duration for new loans\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\n * @param _metadataURI A URI that points to a market's metadata.\n */\n function _setMarketSettings(\n uint256 _marketId,\n uint32 _paymentCycleDuration,\n PaymentType _newPaymentType,\n PaymentCycleType _paymentCycleType,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _borrowerAttestationRequired,\n bool _lenderAttestationRequired,\n string calldata _metadataURI\n ) internal {\n setMarketURI(_marketId, _metadataURI);\n setPaymentDefaultDuration(_marketId, _paymentDefaultDuration);\n setBidExpirationTime(_marketId, _bidExpirationTime);\n setMarketFeePercent(_marketId, _feePercent);\n setLenderAttestationRequired(_marketId, _lenderAttestationRequired);\n setBorrowerAttestationRequired(_marketId, _borrowerAttestationRequired);\n setMarketPaymentType(_marketId, _newPaymentType);\n setPaymentCycle(_marketId, _paymentCycleType, _paymentCycleDuration);\n }\n\n /**\n * @notice Gets addresses of all attested relevant stakeholders.\n * @param _set The stored set of stakeholders to index from.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return stakeholders_ Array of addresses that have been added to a market.\n */\n function _getStakeholdersForMarket(\n EnumerableSet.AddressSet storage _set,\n uint256 _page,\n uint256 _perPage\n ) internal view returns (address[] memory stakeholders_) {\n uint256 len = _set.length();\n\n uint256 start = _page * _perPage;\n if (start <= len) {\n uint256 end = start + _perPage;\n // Ensure we do not go out of bounds\n if (end > len) {\n end = len;\n }\n\n stakeholders_ = new address[](end - start);\n for (uint256 i = start; i < end; i++) {\n stakeholders_[i] = _set.at(i);\n }\n }\n }\n\n /* Internal Functions */\n\n /**\n * @notice Adds a stakeholder (lender or borrower) to a market.\n * @param _marketId The market ID to add a borrower to.\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\n * @param _expirationTime The expiration time of the attestation.\n * @param _expirationTime The expiration time of the attestation.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _attestStakeholder(\n uint256 _marketId,\n address _stakeholderAddress,\n uint256 _expirationTime,\n bool _isLender\n )\n internal\n withAttestingSchema(\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\n )\n {\n require(\n _msgSender() == markets[_marketId].owner,\n \"Not the market owner\"\n );\n\n // Submit attestation for borrower to join a market\n bytes32 uuid = tellerAS.attest(\n _stakeholderAddress,\n _attestingSchemaId, // set by the modifier\n _expirationTime,\n 0,\n abi.encode(_marketId, _stakeholderAddress)\n );\n _attestStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n uuid,\n _isLender\n );\n }\n\n /**\n * @notice Adds a stakeholder (lender or borrower) to a market via delegated attestation.\n * @dev The signature must match that of the market owner.\n * @param _marketId The market ID to add a lender to.\n * @param _stakeholderAddress The address of the lender to add to the market.\n * @param _expirationTime The expiration time of the attestation.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @param _v Signature value\n * @param _r Signature value\n * @param _s Signature value\n */\n function _attestStakeholderViaDelegation(\n uint256 _marketId,\n address _stakeholderAddress,\n uint256 _expirationTime,\n bool _isLender,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n internal\n withAttestingSchema(\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\n )\n {\n // NOTE: block scope to prevent stack too deep!\n bytes32 uuid;\n {\n bytes memory data = abi.encode(_marketId, _stakeholderAddress);\n address attestor = markets[_marketId].owner;\n // Submit attestation for stakeholder to join a market (attestation must be signed by market owner)\n uuid = tellerAS.attestByDelegation(\n _stakeholderAddress,\n _attestingSchemaId, // set by the modifier\n _expirationTime,\n 0,\n data,\n attestor,\n _v,\n _r,\n _s\n );\n }\n _attestStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n uuid,\n _isLender\n );\n }\n\n /**\n * @notice Adds a stakeholder (borrower/lender) to a market.\n * @param _marketId The market ID to add a stakeholder to.\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\n * @param _uuid The UUID of the attestation created.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _attestStakeholderVerification(\n uint256 _marketId,\n address _stakeholderAddress,\n bytes32 _uuid,\n bool _isLender\n ) internal {\n if (_isLender) {\n // Store the lender attestation ID for the market ID\n markets[_marketId].lenderAttestationIds[\n _stakeholderAddress\n ] = _uuid;\n // Add lender address to market set\n markets[_marketId].verifiedLendersForMarket.add(\n _stakeholderAddress\n );\n\n emit LenderAttestation(_marketId, _stakeholderAddress);\n } else {\n // Store the lender attestation ID for the market ID\n markets[_marketId].borrowerAttestationIds[\n _stakeholderAddress\n ] = _uuid;\n // Add lender address to market set\n markets[_marketId].verifiedBorrowersForMarket.add(\n _stakeholderAddress\n );\n\n emit BorrowerAttestation(_marketId, _stakeholderAddress);\n }\n }\n\n /**\n * @notice Removes a stakeholder from an market.\n * @dev The caller must be the market owner.\n * @param _marketId The market ID to remove the borrower from.\n * @param _stakeholderAddress The address of the borrower to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _revokeStakeholder(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender\n ) internal {\n require(\n _msgSender() == markets[_marketId].owner,\n \"Not the market owner\"\n );\n\n bytes32 uuid = _revokeStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n _isLender\n );\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\n // tellerAS.revoke(uuid);\n }\n\n /**\n * @notice Removes a stakeholder from an market via delegated revocation.\n * @param _marketId The market ID to remove the borrower from.\n * @param _stakeholderAddress The address of the borrower to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @param _v Signature value\n * @param _r Signature value\n * @param _s Signature value\n */\n function _revokeStakeholderViaDelegation(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) internal {\n bytes32 uuid = _revokeStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n _isLender\n );\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\n // address attestor = markets[_marketId].owner;\n // tellerAS.revokeByDelegation(uuid, attestor, _v, _r, _s);\n }\n\n /**\n * @notice Removes a stakeholder (borrower/lender) from a market.\n * @param _marketId The market ID to remove the lender from.\n * @param _stakeholderAddress The address of the stakeholder to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @return uuid_ The ID of the previously verified attestation.\n */\n function _revokeStakeholderVerification(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender\n ) internal returns (bytes32 uuid_) {\n if (_isLender) {\n uuid_ = markets[_marketId].lenderAttestationIds[\n _stakeholderAddress\n ];\n // Remove lender address from market set\n markets[_marketId].verifiedLendersForMarket.remove(\n _stakeholderAddress\n );\n\n emit LenderRevocation(_marketId, _stakeholderAddress);\n } else {\n uuid_ = markets[_marketId].borrowerAttestationIds[\n _stakeholderAddress\n ];\n // Remove borrower address from market set\n markets[_marketId].verifiedBorrowersForMarket.remove(\n _stakeholderAddress\n );\n\n emit BorrowerRevocation(_marketId, _stakeholderAddress);\n }\n }\n\n /**\n * @notice Checks if a stakeholder has been attested and added to a market.\n * @param _stakeholderAddress Address of the stakeholder to check.\n * @param _attestationRequired Stored boolean indicating if attestation is required for the stakeholder class.\n * @param _stakeholderAttestationIds Mapping of attested Ids for the stakeholder class.\n */\n function _isVerified(\n address _stakeholderAddress,\n bool _attestationRequired,\n mapping(address => bytes32) storage _stakeholderAttestationIds,\n EnumerableSet.AddressSet storage _verifiedStakeholderForMarket\n ) internal view returns (bool isVerified_, bytes32 uuid_) {\n if (_attestationRequired) {\n isVerified_ =\n _verifiedStakeholderForMarket.contains(_stakeholderAddress) &&\n tellerAS.isAttestationActive(\n _stakeholderAttestationIds[_stakeholderAddress]\n );\n uuid_ = _stakeholderAttestationIds[_stakeholderAddress];\n } else {\n isVerified_ = true;\n }\n }\n}\n" - }, - "contracts/ReputationManager.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n// Interfaces\nimport \"./interfaces/IReputationManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract ReputationManager is IReputationManager, Initializable {\n using EnumerableSet for EnumerableSet.UintSet;\n\n bytes32 public constant CONTROLLER = keccak256(\"CONTROLLER\");\n\n ITellerV2 public tellerV2;\n mapping(address => EnumerableSet.UintSet) private _delinquencies;\n mapping(address => EnumerableSet.UintSet) private _defaults;\n mapping(address => EnumerableSet.UintSet) private _currentDelinquencies;\n mapping(address => EnumerableSet.UintSet) private _currentDefaults;\n\n event MarkAdded(\n address indexed account,\n RepMark indexed repMark,\n uint256 bidId\n );\n event MarkRemoved(\n address indexed account,\n RepMark indexed repMark,\n uint256 bidId\n );\n\n /**\n * @notice Initializes the proxy.\n */\n function initialize(address _tellerV2) external initializer {\n tellerV2 = ITellerV2(_tellerV2);\n }\n\n function getDelinquentLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _delinquencies[_account].values();\n }\n\n function getDefaultedLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _defaults[_account].values();\n }\n\n function getCurrentDelinquentLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _currentDelinquencies[_account].values();\n }\n\n function getCurrentDefaultLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _currentDefaults[_account].values();\n }\n\n function updateAccountReputation(address _account) public override {\n uint256[] memory activeBidIds = tellerV2.getBorrowerActiveLoanIds(\n _account\n );\n for (uint256 i; i < activeBidIds.length; i++) {\n _applyReputation(_account, activeBidIds[i]);\n }\n }\n\n function updateAccountReputation(address _account, uint256 _bidId)\n public\n override\n returns (RepMark)\n {\n return _applyReputation(_account, _bidId);\n }\n\n function _applyReputation(address _account, uint256 _bidId)\n internal\n returns (RepMark mark_)\n {\n mark_ = RepMark.Good;\n\n if (tellerV2.isLoanDefaulted(_bidId)) {\n mark_ = RepMark.Default;\n\n // Remove delinquent status\n _removeMark(_account, _bidId, RepMark.Delinquent);\n } else if (tellerV2.isPaymentLate(_bidId)) {\n mark_ = RepMark.Delinquent;\n }\n\n // Mark status if not \"Good\"\n if (mark_ != RepMark.Good) {\n _addMark(_account, _bidId, mark_);\n }\n }\n\n function _addMark(address _account, uint256 _bidId, RepMark _mark)\n internal\n {\n if (_mark == RepMark.Delinquent) {\n _delinquencies[_account].add(_bidId);\n _currentDelinquencies[_account].add(_bidId);\n } else if (_mark == RepMark.Default) {\n _defaults[_account].add(_bidId);\n _currentDefaults[_account].add(_bidId);\n }\n\n emit MarkAdded(_account, _mark, _bidId);\n }\n\n function _removeMark(address _account, uint256 _bidId, RepMark _mark)\n internal\n {\n if (_mark == RepMark.Delinquent) {\n _currentDelinquencies[_account].remove(_bidId);\n } else if (_mark == RepMark.Default) {\n _currentDefaults[_account].remove(_bidId);\n }\n\n emit MarkRemoved(_account, _mark, _bidId);\n }\n}\n" - }, - "contracts/mock/WethMock.sol": { - "content": "/**\n *Submitted for verification at Etherscan.io on 2017-12-12\n */\n\n// Copyright (C) 2015, 2016, 2017 Dapphub\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\ncontract WethMock {\n string public name = \"Wrapped Ether\";\n string public symbol = \"WETH\";\n uint8 public decimals = 18;\n\n event Approval(address indexed src, address indexed guy, uint256 wad);\n event Transfer(address indexed src, address indexed dst, uint256 wad);\n event Deposit(address indexed dst, uint256 wad);\n event Withdrawal(address indexed src, uint256 wad);\n\n mapping(address => uint256) public balanceOf;\n mapping(address => mapping(address => uint256)) public allowance;\n\n function deposit() public payable {\n balanceOf[msg.sender] += msg.value;\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 wad) public {\n require(balanceOf[msg.sender] >= wad);\n balanceOf[msg.sender] -= wad;\n payable(msg.sender).transfer(wad);\n emit Withdrawal(msg.sender, wad);\n }\n\n function totalSupply() public view returns (uint256) {\n return address(this).balance;\n }\n\n function approve(address guy, uint256 wad) public returns (bool) {\n allowance[msg.sender][guy] = wad;\n emit Approval(msg.sender, guy, wad);\n return true;\n }\n\n function transfer(address dst, uint256 wad) public returns (bool) {\n return transferFrom(msg.sender, dst, wad);\n }\n\n function transferFrom(address src, address dst, uint256 wad)\n public\n returns (bool)\n {\n require(balanceOf[src] >= wad, \"insufficient balance\");\n\n if (src != msg.sender) {\n require(\n allowance[src][msg.sender] >= wad,\n \"insufficient allowance\"\n );\n allowance[src][msg.sender] -= wad;\n }\n\n balanceOf[src] -= wad;\n balanceOf[dst] += wad;\n\n emit Transfer(src, dst, wad);\n\n return true;\n }\n}\n" - }, - "contracts/interfaces/IWETH.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @notice It is the interface of functions that we use for the canonical WETH contract.\n *\n * @author develop@teller.finance\n */\ninterface IWETH {\n /**\n * @notice It withdraws ETH from the contract by sending it to the caller and reducing the caller's internal balance of WETH.\n * @param amount The amount of ETH to withdraw.\n */\n function withdraw(uint256 amount) external;\n\n /**\n * @notice It deposits ETH into the contract and increases the caller's internal balance of WETH.\n */\n function deposit() external payable;\n\n /**\n * @notice It gets the ETH deposit balance of an {account}.\n * @param account Address to get balance of.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @notice It transfers the WETH amount specified to the given {account}.\n * @param to Address to transfer to\n * @param value Amount of WETH to transfer\n */\n function transfer(address to, uint256 value) external returns (bool);\n}\n" - }, - "contracts/tests/Test_Helpers.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/ITellerV2.sol\";\nimport \"../interfaces/ITellerV2Context.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ncontract User {\n address public immutable tellerV2;\n\n constructor(address _tellerV2 /*, WethMock _wethMock*/) {\n tellerV2 = _tellerV2;\n }\n\n function addAllowance(\n address _assetContractAddress,\n address _spender,\n uint256 _amount\n ) public {\n IERC20(_assetContractAddress).approve(_spender, _amount);\n }\n\n function createMarket(\n address marketRegistry,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) public returns (uint256) {\n return\n IMarketRegistry(marketRegistry).createMarket(\n address(this),\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n _paymentCycleType,\n _uri\n );\n }\n\n function acceptBid(uint256 _bidId) public {\n ITellerV2(tellerV2).lenderAcceptBid(_bidId);\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n function submitCollateralBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver,\n _collateralInfo\n );\n }\n\n function repayLoanFull(uint256 _bidId) public {\n return ITellerV2(tellerV2).repayLoanFull(_bidId);\n }\n\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n ITellerV2Context(tellerV2).setTrustedMarketForwarder(\n _marketId,\n _forwarder\n );\n }\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n ITellerV2Context(tellerV2).approveMarketForwarder(\n _marketId,\n _forwarder\n );\n }\n\n receive() external payable {}\n}\n" - }, - "contracts/escrow/CollateralEscrowV1.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\n// Interfaces\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\";\nimport \"../interfaces/escrow/ICollateralEscrowV1.sol\";\n\ncontract CollateralEscrowV1 is OwnableUpgradeable, ICollateralEscrowV1 {\n uint256 public bidId;\n /* Mappings */\n mapping(address => Collateral) public collateralBalances; // collateral address -> collateral\n\n /* Events */\n event CollateralDeposited(address _collateralAddress, uint256 _amount);\n event CollateralWithdrawn(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n );\n\n /**\n * @notice Initializes an escrow.\n * @notice The id of the associated bid.\n */\n function initialize(uint256 _bidId) public initializer {\n __Ownable_init();\n bidId = _bidId;\n }\n\n function getBid() external view returns (uint256) {\n return bidId;\n }\n\n /**\n * @notice Deposits a collateral ERC20 token into the escrow.\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositToken(address _collateralAddress, uint256 _amount)\n external\n onlyOwner\n {\n require(_amount > 0, \"Deposit amount cannot be zero\");\n _depositCollateral(\n CollateralType.ERC20,\n _collateralAddress,\n _amount,\n 0\n );\n Collateral storage collateral = collateralBalances[_collateralAddress];\n collateral._collateralType = CollateralType.ERC20;\n collateral._amount = _amount;\n emit CollateralDeposited(_collateralAddress, _amount);\n }\n\n /**\n * @notice Deposits a collateral asset into the escrow.\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositAsset(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) external payable onlyOwner {\n require(_amount > 0, \"Deposit amount cannot be zero\");\n _depositCollateral(\n _collateralType,\n _collateralAddress,\n _amount,\n _tokenId\n );\n Collateral storage collateral = collateralBalances[_collateralAddress];\n collateral._collateralType = _collateralType;\n collateral._amount = _amount;\n collateral._tokenId = _tokenId;\n emit CollateralDeposited(_collateralAddress, _amount);\n }\n\n /**\n * @notice Withdraws a collateral asset from the escrow.\n * @param _collateralAddress The address of the collateral contract.\n * @param _amount The amount to withdraw.\n * @param _recipient The address to send the assets to.\n */\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) external onlyOwner {\n require(_amount > 0, \"Withdraw amount cannot be zero\");\n Collateral storage collateral = collateralBalances[_collateralAddress];\n require(\n collateral._amount >= _amount,\n \"No collateral balance for asset\"\n );\n _withdrawCollateral(\n collateral,\n _collateralAddress,\n _amount,\n _recipient\n );\n collateral._amount -= _amount;\n emit CollateralWithdrawn(_collateralAddress, _amount, _recipient);\n }\n\n function _depositCollateral(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) internal {\n // Deposit ERC20\n if (_collateralType == CollateralType.ERC20) {\n SafeERC20Upgradeable.safeTransferFrom(\n IERC20Upgradeable(_collateralAddress),\n _msgSender(),\n address(this),\n _amount\n );\n }\n // Deposit ERC721\n else if (_collateralType == CollateralType.ERC721) {\n require(_amount == 1, \"Incorrect deposit amount\");\n IERC721Upgradeable(_collateralAddress).transferFrom(\n _msgSender(),\n address(this),\n _tokenId\n );\n }\n // Deposit ERC1155\n else if (_collateralType == CollateralType.ERC1155) {\n bytes memory data;\n\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\n _msgSender(),\n address(this),\n _tokenId,\n _amount,\n data\n );\n }\n }\n\n function _withdrawCollateral(\n Collateral memory _collateral,\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) internal {\n // Withdraw ERC20\n if (_collateral._collateralType == CollateralType.ERC20) {\n IERC20Upgradeable(_collateralAddress).transfer(\n _recipient,\n _collateral._amount\n );\n }\n // Withdraw ERC721\n else if (_collateral._collateralType == CollateralType.ERC721) {\n require(_amount == 1, \"Incorrect withdrawal amount\");\n IERC721Upgradeable(_collateralAddress).transferFrom(\n address(this),\n _recipient,\n _collateral._tokenId\n );\n }\n // Withdraw ERC1155\n else if (_collateral._collateralType == CollateralType.ERC1155) {\n bytes memory data;\n\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\n address(this),\n _recipient,\n _collateral._tokenId,\n _amount,\n data\n );\n }\n }\n\n // On NFT Received handlers\n\n function onERC721Received(address, address, uint256, bytes calldata)\n external\n pure\n returns (bytes4)\n {\n return\n bytes4(\n keccak256(\"onERC721Received(address,address,uint256,bytes)\")\n );\n }\n\n function onERC1155Received(\n address,\n address,\n uint256 id,\n uint256 value,\n bytes calldata\n ) external returns (bytes4) {\n return\n bytes4(\n keccak256(\n \"onERC1155Received(address,address,uint256,uint256,bytes)\"\n )\n );\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata _ids,\n uint256[] calldata _values,\n bytes calldata\n ) external returns (bytes4) {\n require(\n _ids.length == 1,\n \"Only allowed one asset batch transfer per transaction.\"\n );\n return\n bytes4(\n keccak256(\n \"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"\n )\n );\n }\n}\n" - }, - "contracts/LenderCommitmentForwarder.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./TellerV2MarketForwarder.sol\";\n\n// Interfaces\nimport \"./interfaces/ICollateralManager.sol\";\nimport { Collateral, CollateralType } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n// Libraries\nimport { MathUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\ncontract LenderCommitmentForwarder is TellerV2MarketForwarder {\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n\n enum CommitmentCollateralType {\n NONE, // no collateral required\n ERC20,\n ERC721,\n ERC1155,\n ERC721_ANY_ID,\n ERC1155_ANY_ID\n }\n\n /**\n * @notice Details about a lender's capital commitment.\n * @param maxPrincipal Amount of tokens being committed by the lender. Max amount that can be loaned.\n * @param expiration Expiration time in seconds, when the commitment expires.\n * @param maxDuration Length of time, in seconds that the lender's capital can be lent out for.\n * @param minInterestRate Minimum Annual percentage to be applied for loans using the lender's capital.\n * @param collateralTokenAddress The address for the token contract that must be used to provide collateral for loans for this commitment.\n * @param maxPrincipalPerCollateralAmount The amount of principal that can be used for a loan per each unit of collateral, expanded additionally by principal decimals.\n * @param collateralTokenType The type of asset of the collateralTokenAddress (ERC20, ERC721, or ERC1155).\n * @param lender The address of the lender for this commitment.\n * @param marketId The market id for this commitment.\n * @param principalTokenAddress The address for the token contract that will be used to provide principal for loans of this commitment.\n */\n struct Commitment {\n uint256 maxPrincipal;\n uint32 expiration;\n uint32 maxDuration;\n uint16 minInterestRate;\n address collateralTokenAddress;\n uint256 collateralTokenId;\n uint256 maxPrincipalPerCollateralAmount;\n CommitmentCollateralType collateralTokenType;\n address lender;\n uint256 marketId;\n address principalTokenAddress;\n }\n\n // CommitmentId => commitment\n mapping(uint256 => Commitment) public commitments;\n\n uint256 commitmentCount;\n\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet)\n internal commitmentBorrowersList;\n\n /**\n * @notice This event is emitted when a lender's commitment is created.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event CreatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when a lender's commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event UpdatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when the allowed borrowers for a commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n */\n event UpdatedCommitmentBorrowers(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment has been deleted.\n * @param commitmentId The id of the commitment that was deleted.\n */\n event DeletedCommitment(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment is exercised for a loan.\n * @param commitmentId The id of the commitment that was exercised.\n * @param borrower The address of the borrower.\n * @param tokenAmount The amount of the asset being committed.\n * @param bidId The bid id for the loan from TellerV2.\n */\n event ExercisedCommitment(\n uint256 indexed commitmentId,\n address borrower,\n uint256 tokenAmount,\n uint256 bidId\n );\n\n error InsufficientCommitmentAllocation(\n uint256 allocated,\n uint256 requested\n );\n error InsufficientBorrowerCollateral(uint256 required, uint256 actual);\n\n /** Modifiers **/\n\n modifier commitmentLender(uint256 _commitmentId) {\n require(\n commitments[_commitmentId].lender == _msgSender(),\n \"unauthorized commitment lender\"\n );\n _;\n }\n\n function validateCommitment(Commitment storage _commitment) internal {\n require(\n _commitment.expiration > uint32(block.timestamp),\n \"expired commitment\"\n );\n require(\n _commitment.maxPrincipal > 0,\n \"commitment principal allocation 0\"\n );\n\n if (_commitment.collateralTokenType != CommitmentCollateralType.NONE) {\n require(\n _commitment.maxPrincipalPerCollateralAmount > 0,\n \"commitment collateral ratio 0\"\n );\n\n if (\n _commitment.collateralTokenType ==\n CommitmentCollateralType.ERC20\n ) {\n require(\n _commitment.collateralTokenId == 0,\n \"commitment collateral token id must be 0 for ERC20\"\n );\n }\n }\n }\n\n /** External Functions **/\n\n constructor(address _protocolAddress, address _marketRegistry)\n TellerV2MarketForwarder(_protocolAddress, _marketRegistry)\n {}\n\n /**\n * @notice Creates a loan commitment from a lender for a market.\n * @param _commitment The new commitment data expressed as a struct\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\n * @return commitmentId_ returns the commitmentId for the created commitment\n */\n function createCommitment(\n Commitment calldata _commitment,\n address[] calldata _borrowerAddressList\n ) public returns (uint256 commitmentId_) {\n commitmentId_ = commitmentCount++;\n\n require(\n _commitment.lender == _msgSender(),\n \"unauthorized commitment creator\"\n );\n\n commitments[commitmentId_] = _commitment;\n\n validateCommitment(commitments[commitmentId_]);\n\n _addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList);\n\n emit CreatedCommitment(\n commitmentId_,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n /**\n * @notice Updates the commitment of a lender to a market.\n * @param _commitmentId The Id of the commitment to update.\n * @param _commitment The new commitment data expressed as a struct\n */\n function updateCommitment(\n uint256 _commitmentId,\n Commitment calldata _commitment\n ) public commitmentLender(_commitmentId) {\n require(\n _commitment.principalTokenAddress ==\n commitments[_commitmentId].principalTokenAddress,\n \"Principal token address cannot be updated.\"\n );\n require(\n _commitment.marketId == commitments[_commitmentId].marketId,\n \"Market Id cannot be updated.\"\n );\n\n commitments[_commitmentId] = _commitment;\n\n validateCommitment(commitments[_commitmentId]);\n\n emit UpdatedCommitment(\n _commitmentId,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n /**\n * @notice Updates the borrowers allowed to accept a commitment\n * @param _commitmentId The Id of the commitment to update.\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\n */\n function updateCommitmentBorrowers(\n uint256 _commitmentId,\n address[] calldata _borrowerAddressList\n ) public commitmentLender(_commitmentId) {\n delete commitmentBorrowersList[_commitmentId];\n _addBorrowersToCommitmentAllowlist(_commitmentId, _borrowerAddressList);\n }\n\n /**\n * @notice Adds a borrower to the allowlist for a commmitment.\n * @param _commitmentId The id of the commitment that will allow the new borrower\n * @param _borrowerArray the address array of the borrowers that will be allowed to accept loans using the commitment\n */\n function _addBorrowersToCommitmentAllowlist(\n uint256 _commitmentId,\n address[] calldata _borrowerArray\n ) internal {\n for (uint256 i = 0; i < _borrowerArray.length; i++) {\n commitmentBorrowersList[_commitmentId].add(_borrowerArray[i]);\n }\n if (_borrowerArray.length > 0) {\n emit UpdatedCommitmentBorrowers(_commitmentId);\n }\n }\n\n /**\n * @notice Removes the commitment of a lender to a market.\n * @param _commitmentId The id of the commitment to delete.\n */\n function deleteCommitment(uint256 _commitmentId)\n public\n commitmentLender(_commitmentId)\n {\n delete commitments[_commitmentId];\n delete commitmentBorrowersList[_commitmentId];\n emit DeletedCommitment(_commitmentId);\n }\n\n /**\n * @notice Reduces the commitment amount for a lender to a market.\n * @param _commitmentId The id of the commitment to modify.\n * @param _tokenAmountDelta The amount of change in the maxPrincipal.\n */\n function _decrementCommitment(\n uint256 _commitmentId,\n uint256 _tokenAmountDelta\n ) internal {\n commitments[_commitmentId].maxPrincipal -= _tokenAmountDelta;\n }\n\n /**\n * @notice Accept the commitment to submitBid and acceptBid using the funds\n * @dev LoanDuration must be longer than the market payment cycle\n * @param _commitmentId The id of the commitment being accepted.\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId of collateral to use for the loan if ERC721 or ERC1155.\n * @param _collateralTokenAddress The contract address to use for the loan collateral token.s\n * @param _interestRate The interest rate APY to use for the loan in basis points.\n * @param _loanDuration The overall duratiion for the loan. Must be longer than market payment cycle duration.\n * @return bidId The ID of the loan that was created on TellerV2\n */\n function acceptCommitment(\n uint256 _commitmentId,\n uint256 _principalAmount,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n address _collateralTokenAddress,\n uint16 _interestRate,\n uint32 _loanDuration\n ) external returns (uint256 bidId) {\n address borrower = _msgSender();\n\n Commitment storage commitment = commitments[_commitmentId];\n\n validateCommitment(commitment);\n\n require(\n _collateralTokenAddress == commitment.collateralTokenAddress,\n \"Mismatching collateral token\"\n );\n require(\n _interestRate >= commitment.minInterestRate,\n \"Invalid interest rate\"\n );\n require(\n _loanDuration <= commitment.maxDuration,\n \"Invalid loan max duration\"\n );\n\n require(\n commitmentBorrowersList[_commitmentId].length() == 0 ||\n commitmentBorrowersList[_commitmentId].contains(borrower),\n \"unauthorized commitment borrower\"\n );\n\n if (_principalAmount > commitment.maxPrincipal) {\n revert InsufficientCommitmentAllocation({\n allocated: commitment.maxPrincipal,\n requested: _principalAmount\n });\n }\n\n uint256 requiredCollateral = getRequiredCollateral(\n _principalAmount,\n commitment.maxPrincipalPerCollateralAmount,\n commitment.collateralTokenType,\n commitment.collateralTokenAddress,\n commitment.principalTokenAddress\n );\n if (_collateralAmount < requiredCollateral) {\n revert InsufficientBorrowerCollateral({\n required: requiredCollateral,\n actual: _collateralAmount\n });\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType ==\n CommitmentCollateralType.ERC721_ANY_ID\n ) {\n require(\n _collateralAmount == 1,\n \"invalid commitment collateral amount for ERC721\"\n );\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType == CommitmentCollateralType.ERC1155\n ) {\n require(\n commitment.collateralTokenId == _collateralTokenId,\n \"invalid commitment collateral tokenId\"\n );\n }\n\n bidId = _submitBidFromCommitment(\n borrower,\n commitment.marketId,\n commitment.principalTokenAddress,\n _principalAmount,\n commitment.collateralTokenAddress,\n _collateralAmount,\n _collateralTokenId,\n commitment.collateralTokenType,\n _loanDuration,\n _interestRate\n );\n\n _acceptBid(bidId, commitment.lender);\n\n _decrementCommitment(_commitmentId, _principalAmount);\n\n emit ExercisedCommitment(\n _commitmentId,\n borrower,\n _principalAmount,\n bidId\n );\n }\n\n /**\n * @notice Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _maxPrincipalPerCollateralAmount The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\n * @param _collateralTokenType The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\n * @param _collateralTokenAddress The contract address for the collateral for the loan.\n * @param _principalTokenAddress The contract address for the principal for the loan.\n */\n function getRequiredCollateral(\n uint256 _principalAmount,\n uint256 _maxPrincipalPerCollateralAmount,\n CommitmentCollateralType _collateralTokenType,\n address _collateralTokenAddress,\n address _principalTokenAddress\n ) public view virtual returns (uint256) {\n if (_collateralTokenType == CommitmentCollateralType.NONE) {\n return 0;\n }\n\n uint8 collateralDecimals;\n uint8 principalDecimals = IERC20MetadataUpgradeable(\n _principalTokenAddress\n ).decimals();\n\n if (_collateralTokenType == CommitmentCollateralType.ERC20) {\n collateralDecimals = IERC20MetadataUpgradeable(\n _collateralTokenAddress\n ).decimals();\n }\n\n /*\n * The principalAmount is expanded by (collateralDecimals+principalDecimals) to increase precision\n * and then it is divided by _maxPrincipalPerCollateralAmount which should already been expanded by principalDecimals\n */\n return\n MathUpgradeable.mulDiv(\n _principalAmount,\n (10**(collateralDecimals + principalDecimals)),\n _maxPrincipalPerCollateralAmount,\n MathUpgradeable.Rounding.Up\n );\n }\n\n /**\n * @notice Return the array of borrowers that are allowlisted for a commitment\n * @param _commitmentId The commitment id for the commitment to query.\n * @return borrowers_ An array of addresses restricted to accept the commitment. Empty array means unrestricted.\n */\n function getCommitmentBorrowers(uint256 _commitmentId)\n external\n view\n returns (address[] memory borrowers_)\n {\n borrowers_ = commitmentBorrowersList[_commitmentId].values();\n }\n\n /**\n * @notice Internal function to submit a bid to the lending protocol using a commitment\n * @param _borrower The address of the borrower for the loan.\n * @param _marketId The id for the market of the loan in the lending protocol.\n * @param _principalTokenAddress The contract address for the principal token.\n * @param _principalAmount The amount of principal to borrow for the loan.\n * @param _collateralTokenAddress The contract address for the collateral token.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId for the collateral (if it is ERC721 or ERC1155).\n * @param _collateralTokenType The type of collateral token (ERC20,ERC721,ERC1177,None).\n * @param _loanDuration The duration of the loan in seconds delta. Must be longer than loan payment cycle for the market.\n * @param _interestRate The amount of interest APY for the loan expressed in basis points.\n */\n function _submitBidFromCommitment(\n address _borrower,\n uint256 _marketId,\n address _principalTokenAddress,\n uint256 _principalAmount,\n address _collateralTokenAddress,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n CommitmentCollateralType _collateralTokenType,\n uint32 _loanDuration,\n uint16 _interestRate\n ) internal returns (uint256 bidId) {\n CreateLoanArgs memory createLoanArgs;\n createLoanArgs.marketId = _marketId;\n createLoanArgs.lendingToken = _principalTokenAddress;\n createLoanArgs.principal = _principalAmount;\n createLoanArgs.duration = _loanDuration;\n createLoanArgs.interestRate = _interestRate;\n\n Collateral[] memory collateralInfo;\n if (_collateralTokenType != CommitmentCollateralType.NONE) {\n collateralInfo = new Collateral[](1);\n collateralInfo[0] = Collateral({\n _collateralType: _getEscrowCollateralType(_collateralTokenType),\n _tokenId: _collateralTokenId,\n _amount: _collateralAmount,\n _collateralAddress: _collateralTokenAddress\n });\n }\n\n bidId = _submitBidWithCollateral(\n createLoanArgs,\n collateralInfo,\n _borrower\n );\n }\n\n /**\n * @notice Return the collateral type based on the commitmentcollateral type. Collateral type is used in the base lending protocol.\n * @param _type The type of collateral to be used for the loan.\n */\n function _getEscrowCollateralType(CommitmentCollateralType _type)\n internal\n pure\n returns (CollateralType)\n {\n if (_type == CommitmentCollateralType.ERC20) {\n return CollateralType.ERC20;\n }\n if (\n _type == CommitmentCollateralType.ERC721 ||\n _type == CommitmentCollateralType.ERC721_ANY_ID\n ) {\n return CollateralType.ERC721;\n }\n if (\n _type == CommitmentCollateralType.ERC1155 ||\n _type == CommitmentCollateralType.ERC1155_ANY_ID\n ) {\n return CollateralType.ERC1155;\n }\n\n revert(\"Unknown Collateral Type\");\n }\n}\n" - }, - "contracts/tests/resolvers/TestERC20Token.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract TestERC20Token is ERC20 {\n uint8 private immutable DECIMALS;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint8 _decimals\n ) ERC20(_name, _symbol) {\n DECIMALS = _decimals;\n _mint(msg.sender, _totalSupply);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return DECIMALS;\n }\n}\n" - }, - "contracts/MetaForwarder.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol\";\n\ncontract MetaForwarder is MinimalForwarderUpgradeable {\n function initialize() external initializer {\n __EIP712_init_unchained(\"TellerMetaForwarder\", \"0.0.1\");\n }\n}\n" - }, - "contracts/LenderManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/ILenderManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/IMarketRegistry.sol\";\n\ncontract LenderManager is\n Initializable,\n OwnableUpgradeable,\n ERC721Upgradeable,\n ILenderManager\n{\n IMarketRegistry public immutable marketRegistry;\n\n constructor(IMarketRegistry _marketRegistry) {\n marketRegistry = _marketRegistry;\n }\n\n function initialize() external initializer {\n __LenderManager_init();\n }\n\n function __LenderManager_init() internal onlyInitializing {\n __Ownable_init();\n __ERC721_init(\"TellerLoan\", \"TLN\");\n }\n\n /**\n * @notice Registers a new active lender for a loan, minting the nft\n * @param _bidId The id for the loan to set.\n * @param _newLender The address of the new active lender.\n */\n function registerLoan(uint256 _bidId, address _newLender)\n public\n override\n onlyOwner\n {\n _mint(_newLender, _bidId);\n }\n\n /**\n * @notice Returns the address of the lender that owns a given loan/bid.\n * @param _bidId The id of the bid of which to return the market id\n */\n function _getLoanMarketId(uint256 _bidId) internal view returns (uint256) {\n return ITellerV2(owner()).getLoanMarketId(_bidId);\n }\n\n /**\n * @notice Returns the verification status of a lender for a market.\n * @param _lender The address of the lender which should be verified by the market\n * @param _bidId The id of the bid of which to return the market id\n */\n function _hasMarketVerification(address _lender, uint256 _bidId)\n internal\n view\n virtual\n returns (bool isVerified_)\n {\n uint256 _marketId = _getLoanMarketId(_bidId);\n\n (isVerified_, ) = marketRegistry.isVerifiedLender(_marketId, _lender);\n }\n\n /** ERC721 Functions **/\n\n function _beforeTokenTransfer(address, address to, uint256 tokenId, uint256)\n internal\n override\n {\n require(_hasMarketVerification(to, tokenId), \"Not approved by market\");\n }\n\n function _baseURI() internal view override returns (string memory) {\n return \"\";\n }\n}\n" - }, - "@mangrovedao/hardhat-test-solidity/test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0;\n\n// Should be kept in sync with ./lib.js\n\nlibrary Test {\n /* \n * Expect events from contracts\n */\n event ExpectFrom(address from);\n event StopExpecting();\n\n // Usage: from a test contract `t`, call `expectFrom(a)`. \n // Any subsequent non-special event emitted by `t` will mean \n // \"I expect `a` to emit the exact same event\". \n // The order of expectations must be respected.\n function expectFrom(address from) internal {\n emit ExpectFrom(from);\n }\n\n // After using `expectFrom` and emitting some events you expect\n // to see emitted elsewhere, you can use `stopExpecting` to emit \n // further, normal events from your test.\n function stopExpecting() internal {\n emit StopExpecting();\n }\n\n\n /* \n * Boolean test\n */\n event TestTrue(bool success, string message);\n\n // Succeed iff success is true\n function check(bool success, string memory message) internal {\n emit TestTrue(success, message);\n }\n\n\n /* \n * Always fail, always succeed\n */\n function fail(string memory message) internal {\n emit TestTrue(false, message);\n }\n\n function succeed() internal {\n emit TestTrue(true, \"Success\");\n }\n\n /* \n * Equality testing\n * ! overloaded as `eq` for everything except for bytes use `eq0`.\n */\n\n // Bytes\n event TestEqBytes(bool success, bytes actual, bytes expected, string message);\n\n function eq0(\n bytes memory actual,\n bytes memory expected,\n string memory message\n ) internal returns (bool) {\n bool success = keccak256((actual)) == keccak256((expected));\n emit TestEqBytes(success, actual, expected, message);\n return success;\n }\n\n // Byte32\n event TestEqBytes32(\n bool success,\n bytes32 actual,\n bytes32 expected,\n string message\n );\n\n function eq(\n bytes32 actual,\n bytes32 expected,\n string memory message\n ) internal returns (bool) {\n bool success = (actual == expected);\n emit TestEqBytes32(success, actual, expected, message);\n return success;\n }\n\n // Bool\n event TestEqBool(bool success, bool actual, bool expected, string message);\n function eq(\n bool actual,\n bool expected,\n string memory message\n ) internal returns (bool) {\n bool success = (actual == expected);\n emit TestEqBool(success, actual, expected, message);\n return success;\n }\n\n // uints\n event TestEqUint(bool success, uint actual, uint expected, string message);\n\n function eq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual == expected;\n emit TestEqUint(success, actual, expected, message);\n return success;\n }\n\n // strings\n event TestEqString(\n bool success,\n string actual,\n string expected,\n string message\n );\n\n function eq(\n string memory actual,\n string memory expected,\n string memory message\n ) internal returns (bool) {\n bool success = keccak256(bytes((actual))) == keccak256(bytes((expected)));\n emit TestEqString(success, actual, expected, message);\n return success;\n }\n\n // addresses\n event TestEqAddress(\n bool success,\n address actual,\n address expected,\n string message\n );\n\n\n function eq(\n address actual,\n address expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual == expected;\n emit TestEqAddress(success, actual, expected, message);\n return success;\n }\n\n /* \n * Inequality testing\n */\n event TestLess(bool success, uint actual, uint expected, string message);\n function less(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual < expected;\n emit TestLess(success, actual, expected, message);\n return success;\n }\n\n event TestLessEq(bool success, uint actual, uint expected, string message);\n function lessEq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual <= expected;\n emit TestLessEq(success, actual, expected, message);\n return success;\n }\n\n event TestMore(bool success, uint actual, uint expected, string message);\n function more(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual > expected;\n emit TestMore(success, actual, expected, message);\n return success;\n }\n\n event TestMoreEq(bool success, uint actual, uint expected, string message);\n function moreEq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual >= expected;\n emit TestMoreEq(success, actual, expected, message);\n return success;\n }\n}\n\n// /* Either cast your arguments to address when you call balanceOf logging functions\n// or add `is address` to your ERC20s\n// or use the overloads with `address` types */\ninterface ERC20BalanceOf {\n function balanceOf(address account) view external returns (uint);\n}\n\n\nlibrary Display {\n /* ****************************************************************\n * Register/read address->name mappings to make logs easier to read.\n *****************************************************************/\n /* \n * Names are stored in the contract using the library.\n */\n\n // Disgusting hack so a library can manipulate storage refs.\n bytes32 constant NAMES_POS = keccak256(\"Display.NAMES_POS\");\n // Store mapping in library caller's storage.\n // That's quite fragile.\n struct Registers {\n mapping(address => string) map;\n }\n\n // Also send mapping to javascript test interpreter. The interpreter COULD\n // just make an EVM call to map every name but that would probably be very\n // slow. So we cache locally.\n event Register(address addr, string name);\n\n function registers() internal view returns (Registers storage) {\n this; // silence warning about pure mutability\n Registers storage regs;\n bytes32 _slot = NAMES_POS;\n assembly {\n regs.slot := _slot\n }\n return regs;\n }\n\n /*\n * Give a name to an address for logging purposes\n * @example\n * ```solidity\n * address addr = address(new Contract());\n * register(addr,\"My Contract instance\");\n * ```\n */\n\n function register(address addr, string memory name) internal {\n registers().map[addr] = name;\n emit Register(addr, name);\n }\n\n /*\n * Read the name of a registered address. Default: \"\". \n */\n function nameOf(address addr) internal view returns (string memory) {\n string memory s = registers().map[addr];\n if (keccak256(bytes(s)) != keccak256(bytes(\"\"))) {\n return s;\n } else {\n return \"\";\n }\n }\n\n /* 1 arg logging (string/uint) */\n\n event LogString(string a);\n\n function log(string memory a) internal {\n emit LogString(a);\n }\n\n event LogUint(uint a);\n\n function log(uint a) internal {\n emit LogUint(a);\n }\n\n /* 2 arg logging (string/uint) */\n\n event LogStringString(string a, string b);\n\n function log(string memory a, string memory b) internal {\n emit LogStringString(a, b);\n }\n\n event LogStringUint(string a, uint b);\n\n function log(string memory a, uint b) internal {\n emit LogStringUint(a, b);\n }\n\n event LogUintUint(uint a, uint b);\n\n function log(uint a, uint b) internal {\n emit LogUintUint(a, b);\n }\n\n event LogUintString(uint a, string b);\n\n function log(uint a, string memory b) internal {\n emit LogUintString(a, b);\n }\n\n /* 3 arg logging (string/uint) */\n\n event LogStringStringString(string a, string b, string c);\n\n function log(\n string memory a,\n string memory b,\n string memory c\n ) internal {\n emit LogStringStringString(a, b, c);\n }\n\n event LogStringStringUint(string a, string b, uint c);\n\n function log(\n string memory a,\n string memory b,\n uint c\n ) internal {\n emit LogStringStringUint(a, b, c);\n }\n\n event LogStringUintUint(string a, uint b, uint c);\n\n function log(\n string memory a,\n uint b,\n uint c\n ) internal {\n emit LogStringUintUint(a, b, c);\n }\n\n event LogStringUintString(string a, uint b, string c);\n\n function log(\n string memory a,\n uint b,\n string memory c\n ) internal {\n emit LogStringUintString(a, b, c);\n }\n\n event LogUintUintUint(uint a, uint b, uint c);\n\n function log(\n uint a,\n uint b,\n uint c\n ) internal {\n emit LogUintUintUint(a, b, c);\n }\n\n event LogUintStringUint(uint a, string b, uint c);\n\n function log(\n uint a,\n string memory b,\n uint c\n ) internal {\n emit LogUintStringUint(a, b, c);\n }\n\n event LogUintStringString(uint a, string b, string c);\n\n function log(\n uint a,\n string memory b,\n string memory c\n ) internal {\n emit LogUintStringString(a, b, c);\n }\n\n /* End of register/read section */\n event ERC20Balances(address[] tokens, address[] accounts, uint[] balances);\n\n function logBalances(\n address[1] memory _tokens, \n address _a0\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](1);\n accounts[0] = _a0;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[1] memory _tokens,\n address _a0,\n address _a1\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](2);\n accounts[0] = _a0;\n accounts[1] = _a1;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[1] memory _tokens,\n address _a0,\n address _a1,\n address _a2\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](3);\n accounts[0] = _a0;\n accounts[1] = _a1;\n accounts[2] = _a2;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](1);\n accounts[0] = _a0;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0,\n address _a1\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](2);\n accounts[0] = _a0;\n accounts[1] = _a1;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0,\n address _a1,\n address _a2\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](3);\n accounts[0] = _a0;\n accounts[1] = _a1;\n accounts[2] = _a2;\n logBalances(tokens, accounts);\n }\n\n /* takes [t1,...,tM], [a1,...,aN]\n logs also [...b(t1,aj) ... b(tM,aj) ...] */\n\n function logBalances(address[] memory tokens, address[] memory accounts)\n internal\n {\n uint[] memory balances = new uint[](tokens.length * accounts.length);\n for (uint i = 0; i < tokens.length; i++) {\n for (uint j = 0; j < accounts.length; j++) {\n uint bal = ERC20BalanceOf(tokens[i]).balanceOf(accounts[j]);\n balances[i * accounts.length + j] = bal;\n //console.log(tokens[i].symbol(),nameOf(accounts[j]),bal);\n }\n }\n emit ERC20Balances(tokens, accounts, balances);\n }\n\n}" - }, - "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n constructor(address implementation_) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" - }, - "contracts/ProtocolFee.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract ProtocolFee is OwnableUpgradeable {\n // Protocol fee set for loan processing.\n uint16 private _protocolFee;\n\n /**\n * @notice This event is emitted when the protocol fee has been updated.\n * @param newFee The new protocol fee set.\n * @param oldFee The previously set protocol fee.\n */\n event ProtocolFeeSet(uint16 newFee, uint16 oldFee);\n\n /**\n * @notice Initialized the protocol fee.\n * @param initFee The initial protocol fee to be set on the protocol.\n */\n function __ProtocolFee_init(uint16 initFee) internal onlyInitializing {\n __Ownable_init();\n __ProtocolFee_init_unchained(initFee);\n }\n\n function __ProtocolFee_init_unchained(uint16 initFee)\n internal\n onlyInitializing\n {\n setProtocolFee(initFee);\n }\n\n /**\n * @notice Returns the current protocol fee.\n */\n function protocolFee() public view virtual returns (uint16) {\n return _protocolFee;\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol to set a new protocol fee.\n * @param newFee The new protocol fee to be set.\n */\n function setProtocolFee(uint16 newFee) public virtual onlyOwner {\n // Skip if the fee is the same\n if (newFee == _protocolFee) return;\n\n uint16 oldFee = _protocolFee;\n _protocolFee = newFee;\n emit ProtocolFeeSet(newFee, oldFee);\n }\n}\n" - }, - "contracts/TellerV2Context.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2Storage.sol\";\nimport \"./ERC2771ContextUpgradeable.sol\";\n\n/**\n * @dev This contract should not use any storage\n */\n\nabstract contract TellerV2Context is\n ERC2771ContextUpgradeable,\n TellerV2Storage\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n event TrustedMarketForwarderSet(\n uint256 indexed marketId,\n address forwarder,\n address sender\n );\n event MarketForwarderApproved(\n uint256 indexed marketId,\n address indexed forwarder,\n address sender\n );\n\n constructor(address trustedForwarder)\n ERC2771ContextUpgradeable(trustedForwarder)\n {}\n\n /**\n * @notice Checks if an address is a trusted forwarder contract for a given market.\n * @param _marketId An ID for a lending market.\n * @param _trustedMarketForwarder An address to check if is a trusted forwarder in the given market.\n * @return A boolean indicating the forwarder address is trusted in a market.\n */\n function isTrustedMarketForwarder(\n uint256 _marketId,\n address _trustedMarketForwarder\n ) public view returns (bool) {\n return\n _trustedMarketForwarders[_marketId] == _trustedMarketForwarder ||\n lenderCommitmentForwarder == _trustedMarketForwarder;\n }\n\n /**\n * @notice Checks if an account has approved a forwarder for a market.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n * @param _account The address to verify set an approval.\n * @return A boolean indicating if an approval was set.\n */\n function hasApprovedMarketForwarder(\n uint256 _marketId,\n address _forwarder,\n address _account\n ) public view returns (bool) {\n return\n isTrustedMarketForwarder(_marketId, _forwarder) &&\n _approvedForwarderSenders[_forwarder].contains(_account);\n }\n\n /**\n * @notice Sets a trusted forwarder for a lending market.\n * @notice The caller must owner the market given. See {MarketRegistry}\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n marketRegistry.getMarketOwner(_marketId) == _msgSender(),\n \"Caller must be the market owner\"\n );\n _trustedMarketForwarders[_marketId] = _forwarder;\n emit TrustedMarketForwarderSet(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Approves a forwarder contract to use their address as a sender for a specific market.\n * @notice The forwarder given must be trusted by the market given.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n isTrustedMarketForwarder(_marketId, _forwarder),\n \"Forwarder must be trusted by the market\"\n );\n _approvedForwarderSenders[_forwarder].add(_msgSender());\n emit MarketForwarderApproved(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Retrieves the function caller address by checking the appended calldata if the _actual_ caller is a trusted forwarder.\n * @param _marketId An ID for a lending market.\n * @return sender The address to use as the function caller.\n */\n function _msgSenderForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (address)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n address sender;\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n // Ensure the appended sender address approved the forwarder\n require(\n _approvedForwarderSenders[_msgSender()].contains(sender),\n \"Sender must approve market forwarder\"\n );\n return sender;\n }\n\n return _msgSender();\n }\n\n /**\n * @notice Retrieves the actual function calldata from a trusted forwarder call.\n * @param _marketId An ID for a lending market to verify if the caller is a trusted forwarder.\n * @return calldata The modified bytes array of the function calldata without the appended sender's address.\n */\n function _msgDataForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (bytes calldata)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n return msg.data[:msg.data.length - 20];\n } else {\n return _msgData();\n }\n }\n}\n" - }, - "contracts/libraries/DateTimeLib.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint constant SECONDS_PER_DAY = 24 * 60 * 60;\n uint constant SECONDS_PER_HOUR = 60 * 60;\n uint constant SECONDS_PER_MINUTE = 60;\n int constant OFFSET19700101 = 2440588;\n\n uint constant DOW_MON = 1;\n uint constant DOW_TUE = 2;\n uint constant DOW_WED = 3;\n uint constant DOW_THU = 4;\n uint constant DOW_FRI = 5;\n uint constant DOW_SAT = 6;\n uint constant DOW_SUN = 7;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(uint year, uint month, uint day)\n internal\n pure\n returns (uint _days)\n {\n require(year >= 1970);\n int _year = int(year);\n int _month = int(month);\n int _day = int(day);\n\n int __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n OFFSET19700101;\n\n _days = uint(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint _days)\n internal\n pure\n returns (uint year, uint month, uint day)\n {\n int __days = int(_days);\n\n int L = __days + 68569 + OFFSET19700101;\n int N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int _month = (80 * L) / 2447;\n int _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint(_year);\n month = uint(_month);\n day = uint(_day);\n }\n\n function timestampFromDate(uint year, uint month, uint day)\n internal\n pure\n returns (uint timestamp)\n {\n timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n ) internal pure returns (uint timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n hour *\n SECONDS_PER_HOUR +\n minute *\n SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint timestamp)\n internal\n pure\n returns (uint year, uint month, uint day)\n {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint timestamp)\n internal\n pure\n returns (\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n )\n {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n uint secs = timestamp % SECONDS_PER_DAY;\n hour = secs / SECONDS_PER_HOUR;\n secs = secs % SECONDS_PER_HOUR;\n minute = secs / SECONDS_PER_MINUTE;\n second = secs % SECONDS_PER_MINUTE;\n }\n\n function isValidDate(uint year, uint month, uint day)\n internal\n pure\n returns (bool valid)\n {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint timestamp) internal pure returns (bool leapYear) {\n (uint year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint year) internal pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= DOW_FRI;\n }\n\n function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;\n }\n\n function getDaysInMonth(uint timestamp)\n internal\n pure\n returns (uint daysInMonth)\n {\n (uint year, uint month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint year, uint month)\n internal\n pure\n returns (uint daysInMonth)\n {\n if (\n month == 1 ||\n month == 3 ||\n month == 5 ||\n month == 7 ||\n month == 8 ||\n month == 10 ||\n month == 12\n ) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint timestamp)\n internal\n pure\n returns (uint dayOfWeek)\n {\n uint _days = timestamp / SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint timestamp) internal pure returns (uint year) {\n (year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getMonth(uint timestamp) internal pure returns (uint month) {\n (, month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getDay(uint timestamp) internal pure returns (uint day) {\n (, , day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getHour(uint timestamp) internal pure returns (uint hour) {\n uint secs = timestamp % SECONDS_PER_DAY;\n hour = secs / SECONDS_PER_HOUR;\n }\n\n function getMinute(uint timestamp) internal pure returns (uint minute) {\n uint secs = timestamp % SECONDS_PER_HOUR;\n minute = secs / SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint timestamp) internal pure returns (uint second) {\n second = timestamp % SECONDS_PER_MINUTE;\n }\n\n function addYears(uint timestamp, uint _years)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n year += _years;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint timestamp, uint _months)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint timestamp, uint _days)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _days * SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint timestamp, uint _hours)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint timestamp, uint _minutes)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint timestamp, uint _seconds)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint timestamp, uint _years)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n year -= _years;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint timestamp, uint _months)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n uint yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint timestamp, uint _days)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _days * SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint timestamp, uint _hours)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint timestamp, uint _minutes)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint timestamp, uint _seconds)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _years)\n {\n require(fromTimestamp <= toTimestamp);\n (uint fromYear, , ) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);\n (uint toYear, , ) = _daysToDate(toTimestamp / SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _months)\n {\n require(fromTimestamp <= toTimestamp);\n (uint fromYear, uint fromMonth, ) = _daysToDate(\n fromTimestamp / SECONDS_PER_DAY\n );\n (uint toYear, uint toMonth, ) = _daysToDate(\n toTimestamp / SECONDS_PER_DAY\n );\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _days)\n {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;\n }\n\n function diffHours(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _hours)\n {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _minutes)\n {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _seconds)\n {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = MathUpgradeable.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, MathUpgradeable.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "contracts/ERC2771ContextUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n * @dev This is modified from the OZ library to remove the gap of storage variables at the end.\n */\nabstract contract ERC2771ContextUpgradeable is\n Initializable,\n ContextUpgradeable\n{\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address private immutable _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder)\n public\n view\n virtual\n returns (bool)\n {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender()\n internal\n view\n virtual\n override\n returns (address sender)\n {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData()\n internal\n view\n virtual\n override\n returns (bytes calldata)\n {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "contracts/EAS/TellerASResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IASResolver.sol\";\n\n/**\n * @title A base resolver contract\n */\nabstract contract TellerASResolver is IASResolver {\n error NotPayable();\n\n function isPayable() public pure virtual override returns (bool) {\n return false;\n }\n\n receive() external payable virtual {\n if (!isPayable()) {\n revert NotPayable();\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" - }, - "contracts/interfaces/ITellerV2Context.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Context {\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external;\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "contracts/TellerV2MarketForwarder.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\n\nimport \"./interfaces/IMarketRegistry.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\n\n/**\n * @dev Simple helper contract to forward an encoded function call to the TellerV2 contract. See {TellerV2Context}\n */\nabstract contract TellerV2MarketForwarder is Initializable, ContextUpgradeable {\n using AddressUpgradeable for address;\n\n address public immutable _tellerV2;\n address public immutable _marketRegistry;\n\n struct CreateLoanArgs {\n uint256 marketId;\n address lendingToken;\n uint256 principal;\n uint32 duration;\n uint16 interestRate;\n string metadataURI;\n address recipient;\n }\n\n constructor(address _protocolAddress, address _marketRegistryAddress) {\n _tellerV2 = _protocolAddress;\n _marketRegistry = _marketRegistryAddress;\n }\n\n function getTellerV2() public view returns (address) {\n return _tellerV2;\n }\n\n function getMarketRegistry() public view returns (address) {\n return _marketRegistry;\n }\n\n function getTellerV2MarketOwner(uint256 marketId) public returns (address) {\n return IMarketRegistry(getMarketRegistry()).getMarketOwner(marketId);\n }\n\n /**\n * @dev Performs function call to the TellerV2 contract by appending an address to the calldata.\n * @param _data The encoded function calldata on TellerV2.\n * @param _msgSender The address that should be treated as the underlying function caller.\n * @return The encoded response from the called function.\n *\n * Requirements:\n * - The {_msgSender} address must set an approval on TellerV2 for this forwarder contract __before__ making this call.\n */\n function _forwardCall(bytes memory _data, address _msgSender)\n internal\n returns (bytes memory)\n {\n return\n address(_tellerV2).functionCall(\n abi.encodePacked(_data, _msgSender)\n );\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBid(\n CreateLoanArgs memory _createLoanArgs,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address)\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBidWithCollateral(\n CreateLoanArgs memory _createLoanArgs,\n Collateral[] memory _collateralInfo,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient,\n _collateralInfo\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Accepts a new loan using the TellerV2 lending protocol.\n * @param _bidId The id of the new loan.\n * @param _lender The address of the lender who will provide funds for the new loan.\n */\n function _acceptBid(uint256 _bidId, address _lender)\n internal\n virtual\n returns (bool)\n {\n // Approve the borrower's loan\n _forwardCall(\n abi.encodeWithSelector(ITellerV2.lenderAcceptBid.selector, _bidId),\n _lender\n );\n\n return true;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (metatx/MinimalForwarder.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../utils/cryptography/EIP712Upgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Simple minimal forwarder to be used together with an ERC2771 compatible contract. See {ERC2771Context}.\n *\n * MinimalForwarder is mainly meant for testing, as it is missing features to be a good production-ready forwarder. This\n * contract does not intend to have all the properties that are needed for a sound forwarding system. A fully\n * functioning forwarding system with good properties requires more complexity. We suggest you look at other projects\n * such as the GSN which do have the goal of building a system like that.\n */\ncontract MinimalForwarderUpgradeable is Initializable, EIP712Upgradeable {\n using ECDSAUpgradeable for bytes32;\n\n struct ForwardRequest {\n address from;\n address to;\n uint256 value;\n uint256 gas;\n uint256 nonce;\n bytes data;\n }\n\n bytes32 private constant _TYPEHASH =\n keccak256(\"ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data)\");\n\n mapping(address => uint256) private _nonces;\n\n function __MinimalForwarder_init() internal onlyInitializing {\n __EIP712_init_unchained(\"MinimalForwarder\", \"0.0.1\");\n }\n\n function __MinimalForwarder_init_unchained() internal onlyInitializing {}\n\n function getNonce(address from) public view returns (uint256) {\n return _nonces[from];\n }\n\n function verify(ForwardRequest calldata req, bytes calldata signature) public view returns (bool) {\n address signer = _hashTypedDataV4(\n keccak256(abi.encode(_TYPEHASH, req.from, req.to, req.value, req.gas, req.nonce, keccak256(req.data)))\n ).recover(signature);\n return _nonces[req.from] == req.nonce && signer == req.from;\n }\n\n function execute(ForwardRequest calldata req, bytes calldata signature)\n public\n payable\n returns (bool, bytes memory)\n {\n require(verify(req, signature), \"MinimalForwarder: signature does not match request\");\n _nonces[req.from] = req.nonce + 1;\n\n (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}(\n abi.encodePacked(req.data, req.from)\n );\n\n // Validate that the relayer has sent enough gas for the call.\n // See https://ronan.eth.limo/blog/ethereum-gas-dangers/\n if (gasleft() <= req.gas / 63) {\n // We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since\n // neither revert or assert consume all gas since Solidity 0.8.0\n // https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require\n /// @solidity memory-safe-assembly\n assembly {\n invalid()\n }\n }\n\n return (success, returndata);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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 if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC721_init_unchained(name_, symbol_);\n }\n\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721Upgradeable.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256, /* firstTokenId */\n uint256 batchSize\n ) internal virtual {\n if (batchSize > 1) {\n if (from != address(0)) {\n _balances[from] -= batchSize;\n }\n if (to != address(0)) {\n _balances[to] += batchSize;\n }\n }\n }\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 firstTokenId,\n uint256 batchSize\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[44] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "contracts/tests/V2Calculations_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/Arrays.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nimport \"hardhat/console.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\nimport { Bid } from \"../TellerV2Storage.sol\";\nimport { PaymentType } from \"../libraries/V2Calculations.sol\";\n\ncontract V2Calculations_Test is Testable {\n using Arrays for uint256[];\n using EnumerableSet for EnumerableSet.UintSet;\n\n Bid __bid;\n EnumerableSet.UintSet cyclesToSkip;\n uint256[] cyclesWithExtraPayments;\n uint256[] cyclesWithExtraPaymentsAmounts;\n\n constructor() {\n __bid.loanDetails.principal = 100000e6; // 100k\n __bid.loanDetails.loanDuration = 365 days * 3; // 3 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 1000; // 10.0%\n }\n\n function setup_beforeAll() public {\n delete cyclesToSkip;\n delete cyclesWithExtraPayments;\n delete cyclesWithExtraPaymentsAmounts;\n }\n\n // EMI loan\n function _01_calculateAmountOwed_test() public {\n cyclesToSkip.add(2);\n cyclesWithExtraPayments = [3, 4];\n cyclesWithExtraPaymentsAmounts = [25000e6, 25000e6];\n\n calculateAmountOwed_runner(\n 18,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan\n function _02_calculateAmountOwed_test() public {\n cyclesToSkip.add(3);\n cyclesToSkip.add(4);\n cyclesToSkip.add(5);\n\n calculateAmountOwed_runner(\n 36,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan\n function _03_calculateAmountOwed_test() public {\n cyclesWithExtraPayments = [3, 7];\n cyclesWithExtraPaymentsAmounts = [35000e6, 20000e6];\n\n calculateAmountOwed_runner(\n 16,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan - Monthly payment cycle\n function _04_calculateAmountOwed_test() public {\n cyclesToSkip.add(5);\n cyclesToSkip.add(7);\n\n calculateAmountOwed_runner(\n 36,\n PaymentType.EMI,\n PaymentCycleType.Monthly\n );\n }\n\n // EMI loan - Monthly payment cycle\n function _05_calculateAmountOwed_test() public {\n cyclesWithExtraPayments = [2, 6];\n cyclesWithExtraPaymentsAmounts = [35000e6, 20000e6];\n\n calculateAmountOwed_runner(\n 16,\n PaymentType.EMI,\n PaymentCycleType.Monthly\n );\n }\n\n // Bullet loan\n function _06_calculateAmountOwed_test() public {\n cyclesToSkip.add(6);\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Seconds\n );\n }\n\n // Bullet loan\n function _07_calculateAmountOwed_test() public {\n cyclesToSkip.add(12);\n cyclesWithExtraPayments = [1, 8];\n cyclesWithExtraPaymentsAmounts = [15000e6, 10000e6];\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Seconds\n );\n }\n\n // Bullet loan - Monthly payment cycle\n function _08_calculateAmountOwed_test() public {\n cyclesToSkip.add(5);\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Monthly\n );\n }\n\n // Bullet loan - Monthly paymenty cycle\n function _09_calculateAmountOwed_test() public {\n cyclesToSkip.add(8);\n cyclesWithExtraPayments = [3];\n cyclesWithExtraPaymentsAmounts = [13000e6];\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Monthly\n );\n }\n\n function calculateAmountOwed_runner(\n uint256 expectedTotalCycles,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType\n ) private {\n // Calculate payment cycle amount\n uint256 paymentCycleAmount = V2Calculations.calculatePaymentCycleAmount(\n _paymentType,\n _paymentCycleType,\n __bid.loanDetails.principal,\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle,\n __bid.terms.APR\n );\n\n // Set the bid's payment cycle amount\n __bid.terms.paymentCycleAmount = paymentCycleAmount;\n // Set accepted bid timestamp to now\n __bid.loanDetails.acceptedTimestamp = uint32(block.timestamp);\n\n uint256 nowTimestamp = block.timestamp;\n uint256 skippedPaymentCounter;\n uint256 owedPrincipal = __bid.loanDetails.principal;\n uint256 cycleCount = Math.ceilDiv(\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle\n );\n uint256 cycleIndex;\n while (owedPrincipal > 0) {\n // Increment cycle index\n cycleIndex++;\n\n // Increase timestamp\n nowTimestamp += __bid.terms.paymentCycle;\n\n uint256 duePrincipal;\n uint256 interest;\n (owedPrincipal, duePrincipal, interest) = V2Calculations\n .calculateAmountOwed(__bid, nowTimestamp, _paymentCycleType);\n\n // Check if we should skip this cycle for payments\n if (cyclesToSkip.length() > 0) {\n if (cyclesToSkip.contains(cycleIndex)) {\n // Add this cycle's payment amount to the next cycle's expected payment\n skippedPaymentCounter++;\n continue;\n }\n }\n\n skippedPaymentCounter = 0;\n\n uint256 extraPaymentAmount;\n // Add additional payment amounts for cycles\n if (cyclesWithExtraPayments.length > 0) {\n uint256 index = cyclesWithExtraPayments.findUpperBound(\n cycleIndex\n );\n if (\n index < cyclesWithExtraPayments.length &&\n cyclesWithExtraPayments[index] == cycleIndex\n ) {\n extraPaymentAmount = cyclesWithExtraPaymentsAmounts[index];\n }\n }\n\n // Mark repayment amounts\n uint256 principalPayment;\n principalPayment = duePrincipal + extraPaymentAmount;\n if (principalPayment > 0) {\n __bid.loanDetails.totalRepaid.principal += principalPayment;\n // Subtract principal owed for while loop execution check\n owedPrincipal -= principalPayment;\n }\n\n __bid.loanDetails.totalRepaid.interest += interest;\n\n // Set last repaid time\n __bid.loanDetails.lastRepaidTimestamp = uint32(nowTimestamp);\n }\n Test.eq(\n cycleIndex,\n expectedTotalCycles,\n \"Expected number of cycles incorrect\"\n );\n Test.eq(\n cycleIndex <= cycleCount + 1,\n true,\n \"Payment cycle exceeded agreed terms\"\n );\n }\n\n function calculateAmountOwed_test() public {\n uint256 principal = 24486571879936808846;\n uint256 repaidPrincipal = 23410087846643631232;\n uint16 interestRate = 3000;\n __bid.loanDetails.principal = principal;\n __bid.terms.APR = interestRate;\n __bid.loanDetails.totalRepaid.principal = repaidPrincipal;\n __bid.terms.paymentCycleAmount = 8567977538702439153;\n __bid.terms.paymentCycle = 2592000;\n __bid.loanDetails.acceptedTimestamp = 1646159355;\n __bid.paymentType = PaymentType.EMI;\n\n (uint256 _owedPrincipal, uint256 _duePrincipal, uint256 _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n 1658159355, // last repaid timestamp\n 1663189241, //timestamp\n PaymentCycleType.Seconds\n );\n\n console.log(\"calc amt owed test \");\n console.log(_owedPrincipal);\n console.log(_duePrincipal);\n\n Test.eq(\n _owedPrincipal,\n 1076484033293177614,\n \"Expected number of cycles incorrect\"\n );\n Test.eq(\n _duePrincipal,\n 1076484033293177614,\n \"Expected number of cycles incorrect\"\n );\n }\n\n function calculateBulletAmountOwed_test() public {\n uint256 _principal = 100000e6;\n uint256 _repaidPrincipal = 0;\n uint16 _apr = 3000;\n uint256 _acceptedTimestamp = 1646159355;\n uint256 _lastRepaidTimestamp = _acceptedTimestamp;\n __bid.loanDetails.principal = _principal;\n __bid.terms.APR = _apr;\n __bid.loanDetails.totalRepaid.principal = _repaidPrincipal;\n __bid.terms.paymentCycleAmount = 8567977538702439153;\n __bid.terms.paymentCycle = 2592000;\n __bid.loanDetails.acceptedTimestamp = uint32(_acceptedTimestamp);\n __bid.paymentType = PaymentType.Bullet;\n uint256 _paymentCycleAmount = V2Calculations\n .calculatePaymentCycleAmount(\n PaymentType.Bullet,\n PaymentCycleType.Seconds,\n _principal,\n 365 days,\n 365 days / 12,\n _apr\n );\n __bid.terms.paymentCycleAmount = _paymentCycleAmount;\n\n // Within the first payment cycle\n uint256 _timestamp = _acceptedTimestamp + ((365 days / 12) / 2);\n\n (\n uint256 _owedPrincipal,\n uint256 _duePrincipal,\n uint256 _interest\n ) = V2Calculations.calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"First cycle bullet owed principal incorrect\"\n );\n Test.eq(_duePrincipal, 0, \"First cycle bullet due principal incorrect\");\n Test.eq(_interest, 1250000000, \"First cycle bullet interest incorrect\");\n\n // Within random payment cycle\n _timestamp = _acceptedTimestamp + ((365 days / 12) * 3);\n\n __bid.terms.paymentCycle = 365 days / 12;\n __bid.loanDetails.loanDuration = 365 days;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Second cycle bullet Owed principal incorrect\"\n );\n Test.eq(_duePrincipal, 0, \"Second cycle bullet principal incorrect\");\n Test.eq(\n _interest,\n 7500000000,\n \"Second cycle bullet interest incorrect\"\n );\n\n // Last payment cycle\n _timestamp = _acceptedTimestamp + 360 days;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Final cycle bullet Owed principal incorrect\"\n );\n Test.eq(\n _duePrincipal,\n _principal,\n \"Final cycle bullet principal incorrect\"\n );\n Test.eq(\n _interest,\n 29589041095,\n \"Final cycle bullet interest incorrect\"\n );\n\n // Beyond last payment cycle (checks for overflow protection)\n _timestamp = _acceptedTimestamp + 365 days * 2;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Final cycle bullet Owed principal incorrect\"\n );\n Test.eq(\n _duePrincipal,\n _principal,\n \"Final cycle bullet principal incorrect\"\n );\n Test.eq(\n _interest,\n ((_principal * _apr) / 10000) * 2,\n \"Final cycle bullet interest incorrect\"\n );\n }\n}\n" - }, - "hardhat/console.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >= 0.4.22 <0.9.0;\n\nlibrary console {\n\taddress constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n\tfunction _sendLogPayload(bytes memory payload) private view {\n\t\tuint256 payloadLength = payload.length;\n\t\taddress consoleAddress = CONSOLE_ADDRESS;\n\t\tassembly {\n\t\t\tlet payloadStart := add(payload, 32)\n\t\t\tlet r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n\t\t}\n\t}\n\n\tfunction log() internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log()\"));\n\t}\n\n\tfunction logInt(int256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n\t}\n\n\tfunction logUint(uint256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n\t}\n\n\tfunction logString(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction logBool(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction logAddress(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction logBytes(bytes memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n\t}\n\n\tfunction logBytes1(bytes1 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n\t}\n\n\tfunction logBytes2(bytes2 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n\t}\n\n\tfunction logBytes3(bytes3 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n\t}\n\n\tfunction logBytes4(bytes4 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n\t}\n\n\tfunction logBytes5(bytes5 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n\t}\n\n\tfunction logBytes6(bytes6 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n\t}\n\n\tfunction logBytes7(bytes7 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n\t}\n\n\tfunction logBytes8(bytes8 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n\t}\n\n\tfunction logBytes9(bytes9 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n\t}\n\n\tfunction logBytes10(bytes10 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n\t}\n\n\tfunction logBytes11(bytes11 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n\t}\n\n\tfunction logBytes12(bytes12 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n\t}\n\n\tfunction logBytes13(bytes13 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n\t}\n\n\tfunction logBytes14(bytes14 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n\t}\n\n\tfunction logBytes15(bytes15 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n\t}\n\n\tfunction logBytes16(bytes16 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n\t}\n\n\tfunction logBytes17(bytes17 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n\t}\n\n\tfunction logBytes18(bytes18 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n\t}\n\n\tfunction logBytes19(bytes19 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n\t}\n\n\tfunction logBytes20(bytes20 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n\t}\n\n\tfunction logBytes21(bytes21 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n\t}\n\n\tfunction logBytes22(bytes22 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n\t}\n\n\tfunction logBytes23(bytes23 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n\t}\n\n\tfunction logBytes24(bytes24 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n\t}\n\n\tfunction logBytes25(bytes25 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n\t}\n\n\tfunction logBytes26(bytes26 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n\t}\n\n\tfunction logBytes27(bytes27 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n\t}\n\n\tfunction logBytes28(bytes28 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n\t}\n\n\tfunction logBytes29(bytes29 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n\t}\n\n\tfunction logBytes30(bytes30 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n\t}\n\n\tfunction logBytes31(bytes31 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n\t}\n\n\tfunction logBytes32(bytes32 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n\t}\n\n\tfunction log(uint256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n\t}\n\n\tfunction log(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction log(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction log(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n\t}\n\n\tfunction log(address p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n\t}\n\n\tfunction log(address p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n\t}\n\n\tfunction log(address p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n\t}\n\n\tfunction log(address p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n}\n" - }, - "@openzeppelin/contracts/utils/Arrays.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Arrays.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./StorageSlot.sol\";\nimport \"./math/Math.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary Arrays {\n using StorageSlot for bytes32;\n\n /**\n * @dev Searches a sorted `array` and returns the first index that contains\n * a value greater or equal to `element`. If no such index exists (i.e. all\n * values in the array are strictly less than `element`), the array length is\n * returned. Time complexity O(log n).\n *\n * `array` is expected to be sorted in ascending order, and to contain no\n * repeated elements.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n if (array.length == 0) {\n return 0;\n }\n\n uint256 low = 0;\n uint256 high = array.length;\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n // because Math.average rounds down (it does integer division with truncation).\n if (unsafeAccess(array, mid).value > element) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.\n if (low > 0 && unsafeAccess(array, low - 1).value == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getAddressSlot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getBytes32Slot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getUint256Slot();\n }\n}\n" - }, - "contracts/tests/TellerV2Context_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport { Testable } from \"./Testable.sol\";\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\nimport { IMarketRegistry } from \"../interfaces/IMarketRegistry.sol\";\nimport { TellerV2MarketForwarder } from \"../TellerV2MarketForwarder.sol\";\nimport { LenderCommitmentForwarder } from \"../LenderCommitmentForwarder.sol\";\n\ncontract TellerV2Context_Test is Testable, TellerV2Context {\n uint256 private marketId;\n /*User private marketOwner;\n User private user1;\n User private user2;*/\n User private marketOwner;\n User private user1;\n\n constructor() TellerV2Context(address(0)) {}\n\n function setup_beforeAll() public {\n marketOwner = new User(TellerV2Context(this));\n\n marketRegistry = IMarketRegistry(\n address(new MockMarketRegistry(marketOwner))\n );\n\n Test.eq(\n marketRegistry.getMarketOwner(5),\n address(marketOwner),\n \"should have set marketOwner\"\n );\n }\n\n function isTrustedMarketForwarder_test() public returns (bool) {\n Test.eq(\n super.isTrustedMarketForwarder(89, lenderCommitmentForwarder),\n true,\n \"lenderCommitmentForwarder should be a trusted forwarder for all markets\"\n );\n //Test.eq(super.isTrustedMarketForwarder(1, address(0)) , false, \"by default address(0) should not be a trusted forwarder\");\n\n address stubbedMarketForwarder = address(\n 0xB11ca87E32075817C82Cc471994943a4290f4a14\n );\n Test.eq(\n super.isTrustedMarketForwarder(7, stubbedMarketForwarder),\n false,\n \"by default an address should not be a trusted forwarder\"\n );\n\n marketOwner.setTrustedMarketForwarder(7, stubbedMarketForwarder);\n\n Test.eq(\n super.isTrustedMarketForwarder(7, stubbedMarketForwarder),\n true,\n \" address should be a trusted forwarder after setting \"\n );\n }\n}\n\ncontract User {\n TellerV2Context public immutable context;\n\n constructor(TellerV2Context _context) {\n context = _context;\n }\n\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n context.setTrustedMarketForwarder(_marketId, _forwarder);\n }\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n context.approveMarketForwarder(_marketId, _forwarder);\n }\n}\n\ncontract MockMarketRegistry {\n User private immutable marketOwner;\n\n constructor(User _marketOwner) {\n marketOwner = _marketOwner;\n }\n\n function getMarketOwner(uint256) external view returns (address) {\n return address(marketOwner);\n }\n}\n" - }, - "contracts/tests/TellerV2Autopay_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2Autopay } from \"../TellerV2Autopay.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport \"../TellerV2Storage.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\n\nimport \"../mock/TellerV2SolMock.sol\";\nimport \"../mock/MarketRegistryMock.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"../interfaces/ITellerV2Autopay.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ncontract TellerV2Autopay_Test is Testable, TellerV2Autopay {\n User private marketOwner;\n User private borrower;\n User private lender;\n User private contractOwner;\n\n WethMock wethMock;\n\n address marketRegistry;\n\n constructor() TellerV2Autopay(address(new TellerV2SolMock())) {\n marketRegistry = address(new MarketRegistryMock(address(0)));\n TellerV2SolMock(address(tellerV2)).setMarketRegistry(marketRegistry);\n }\n\n function setup_beforeAll() public {\n wethMock = new WethMock();\n\n marketOwner = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n borrower = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n lender = new User(address(this), address(tellerV2), address(wethMock));\n\n contractOwner = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n\n contractOwner.initialize(5, address(contractOwner));\n }\n\n function setAutoPayEnabled_before() public {\n uint256 marketplaceId = 1;\n marketOwner.createMarketWithinRegistry(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n \"uri://\"\n );\n\n uint256 bidId = borrower.submitBid(\n address(wethMock),\n marketplaceId,\n 100,\n 4000,\n 300,\n \"ipfs://\",\n address(borrower)\n );\n }\n\n function setAutoPayEnabled_test() public {\n uint256 bidId = 0;\n\n borrower.enableAutoPay(bidId, true);\n\n Test.eq(\n loanAutoPayEnabled[bidId],\n true,\n \"Autopay not enabled after setAutoPayEnabled\"\n );\n }\n\n function setAutopayFee_test() public {\n _setAutopayFee(4);\n Test.eq(4, getAutopayFee(), \"Auto pay fee not set\");\n }\n\n function setAutopayFeeOnlyOwner_test() public {\n User user = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n try user.setAutopayFee(4) {\n Test.fail(\"Auto pay fee set by non owner\");\n } catch Error(string memory reason) {\n Test.eq(\n reason,\n \"Ownable: caller is not the owner\",\n \"Should not be able to set autopay fee\"\n );\n } catch {\n Test.fail(\"Unknown error\");\n }\n }\n\n function autoPayLoanMinimum_before() public {\n uint256 marketplaceId = 1;\n\n uint256 lenderNewBalance = 500000;\n\n payable(address(lender)).transfer(lenderNewBalance);\n\n //lender approves for acceptBid\n lender.depositToWeth(lenderNewBalance);\n lender.approveWeth(address(tellerV2), lenderNewBalance);\n\n uint256 bidId = borrower.submitBid(\n address(wethMock),\n marketplaceId,\n 1000,\n 4000,\n 300,\n \"ipfs://\",\n address(borrower)\n );\n\n borrower.enableAutoPay(bidId, true);\n\n uint256 lenderBalance = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n\n lender.acceptBid(bidId);\n\n uint256 borrowerNewBalance = 500000;\n\n payable(address(borrower)).transfer(borrowerNewBalance);\n\n //borrower approve to do repay\n borrower.depositToWeth(borrowerNewBalance);\n borrower.approveWeth(address(this), borrowerNewBalance);\n }\n\n function autoPayLoanMinimum_test() public {\n uint256 bidId = 0;\n\n uint256 lenderBalanceBefore = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n uint256 borrowerBalanceBefore = ERC20(address(wethMock)).balanceOf(\n address(borrower)\n );\n\n lender.autoPayLoanMinimum(bidId);\n\n uint256 lenderBalanceAfter = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n uint256 borrowerBalanceAfter = ERC20(address(wethMock)).balanceOf(\n address(borrower)\n );\n\n uint256 lenderBalanceDelta = lenderBalanceAfter - lenderBalanceBefore;\n\n Test.eq(\n lenderBalanceDelta,\n 2,\n \"lender did not receive the auto pay charge\"\n );\n\n uint256 borrowerBalanceDelta = borrowerBalanceBefore -\n borrowerBalanceAfter;\n\n Test.eq(borrowerBalanceDelta, 4002, \"borrower did not autopay\");\n }\n\n function getEstimatedMinimumPayment(uint256 _bidId)\n public\n override\n returns (uint256 _amount)\n {\n return 4000; //stub this for this test since there is not a good way to fast forward timestamp\n }\n}\n\ncontract User {\n address public immutable tellerV2;\n address public immutable wethMock;\n address public immutable tellerV2Autopay;\n\n constructor(address _tellerV2Autopay, address _tellerV2, address _wethMock)\n {\n tellerV2Autopay = _tellerV2Autopay;\n tellerV2 = _tellerV2;\n wethMock = _wethMock;\n }\n\n function enableAutoPay(uint256 bidId, bool enabled) public {\n ITellerV2Autopay(tellerV2Autopay).setAutoPayEnabled(bidId, enabled);\n }\n\n function createMarketWithinRegistry(\n address marketRegistry,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n string calldata _uri\n ) public {\n IMarketRegistry(marketRegistry).createMarket(\n address(this),\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n PaymentCycleType.Seconds,\n _uri\n );\n }\n\n function autoPayLoanMinimum(uint256 bidId) public {\n ITellerV2Autopay(tellerV2Autopay).autoPayLoanMinimum(bidId);\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n function initialize(uint16 _newFee, address _newOwner) public {\n ITellerV2Autopay(tellerV2Autopay).initialize(_newFee, _newOwner);\n }\n\n function setAutopayFee(uint16 _newFee) public {\n ITellerV2Autopay(tellerV2Autopay).setAutopayFee(_newFee);\n }\n\n function acceptBid(uint256 _bidId) public {\n ITellerV2(tellerV2).lenderAcceptBid(_bidId);\n }\n\n function depositToWeth(uint256 amount) public {\n IWETH(wethMock).deposit{ value: amount }();\n }\n\n function approveWeth(address to, uint256 amount) public {\n ERC20(wethMock).approve(to, amount);\n }\n\n receive() external payable {}\n}\n" - }, - "contracts/TellerV2Autopay.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/ITellerV2Autopay.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { Payment } from \"./TellerV2Storage.sol\";\n\n/**\n * @dev Helper contract to autopay loans\n */\ncontract TellerV2Autopay is OwnableUpgradeable, ITellerV2Autopay {\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n\n ITellerV2 public immutable tellerV2;\n\n //bidId => enabled\n mapping(uint256 => bool) public loanAutoPayEnabled;\n\n // Autopay fee set for automatic loan payments\n uint16 private _autopayFee;\n\n /**\n * @notice This event is emitted when a loan is autopaid.\n * @param bidId The id of the bid/loan which was repaid.\n * @param msgsender The account that called the method\n */\n event AutoPaidLoanMinimum(uint256 indexed bidId, address indexed msgsender);\n\n /**\n * @notice This event is emitted when loan autopayments are enabled or disabled.\n * @param bidId The id of the bid/loan.\n * @param enabled Whether the autopayments are enabled or disabled\n */\n event AutoPayEnabled(uint256 indexed bidId, bool enabled);\n\n /**\n * @notice This event is emitted when the autopay fee has been updated.\n * @param newFee The new autopay fee set.\n * @param oldFee The previously set autopay fee.\n */\n event AutopayFeeSet(uint16 newFee, uint16 oldFee);\n\n constructor(address _protocolAddress) {\n tellerV2 = ITellerV2(_protocolAddress);\n }\n\n /**\n * @notice Initialized the proxy.\n * @param _fee The fee collected for automatic payment processing.\n * @param _owner The address of the ownership to be transferred to.\n */\n function initialize(uint16 _fee, address _owner) external initializer {\n _transferOwnership(_owner);\n _setAutopayFee(_fee);\n }\n\n /**\n * @notice Let the owner of the contract set a new autopay fee.\n * @param _newFee The new autopay fee to set.\n */\n function setAutopayFee(uint16 _newFee) public virtual onlyOwner {\n _setAutopayFee(_newFee);\n }\n\n function _setAutopayFee(uint16 _newFee) internal {\n // Skip if the fee is the same\n if (_newFee == _autopayFee) return;\n uint16 oldFee = _autopayFee;\n _autopayFee = _newFee;\n emit AutopayFeeSet(_newFee, oldFee);\n }\n\n /**\n * @notice Returns the current autopay fee.\n */\n function getAutopayFee() public view virtual returns (uint16) {\n return _autopayFee;\n }\n\n /**\n * @notice Function for a borrower to enable or disable autopayments\n * @param _bidId The id of the bid to cancel.\n * @param _autoPayEnabled boolean for allowing autopay on a loan\n */\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external {\n require(\n _msgSender() == tellerV2.getLoanBorrower(_bidId),\n \"Only the borrower can set autopay\"\n );\n\n loanAutoPayEnabled[_bidId] = _autoPayEnabled;\n\n emit AutoPayEnabled(_bidId, _autoPayEnabled);\n }\n\n /**\n * @notice Function for a minimum autopayment to be performed on a loan\n * @param _bidId The id of the bid to repay.\n */\n function autoPayLoanMinimum(uint256 _bidId) external {\n require(\n loanAutoPayEnabled[_bidId],\n \"Autopay is not enabled for that loan\"\n );\n\n address lendingToken = ITellerV2(tellerV2).getLoanLendingToken(_bidId);\n address borrower = ITellerV2(tellerV2).getLoanBorrower(_bidId);\n\n uint256 amountToRepayMinimum = getEstimatedMinimumPayment(_bidId);\n uint256 autopayFeeAmount = amountToRepayMinimum.percent(\n getAutopayFee()\n );\n\n // Pull lendingToken in from the borrower to this smart contract\n ERC20(lendingToken).safeTransferFrom(\n borrower,\n address(this),\n amountToRepayMinimum + autopayFeeAmount\n );\n\n // Transfer fee to msg sender\n ERC20(lendingToken).safeTransfer(_msgSender(), autopayFeeAmount);\n\n // Approve the lendingToken to tellerV2\n ERC20(lendingToken).approve(address(tellerV2), amountToRepayMinimum);\n\n // Use that lendingToken to repay the loan\n tellerV2.repayLoan(_bidId, amountToRepayMinimum);\n\n emit AutoPaidLoanMinimum(_bidId, msg.sender);\n }\n\n function getEstimatedMinimumPayment(uint256 _bidId)\n public\n virtual\n returns (uint256 _amount)\n {\n Payment memory estimatedPayment = tellerV2.calculateAmountDue(_bidId);\n\n _amount = estimatedPayment.principal + estimatedPayment.interest;\n }\n}\n" - }, - "contracts/mock/TellerV2SolMock.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"../TellerV2.sol\";\nimport \"../interfaces/ITellerV2.sol\";\nimport \"../TellerV2Context.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport { LoanDetails, Payment, BidState } from \"../TellerV2Storage.sol\";\n\n/*\nThis is only used for sol test so its named specifically to avoid being used for the typescript tests.\n*/\ncontract TellerV2SolMock is ITellerV2, TellerV2Storage {\n function setMarketRegistry(address _marketRegistry) public {\n marketRegistry = IMarketRegistry(_marketRegistry);\n }\n\n function getMarketRegistry() external view returns (IMarketRegistry) {\n return marketRegistry;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketId,\n uint256 _principal,\n uint32 _duration,\n uint16,\n string calldata,\n address _receiver\n ) public returns (uint256 bidId_) {\n bidId_ = bidId;\n\n Bid storage bid = bids[bidId];\n bid.borrower = msg.sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n bidId++;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public returns (uint256 bidId_) {}\n\n function repayLoanMinimum(uint256 _bidId) external {}\n\n function repayLoanFull(uint256 _bidId) external {}\n\n function repayLoan(uint256 _bidId, uint256 _amount) public {\n Bid storage bid = bids[_bidId];\n\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n msg.sender,\n address(this),\n _amount\n );\n }\n\n /*\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n function lenderAcceptBid(uint256 _bidId)\n public\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n Bid storage bid = bids[_bidId];\n\n bid.lender = msg.sender;\n\n //send tokens to caller\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n bid.lender,\n bid.receiver,\n bid.loanDetails.principal\n );\n //for the reciever\n\n return (0, bid.loanDetails.principal, 0);\n }\n\n function getBidState(uint256 _bidId) public view returns (BidState) {\n return bids[_bidId].state;\n }\n\n function getLoanDetails(uint256 _bidId)\n public\n view\n returns (LoanDetails memory)\n {\n return bids[_bidId].loanDetails;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n public\n view\n returns (uint256[] memory)\n {}\n\n function isLoanDefaulted(uint256 _bidId) public view returns (bool) {}\n\n function isPaymentLate(uint256 _bidId) public view returns (bool) {}\n\n function getLoanBorrower(uint256 _bidId)\n external\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n function getLoanLender(uint256 _bidId)\n external\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function setLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp) public {\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n}\n" - }, - "contracts/mock/MarketRegistryMock.sol": { - "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport { PaymentType } from \"../libraries/V2Calculations.sol\";\n\ncontract MarketRegistryMock is IMarketRegistry {\n address marketOwner;\n\n constructor(address _marketOwner) {\n marketOwner = _marketOwner;\n }\n\n function initialize(TellerAS _tellerAS) external {}\n\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\n public\n view\n returns (bool isVerified_, bytes32 uuid_)\n {\n isVerified_ = true;\n }\n\n function isMarketClosed(uint256 _marketId) public view returns (bool) {\n return false;\n }\n\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\n public\n view\n returns (bool isVerified_, bytes32 uuid_)\n {\n isVerified_ = true;\n }\n\n function getMarketOwner(uint256 _marketId) public view returns (address) {\n return address(marketOwner);\n }\n\n function getMarketFeeRecipient(uint256 _marketId)\n public\n view\n returns (address)\n {\n return address(marketOwner);\n }\n\n function getMarketURI(uint256 _marketId)\n public\n view\n returns (string memory)\n {\n return \"url://\";\n }\n\n function getPaymentCycle(uint256 _marketId)\n public\n view\n returns (uint32, PaymentCycleType)\n {\n return (1000, PaymentCycleType.Seconds);\n }\n\n function getPaymentDefaultDuration(uint256 _marketId)\n public\n view\n returns (uint32)\n {\n return 1000;\n }\n\n function getBidExpirationTime(uint256 _marketId)\n public\n view\n returns (uint32)\n {\n return 1000;\n }\n\n function getMarketplaceFee(uint256 _marketId) public view returns (uint16) {\n return 1000;\n }\n\n function setMarketOwner(address _owner) public {\n marketOwner = _owner;\n }\n\n function getPaymentType(uint256 _marketId)\n public\n view\n returns (PaymentType)\n {}\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) public returns (uint256) {}\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) public returns (uint256) {}\n}\n" - }, - "contracts/interfaces/ITellerV2Autopay.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Autopay {\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external;\n\n function autoPayLoanMinimum(uint256 _bidId) external;\n\n function initialize(uint16 _newFee, address _newOwner) external;\n\n function setAutopayFee(uint16 _newFee) external;\n}\n" - }, - "contracts/tests/MarketRegistry_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"../TellerV2Storage.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\nimport \"./Test_Helpers.sol\";\n\n/*\n\nThis should have more unit tests that operate on MarketRegistry.sol \n\n*/\n\ncontract MarketRegistry_Test is Testable, TellerV2 {\n User private marketOwner;\n User private borrower;\n User private lender;\n\n WethMock wethMock;\n\n constructor() TellerV2(address(address(0))) {}\n\n function setup_beforeAll() public {\n //wethMock = new WethMock();\n\n marketOwner = new User(address(this));\n borrower = new User(address(this));\n lender = new User(address(this));\n\n lenderCommitmentForwarder = address(0);\n marketRegistry = IMarketRegistry(new MarketRegistry());\n reputationManager = IReputationManager(new ReputationManager());\n }\n\n function createMarket_test() public {\n // Standard seconds payment cycle\n marketOwner.createMarket(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n \"uri://\"\n );\n (\n uint32 paymentCycleDuration,\n PaymentCycleType paymentCycle\n ) = marketRegistry.getPaymentCycle(1);\n\n require(\n paymentCycle == PaymentCycleType.Seconds,\n \"Market payment cycle type incorrectly created\"\n );\n\n require(\n paymentCycleDuration == 8000,\n \"Market payment cycle duration set incorrectly\"\n );\n\n // Monthly payment cycle\n marketOwner.createMarket(\n address(marketRegistry),\n 0,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Monthly,\n \"uri://\"\n );\n (paymentCycleDuration, paymentCycle) = marketRegistry.getPaymentCycle(\n 2\n );\n\n require(\n paymentCycle == PaymentCycleType.Monthly,\n \"Monthly market payment cycle type incorrectly created\"\n );\n\n require(\n paymentCycleDuration == 30 days,\n \"Monthly market payment cycle duration set incorrectly\"\n );\n\n // Monthly payment cycle should fail\n bool createFailed;\n try\n marketOwner.createMarket(\n address(marketRegistry),\n 3000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Monthly,\n \"uri://\"\n )\n {} catch {\n createFailed = true;\n }\n require(createFailed, \"Monthly market should not have been created\");\n }\n}\n" - }, - "contracts/tests/LenderCommitmentForwarder_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"./resolvers/TestERC20Token.sol\";\nimport \"../TellerV2MarketForwarder.sol\";\nimport \"../TellerV2Context.sol\";\nimport { Testable } from \"./Testable.sol\";\nimport { LenderCommitmentForwarder } from \"../LenderCommitmentForwarder.sol\";\n\nimport { Collateral, CollateralType } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\n/* \n add tests for each token type \n\n add test for conversion of collateral type -- simple \n\n */\n\ncontract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder {\n LenderCommitmentForwarderTest_TellerV2Mock private tellerV2Mock;\n MarketRegistryMock mockMarketRegistry;\n\n LenderCommitmentUser private marketOwner;\n LenderCommitmentUser private lender;\n LenderCommitmentUser private borrower;\n\n // address tokenAddress;\n uint256 marketId;\n uint256 maxAmount;\n\n address[] emptyArray;\n address[] borrowersArray;\n\n uint32 maxLoanDuration;\n uint16 minInterestRate;\n uint32 expiration;\n\n bool acceptBidWasCalled;\n bool submitBidWasCalled;\n bool submitBidWithCollateralWasCalled;\n\n TestERC20Token principalToken;\n uint8 constant principalTokenDecimals = 18;\n\n TestERC20Token collateralToken;\n uint8 constant collateralTokenDecimals = 6;\n\n constructor()\n LenderCommitmentForwarder(\n address(new LenderCommitmentForwarderTest_TellerV2Mock()), ///_protocolAddress\n address(new MarketRegistryMock(address(0)))\n )\n {}\n\n function setup_beforeAll() public {\n tellerV2Mock = LenderCommitmentForwarderTest_TellerV2Mock(\n address(getTellerV2())\n );\n mockMarketRegistry = MarketRegistryMock(address(getMarketRegistry()));\n\n marketOwner = new LenderCommitmentUser(address(tellerV2Mock), (this));\n borrower = new LenderCommitmentUser(address(tellerV2Mock), (this));\n lender = new LenderCommitmentUser(address(tellerV2Mock), (this));\n tellerV2Mock.__setMarketOwner(marketOwner);\n\n mockMarketRegistry.setMarketOwner(address(marketOwner));\n\n //tokenAddress = address(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);\n marketId = 2;\n maxAmount = 100000000000000000000;\n maxLoanDuration = 2480000;\n minInterestRate = 3000;\n expiration = uint32(block.timestamp) + uint32(64000);\n\n marketOwner.setTrustedMarketForwarder(marketId, address(this));\n lender.approveMarketForwarder(marketId, address(this));\n\n borrowersArray = new address[](1);\n borrowersArray[0] = address(borrower);\n\n principalToken = new TestERC20Token(\n \"Test Wrapped ETH\",\n \"TWETH\",\n 0,\n principalTokenDecimals\n );\n\n collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n collateralTokenDecimals\n );\n\n delete acceptBidWasCalled;\n delete submitBidWasCalled;\n delete submitBidWithCollateralWasCalled;\n\n delete commitmentCount;\n }\n\n function _createCommitment(\n CommitmentCollateralType _collateralType,\n uint256 _maxPrincipalPerCollateral\n ) internal returns (Commitment storage commitment_) {\n commitment_ = commitments[0];\n commitment_.marketId = marketId;\n commitment_.principalTokenAddress = address(principalToken);\n commitment_.maxPrincipal = maxAmount;\n commitment_.maxDuration = maxLoanDuration;\n commitment_.minInterestRate = minInterestRate;\n commitment_.expiration = expiration;\n commitment_.lender = address(lender);\n\n commitment_.collateralTokenType = _collateralType;\n commitment_.maxPrincipalPerCollateralAmount =\n _maxPrincipalPerCollateral *\n 10**principalTokenDecimals;\n\n if (_collateralType == CommitmentCollateralType.ERC20) {\n commitment_.collateralTokenAddress = address(collateralToken);\n } else if (_collateralType == CommitmentCollateralType.ERC721) {\n commitment_.collateralTokenAddress = address(\n 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\n );\n } else if (_collateralType == CommitmentCollateralType.ERC1155) {\n commitment_.collateralTokenAddress = address(\n 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\n );\n }\n }\n\n function createCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage existingCommitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6 * 1e18\n );\n\n lender._createCommitment(existingCommitment, emptyArray);\n }\n\n function updateCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage existingCommitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n Test.eq(\n address(lender),\n existingCommitment.lender,\n \"Not the owner of created commitment\"\n );\n\n lender._updateCommitment(commitmentId, existingCommitment);\n }\n\n function deleteCommitment_test() public {\n uint256 commitmentId = 0;\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n Test.eq(\n commitment.lender,\n address(lender),\n \"Not the owner of created commitment\"\n );\n\n lender._deleteCommitment(commitmentId);\n\n Test.eq(\n commitment.lender,\n address(0),\n \"The commitment was not deleted\"\n );\n }\n\n function acceptCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n Test.eq(\n acceptBidWasCalled,\n false,\n \"Expect accept bid not called before exercise\"\n );\n\n uint256 bidId = borrower._acceptCommitment(\n commitmentId,\n maxAmount - 100, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n\n Test.eq(\n commitment.maxPrincipal == 100,\n true,\n \"Commitment max principal was not decremented\"\n );\n\n bidId = borrower._acceptCommitment(\n commitmentId,\n 100, //principalAmount\n 100, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(commitment.maxPrincipal == 0, true, \"commitment not accepted\");\n\n bool acceptCommitTwiceFails;\n\n try\n borrower._acceptCommitment(\n commitmentId,\n 100, //principalAmount\n 100, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n acceptCommitTwiceFails = true;\n }\n\n Test.eq(\n acceptCommitTwiceFails,\n true,\n \"Should fail when accepting commit twice\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_valid_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n uint256 bidId = borrower._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_invalid_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n bool acceptCommitAsMarketOwnerFails;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n acceptCommitAsMarketOwnerFails = true;\n }\n\n Test.eq(\n acceptCommitAsMarketOwnerFails,\n true,\n \"Should fail when accepting as invalid borrower\"\n );\n\n lender._updateCommitmentBorrowers(commitmentId, emptyArray);\n\n acceptBidWasCalled = false;\n\n marketOwner._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_reset_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n lender._updateCommitmentBorrowers(commitmentId, emptyArray);\n\n marketOwner._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentFailsWithInsufficientCollateral_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n bool failedToAcceptCommitment;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n 0, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n failedToAcceptCommitment = true;\n }\n\n Test.eq(\n failedToAcceptCommitment,\n true,\n \"Should fail to accept commitment with insufficient collateral\"\n );\n }\n\n function acceptCommitmentFailsWithInvalidAmount_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC721,\n 1000e6\n );\n\n bool failedToAcceptCommitment;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n 2, //collateralAmount\n 22, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n failedToAcceptCommitment = true;\n }\n\n Test.eq(\n failedToAcceptCommitment,\n true,\n \"Should fail to accept commitment with invalid amount for ERC721\"\n );\n }\n\n function decrementCommitment_before() public {}\n\n function decrementCommitment_test() public {\n uint256 commitmentId = 0;\n uint256 _decrementAmount = 22;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n _decrementCommitment(commitmentId, _decrementAmount);\n\n Test.eq(\n commitment.maxPrincipal == maxAmount - _decrementAmount,\n true,\n \"Commitment max principal was not decremented\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 700 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_700_USDC__500_per_WETH_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test Wrapped ETH\",\n \"TWETH\",\n 0,\n 18\n );\n Test.eq(\n super.getRequiredCollateral(\n 700 * (1e6), // 700 USDC loan\n 500 * (1e6) * (1e6), // 500 USDC loan allowed per WETH, expanded by principal token decimals\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 14e17, // 1.4 WETH\n \"expected 1.4 WETH collateral\"\n );\n }\n\n /**\n * collateral token = NFT (10**0)\n * principal token = USDC (10**6)\n * principal = 700 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_700_USDC_loan__500_per_ERC1155_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 700e6, // 700 USDC loan\n 500e6 * (10**6) * (10**0), // 500 USDC per NFT\n CommitmentCollateralType.ERC1155,\n address(0),\n address(usdcToken)\n ),\n 2, // 2 NFTs\n \"expected 2 NFTs collateral\"\n );\n }\n\n /**\n * collateral token = NFT (10**0)\n * principal token = USDC (10**6)\n * principal = 500 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_500_USDC_loan__500_per_ERC721_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 500e6, // 7500 USDC loan\n 500e6 * (1e6), // 500 USDC per NFT, expanded by principal token decimals\n CommitmentCollateralType.ERC721,\n address(0),\n address(usdcToken)\n ),\n 1, // 1 NFT\n \"expected 1 NFT collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 WETH\n * max principal per collateral = 0.00059 WETH\n */\n function getRequiredCollateral_1_WETH_loan__00059_per_USDC_test() public {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e18, // 1 WETH loan\n 59e13 * (1e18), // 0.00059 WETH per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1_694_915_255, // 1,694.915255 USDC (1694.915254237 rounded up to 6 decimals)\n \"expected 1,694.915255 USDC collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 1000 USDC $\n * max principal per collateral = 1.0 WETH\n */\n function getRequiredCollateral_1000_USDC_loan_9_gwei_per_usdc_unit_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 1000 * (1e6), // 1000 USDC loan //principal\n 1e9 * (1e6), // 1000000000 wei per USDC base unit //ratio\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 1e18, // 1 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 8888 USDC $\n * max principal per collateral = 1 gwei per USDDC base unit\n */\n function getRequiredCollateral_8888_USDC_loan__9_gwei_per_usdc_unit_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 8888 * (1e6), // 8888 USDC loan //principal\n 1e9 * (1e6), // 1000000000 wei per USDC base unit //ratio\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 8888e15, // 8.888 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**8)\n * principal = 8888 USDC\n * max principal per collateral = 8888000000 wei per USDC base unit\n */\n function getRequiredCollateral_8888_USDC_loan__unit_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 8888 * (1e6), // 8888 USDC loan //principal\n 8888000000 * (1e6), // 8888000000 wei per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 1e18, // 1 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = GWEI (10**9)\n * principal = 6 GWEI\n * max principal per collateral = 0.00059 USDC per gwei\n */\n function getRequiredCollateral_6_GWEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token gweiToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 9\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 6 gwei, // 6 GWEI loan\n 59e13 * (1e9), // 0.00059 USDC per gwei\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(gweiToken)\n ),\n 11, // 0.000011 USDC (0.000010169 rounded up to 6 decimals)\n \"expected 0.000011 USDC collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WEI (10**0)\n * principal = 1 WEI\n * max principal per collateral = // 0.00059 WETH per usdc base unit\n */\n function getRequiredCollateral_1_WEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1, // 1 WEI loan\n 59e13 * 1e18, // 0.00059 WETH per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1, // 0.001695 USDC rounded up\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 GWEI\n * max principal per collateral = 0.00059 WETH per gwei\n */\n function getRequiredCollateral_1_GWEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e9, // 1 GWEI loan\n 59e13 * 1e18, // 0.00059 WETH per USDC base unit (hence why not multiplying by 1e6)\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 2,\n \"expected at least 2 units of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 GWEI\n * max principal per collateral = 1 wei per usdc $\n */\n function getRequiredCollateral_1_wei_loan__1_Wei_per_USDC_test() public {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e9, // 1 gwei\n (1 * 1e6) * 1e18, // must provide 1:1 ratio usdc $ to wei\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1e3 * 1e6, // 1000 usdc $\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 wei\n * max principal per collateral = 1 wei per usdc $\n */\n function getRequiredCollateral_1_wei_loan__1_Wei_per_USDC_unit_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1, // 1 wei\n (1 * 1e6) * 1e18, // must provide 1 usdc to get loan of 1 wei, expanded by principal decimals\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1, // 1 usdc base unit\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /*\n Overrider methods for exercise \n */\n\n function _submitBid(CreateLoanArgs memory, address)\n internal\n override\n returns (uint256 bidId)\n {\n submitBidWasCalled = true;\n return 1;\n }\n\n function _submitBidWithCollateral(\n CreateLoanArgs memory,\n Collateral[] memory,\n address\n ) internal override returns (uint256 bidId) {\n submitBidWithCollateralWasCalled = true;\n return 1;\n }\n\n function _acceptBid(uint256, address) internal override returns (bool) {\n acceptBidWasCalled = true;\n\n Test.eq(\n submitBidWithCollateralWasCalled,\n true,\n \"Submit bid must be called before accept bid\"\n );\n\n return true;\n }\n}\n\ncontract LenderCommitmentUser is User {\n LenderCommitmentForwarder public immutable commitmentForwarder;\n\n constructor(\n address _tellerV2,\n LenderCommitmentForwarder _commitmentForwarder\n ) User(_tellerV2) {\n commitmentForwarder = _commitmentForwarder;\n }\n\n function _createCommitment(\n LenderCommitmentForwarder.Commitment calldata _commitment,\n address[] calldata borrowerAddressList\n ) public returns (uint256) {\n return\n commitmentForwarder.createCommitment(\n _commitment,\n borrowerAddressList\n );\n }\n\n function _updateCommitment(\n uint256 commitmentId,\n LenderCommitmentForwarder.Commitment calldata _commitment\n ) public {\n commitmentForwarder.updateCommitment(commitmentId, _commitment);\n }\n\n function _updateCommitmentBorrowers(\n uint256 commitmentId,\n address[] calldata borrowerAddressList\n ) public {\n commitmentForwarder.updateCommitmentBorrowers(\n commitmentId,\n borrowerAddressList\n );\n }\n\n function _acceptCommitment(\n uint256 commitmentId,\n uint256 principal,\n uint256 collateralAmount,\n uint256 collateralTokenId,\n address collateralTokenAddress,\n uint16 interestRate,\n uint32 loanDuration\n ) public returns (uint256) {\n return\n commitmentForwarder.acceptCommitment(\n commitmentId,\n principal,\n collateralAmount,\n collateralTokenId,\n collateralTokenAddress,\n interestRate,\n loanDuration\n );\n }\n\n function _deleteCommitment(uint256 _commitmentId) public {\n commitmentForwarder.deleteCommitment(_commitmentId);\n }\n}\n\n//Move to a helper file !\ncontract LenderCommitmentForwarderTest_TellerV2Mock is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "contracts/tests/MarketForwarder_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport { Testable } from \"./Testable.sol\";\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\nimport { IMarketRegistry } from \"../interfaces/IMarketRegistry.sol\";\nimport { TellerV2MarketForwarder } from \"../TellerV2MarketForwarder.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\ncontract MarketForwarder_Test is Testable, TellerV2MarketForwarder {\n MarketForwarderTester private tellerV2Mock;\n\n MarketRegistryMock mockMarketRegistry;\n\n uint256 private marketId;\n MarketForwarderUser private marketOwner;\n MarketForwarderUser private user1;\n MarketForwarderUser private user2;\n\n constructor()\n TellerV2MarketForwarder(\n address(new MarketForwarderTester()),\n address(new MarketRegistryMock(address(0)))\n )\n {}\n\n function setup_beforeAll() public {\n mockMarketRegistry = MarketRegistryMock(address(getMarketRegistry()));\n tellerV2Mock = MarketForwarderTester(address(getTellerV2()));\n\n marketOwner = new MarketForwarderUser(address(tellerV2Mock));\n user1 = new MarketForwarderUser(address(tellerV2Mock));\n user2 = new MarketForwarderUser(address(tellerV2Mock));\n\n tellerV2Mock.__setMarketOwner(marketOwner);\n\n mockMarketRegistry.setMarketOwner(address(marketOwner));\n\n delete marketId;\n }\n\n function setTrustedMarketForwarder_before() public {\n marketOwner.setTrustedMarketForwarder(marketId, address(this));\n }\n\n function setTrustedMarketForwarder_test() public {\n Test.eq(\n tellerV2Mock.isTrustedMarketForwarder(marketId, address(this)),\n true,\n \"Trusted forwarder was not set\"\n );\n }\n\n function approveMarketForwarder_before() public {\n setTrustedMarketForwarder_before();\n\n user1.approveMarketForwarder(marketId, address(this));\n user2.approveMarketForwarder(marketId, address(this));\n }\n\n function approveMarketForwarder_test() public {\n Test.eq(\n tellerV2Mock.hasApprovedMarketForwarder(\n marketId,\n address(this),\n address(user1)\n ),\n true,\n \"Borrower did not set market forwarder approval\"\n );\n Test.eq(\n tellerV2Mock.hasApprovedMarketForwarder(\n marketId,\n address(this),\n address(user2)\n ),\n true,\n \"Lender did not set market forwarder approval\"\n );\n }\n\n function forwardUserCall_before() public {\n approveMarketForwarder_before();\n }\n\n function forwardUserCall_test() public {\n address expectedSender = address(user1);\n address sender = abi.decode(\n _forwardCall(\n abi.encodeWithSelector(\n MarketForwarderTester.getSenderForMarket.selector,\n marketId\n ),\n expectedSender\n ),\n (address)\n );\n Test.eq(\n sender,\n expectedSender,\n \"Sender address for market does not match expected\"\n );\n\n bytes memory expectedData = abi.encodeWithSelector(\n MarketForwarderTester.getDataForMarket.selector,\n marketId\n );\n bytes memory data = abi.decode(\n _forwardCall(expectedData, expectedSender),\n (bytes)\n );\n Test.eq0(\n data,\n expectedData,\n \"Function calldata for market does not match expected\"\n );\n }\n}\n\n//This should use the user helper !!\ncontract MarketForwarderUser is User {\n constructor(address _tellerV2) User(_tellerV2) {}\n}\n\n//Move to a helper\n//this is a tellerV2 mock\ncontract MarketForwarderTester is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "contracts/tests/LenderManager_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\nimport \"../TellerV2MarketForwarder.sol\";\nimport { Testable } from \"./Testable.sol\";\nimport { LenderManager } from \"../LenderManager.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\n\ncontract LenderManager_Test is Testable, LenderManager {\n LenderManagerUser private marketOwner;\n LenderManagerUser private lender;\n LenderManagerUser private borrower;\n\n LenderCommitmentTester mockTellerV2;\n MarketRegistryMock mockMarketRegistry;\n\n bool mockedHasMarketVerification;\n\n constructor()\n LenderManager(\n //address(0),\n new MarketRegistryMock(address(0))\n )\n {}\n\n function setup_beforeAll() public {\n mockTellerV2 = new LenderCommitmentTester();\n\n marketOwner = new LenderManagerUser(\n address(mockTellerV2),\n address(this)\n );\n borrower = new LenderManagerUser(address(mockTellerV2), address(this));\n lender = new LenderManagerUser(address(mockTellerV2), address(this));\n\n mockMarketRegistry = new MarketRegistryMock(address(marketOwner));\n\n delete mockedHasMarketVerification;\n }\n\n function registerLoan_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n\n super.registerLoan(bidId, address(lender));\n\n Test.eq(\n super._exists(bidId),\n true,\n \"Loan registration did not mint nft\"\n );\n }\n\n function transferFrom_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n\n super._mint(address(lender), bidId);\n\n lender.transferLoan(bidId, address(borrower));\n\n Test.eq(\n super.ownerOf(bidId),\n address(borrower),\n \"Loan nft was not transferred\"\n );\n }\n\n function transferFromToInvalidRecipient_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n super._mint(address(lender), bidId);\n\n mockedHasMarketVerification = false;\n\n bool transferFailed;\n\n //I want to expect this to fail !!\n try lender.transferLoan(bidId, address(address(borrower))) {} catch {\n transferFailed = true;\n }\n\n Test.eq(transferFailed, true, \"Loan transfer should have failed\");\n\n Test.eq(\n super.ownerOf(bidId),\n address(lender),\n \"Loan nft is no longer owned by lender\"\n );\n }\n\n //override\n function _hasMarketVerification(address _lender, uint256 _bidId)\n internal\n view\n override\n returns (bool)\n {\n return mockedHasMarketVerification;\n }\n\n //should be able to test the negative case-- use foundry\n function _checkOwner() internal view override {\n // do nothing\n }\n}\n\ncontract LenderManagerUser is User {\n address lenderManager;\n\n constructor(address _tellerV2, address _lenderManager) User(_tellerV2) {\n lenderManager = _lenderManager;\n }\n\n function transferLoan(uint256 bidId, address to) public {\n IERC721(lenderManager).transferFrom(address(this), to, bidId);\n }\n}\n\n//Move to a helper or change it\ncontract LenderCommitmentTester is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "contracts/tests/PMT_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract PMT_Test is Testable, TellerV2 {\n Bid __bid;\n\n constructor() TellerV2(address(0)) {}\n\n function _01_pmt_test() public {\n __bid.loanDetails.principal = 10000e6; // 10k USDC\n __bid.loanDetails.loanDuration = 365 days * 3; // 3 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 300; // 3.0%\n pmt_runner(290812096, 365 days);\n }\n\n function _02_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 365 days * 10; // 10 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 800; // 8.0%\n pmt_runner(1213275944, 365 days);\n }\n\n function _03_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 365 days * 10; // 10 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 0; // 0.0%\n pmt_runner(833333334, 365 days);\n }\n\n function _04_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 45 days; // 45 days\n __bid.terms.paymentCycle = 30 days; // 1 month\n __bid.terms.APR = 600; // 6.0%\n pmt_runner(50370166243, 365 days);\n }\n\n function pmt_runner(uint256 _expected, uint256 _daysInYear) private {\n uint256 pmt = NumbersLib.pmt(\n __bid.loanDetails.principal,\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle,\n __bid.terms.APR,\n _daysInYear\n );\n Test.eq(pmt, _expected, \"Loan payment for cycle incorrect\");\n }\n}\n" - }, - "contracts/tests/NextDueDate_test.sol": { - "content": "pragma solidity ^0.8.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract NextDueDate_Test is Testable, TellerV2 {\n Bid __bid;\n\n constructor() TellerV2(address(0)) {\n __bid.loanDetails.principal = 10000e6; // 10k USDC\n __bid.loanDetails.loanDuration = 365 days * 2; // 2 years\n __bid.terms.paymentCycle = 30 days; // 1 month\n __bid.terms.APR = 450; // 4.5%\n __bid.state = BidState.ACCEPTED;\n }\n\n function _01_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2020, 1, 31) // Leap year\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is Feb 29th\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2020, 2, 29));\n nextDueDate_runner(expectedDate);\n }\n\n function _02_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2020, 2, 29)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 29th\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2020, 3, 29));\n nextDueDate_runner(expectedDate);\n }\n\n function _03_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 2, 1)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 1st\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2023, 3, 1));\n nextDueDate_runner(expectedDate);\n }\n\n function _04_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 1, 31)\n );\n __bid.loanDetails.lastRepaidTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 2, 1)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 31st\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2023, 3, 31));\n nextDueDate_runner(expectedDate);\n }\n\n function nextDueDate_runner(uint256 _expected) private {\n uint256 nextDueDate = calculateNextDueDate(1);\n Test.eq(nextDueDate, _expected, \"Next due date incorrect\");\n }\n}\n" - }, - "contracts/tests/GetMetaDataURI_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract GetMetaDataURI_Test is Testable, TellerV2 {\n constructor() TellerV2(address(0)) {}\n\n function setup_beforeAll() public {\n // Old depreciated _metadataURI on bid struct\n bids[0]\n ._metadataURI = 0x0000000000000000000000000000000086004f3f419f88be1cab574b4bd01b6d;\n // New metadataURI from uris mapping\n uris[59] = \"ipfs://QmMyDataHash\";\n }\n\n function getMetaDataURI_test() public {\n string memory oldURI = getMetadataURI(0);\n Test.eq(\n oldURI,\n \"0x0000000000000000000000000000000086004f3f419f88be1cab574b4bd01b6d\",\n \"Expected URI does not match stored depreciated value in the Bid struct\"\n );\n string memory newURI = getMetadataURI(59);\n Test.eq(\n newURI,\n \"ipfs://QmMyDataHash\",\n \"Expected URI does not match new value in uri mapping\"\n );\n }\n}\n" - }, - "contracts/TellerV2Mock.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2.sol\";\n\ncontract TellerV2Mock is TellerV2 {\n constructor(address trustedForwarder) TellerV2(trustedForwarder) {}\n\n function mockBid(Bid calldata _bid) external {\n bids[bidId] = _bid;\n borrowerBids[_msgSender()].push(bidId);\n bidId++;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId, uint32 _timestamp) external {\n require(_timestamp > 0, \"Accepted timestamp 0\");\n bids[_bidId].loanDetails.acceptedTimestamp = _timestamp;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId) external {\n bids[_bidId].loanDetails.acceptedTimestamp = uint32(block.timestamp);\n }\n\n function mockLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp)\n external\n {\n require(_timestamp > 0, \"Repaid timestamp 0\");\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n\n function setVersion(uint256 _version) public {\n version = _version;\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/packages/contracts/deployments/goerli/solcInputs/556fedad003f0c0b44fba88774cf2ef3.json b/packages/contracts/deployments/goerli/solcInputs/556fedad003f0c0b44fba88774cf2ef3.json deleted file mode 100644 index 3510fd3c3..000000000 --- a/packages/contracts/deployments/goerli/solcInputs/556fedad003f0c0b44fba88774cf2ef3.json +++ /dev/null @@ -1,425 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/CollateralManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n// Interfaces\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\";\nimport \"./interfaces/ICollateralManager.sol\";\nimport { Collateral, CollateralType, ICollateralEscrowV1 } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\nimport \"./interfaces/ITellerV2.sol\";\n\ncontract CollateralManager is OwnableUpgradeable, ICollateralManager {\n /* Storage */\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n ITellerV2 public tellerV2;\n address private collateralEscrowBeacon; // The address of the escrow contract beacon\n mapping(uint256 => address) public _escrows; // bidIds -> collateralEscrow\n // bidIds -> validated collateral info\n mapping(uint256 => CollateralInfo) internal _bidCollaterals;\n struct CollateralInfo {\n EnumerableSetUpgradeable.AddressSet collateralAddresses;\n mapping(address => Collateral) collateralInfo;\n }\n\n /* Events */\n event CollateralEscrowDeployed(uint256 _bidId, address _collateralEscrow);\n event CollateralCommitted(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n );\n event CollateralClaimed(uint256 _bidId);\n event CollateralDeposited(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n );\n event CollateralWithdrawn(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId,\n address _recipient\n );\n\n /* Modifiers */\n modifier onlyTellerV2() {\n require(_msgSender() == address(tellerV2), \"Sender not authorized\");\n _;\n }\n\n /* External Functions */\n\n /**\n * @notice Initializes the collateral manager.\n * @param _collateralEscrowBeacon The address of the escrow implementation.\n * @param _tellerV2 The address of the protocol.\n */\n function initialize(address _collateralEscrowBeacon, address _tellerV2)\n external\n initializer\n {\n collateralEscrowBeacon = _collateralEscrowBeacon;\n tellerV2 = ITellerV2(_tellerV2);\n __Ownable_init_unchained();\n }\n\n /**\n * @notice Sets the address of the Beacon contract used for the collateral escrow contracts.\n * @param _collateralEscrowBeacon The address of the Beacon contract.\n */\n function setCollateralEscrowBeacon(address _collateralEscrowBeacon)\n external\n reinitializer(2)\n {\n collateralEscrowBeacon = _collateralEscrowBeacon;\n }\n\n /**\n * @notice Checks to see if a bid is backed by collateral.\n * @param _bidId The id of the bid to check.\n */\n\n function isBidCollateralBacked(uint256 _bidId) public returns (bool) {\n return _bidCollaterals[_bidId].collateralAddresses.length() > 0;\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral assets.\n * @return validation_ Boolean indicating if the collateral balances were validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral[] calldata _collateralInfo\n ) public returns (bool validation_) {\n address borrower = tellerV2.getLoanBorrower(_bidId);\n (validation_, ) = checkBalances(borrower, _collateralInfo);\n if (validation_) {\n for (uint256 i; i < _collateralInfo.length; i++) {\n Collateral memory info = _collateralInfo[i];\n _commitCollateral(_bidId, info);\n }\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral calldata _collateralInfo\n ) public returns (bool validation_) {\n address borrower = tellerV2.getLoanBorrower(_bidId);\n validation_ = _checkBalance(borrower, _collateralInfo);\n if (validation_) {\n _commitCollateral(_bidId, _collateralInfo);\n }\n }\n\n /**\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\n * @param _bidId The id of the associated bid.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function revalidateCollateral(uint256 _bidId)\n external\n returns (bool validation_)\n {\n Collateral[] memory collateralInfos = getCollateralInfo(_bidId);\n address borrower = tellerV2.getLoanBorrower(_bidId);\n (validation_, ) = _checkBalances(borrower, collateralInfos, true);\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral assets.\n */\n function checkBalances(\n address _borrowerAddress,\n Collateral[] calldata _collateralInfo\n ) public returns (bool validated_, bool[] memory checks_) {\n return _checkBalances(_borrowerAddress, _collateralInfo, false);\n }\n\n /**\n * @notice Deploys a new collateral escrow and deposits collateral.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function deployAndDeposit(uint256 _bidId) external onlyTellerV2 {\n if (isBidCollateralBacked(_bidId)) {\n (address proxyAddress, ) = _deployEscrow(_bidId);\n _escrows[_bidId] = proxyAddress;\n\n for (\n uint256 i;\n i < _bidCollaterals[_bidId].collateralAddresses.length();\n i++\n ) {\n _deposit(\n _bidId,\n _bidCollaterals[_bidId].collateralInfo[\n _bidCollaterals[_bidId].collateralAddresses.at(i)\n ]\n );\n }\n\n emit CollateralEscrowDeployed(_bidId, proxyAddress);\n }\n }\n\n /**\n * @notice Gets the address of a deployed escrow.\n * @notice _bidId The bidId to return the escrow for.\n * @return The address of the escrow.\n */\n function getEscrow(uint256 _bidId) external view returns (address) {\n return _escrows[_bidId];\n }\n\n /**\n * @notice Gets the collateral info for a given bid id.\n * @param _bidId The bidId to return the collateral info for.\n * @return infos_ The stored collateral info.\n */\n function getCollateralInfo(uint256 _bidId)\n public\n view\n returns (Collateral[] memory infos_)\n {\n CollateralInfo storage collateral = _bidCollaterals[_bidId];\n address[] memory collateralAddresses = collateral\n .collateralAddresses\n .values();\n infos_ = new Collateral[](collateralAddresses.length);\n for (uint256 i; i < collateralAddresses.length; i++) {\n infos_[i] = collateral.collateralInfo[collateralAddresses[i]];\n }\n }\n\n /**\n * @notice Withdraws deposited collateral from the created escrow of a bid that has been successfully repaid.\n * @param _bidId The id of the bid to withdraw collateral for.\n */\n function withdraw(uint256 _bidId) external {\n BidState bidState = tellerV2.getBidState(_bidId);\n if (bidState == BidState.PAID) {\n _withdraw(_bidId, tellerV2.getLoanBorrower(_bidId));\n } else if (tellerV2.isLoanDefaulted(_bidId)) {\n _withdraw(_bidId, tellerV2.getLoanLender(_bidId));\n emit CollateralClaimed(_bidId);\n } else {\n revert(\"collateral cannot be withdrawn\");\n }\n }\n\n /**\n * @notice Sends the deposited collateral to a liquidator of a bid.\n * @notice Can only be called by the protocol.\n * @param _bidId The id of the liquidated bid.\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\n */\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\n external\n onlyTellerV2\n {\n if (isBidCollateralBacked(_bidId)) {\n BidState bidState = tellerV2.getBidState(_bidId);\n require(\n bidState == BidState.LIQUIDATED,\n \"Loan has not been liquidated\"\n );\n _withdraw(_bidId, _liquidatorAddress);\n }\n }\n\n /* Internal Functions */\n\n /**\n * @notice Deploys a new collateral escrow.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function _deployEscrow(uint256 _bidId)\n internal\n returns (address proxyAddress_, address borrower_)\n {\n proxyAddress_ = _escrows[_bidId];\n // Get bid info\n borrower_ = tellerV2.getLoanBorrower(_bidId);\n if (proxyAddress_ == address(0)) {\n require(borrower_ != address(0), \"Bid does not exist\");\n\n BeaconProxy proxy = new BeaconProxy(\n collateralEscrowBeacon,\n abi.encodeWithSelector(\n ICollateralEscrowV1.initialize.selector,\n _bidId\n )\n );\n proxyAddress_ = address(proxy);\n }\n }\n\n function _deposit(uint256 _bidId, Collateral memory collateralInfo)\n public\n payable\n {\n require(collateralInfo._amount > 0, \"Collateral not validated\");\n (address escrowAddress, address borrower) = _deployEscrow(_bidId);\n ICollateralEscrowV1 collateralEscrow = ICollateralEscrowV1(\n escrowAddress\n );\n // Pull collateral from borrower & deposit into escrow\n if (collateralInfo._collateralType == CollateralType.ERC20) {\n IERC20Upgradeable(collateralInfo._collateralAddress).transferFrom(\n borrower,\n address(this),\n collateralInfo._amount\n );\n IERC20Upgradeable(collateralInfo._collateralAddress).approve(\n escrowAddress,\n collateralInfo._amount\n );\n collateralEscrow.depositToken(\n collateralInfo._collateralAddress,\n collateralInfo._amount\n );\n } else if (collateralInfo._collateralType == CollateralType.ERC721) {\n IERC721Upgradeable(collateralInfo._collateralAddress).transferFrom(\n borrower,\n address(this),\n collateralInfo._tokenId\n );\n IERC721Upgradeable(collateralInfo._collateralAddress).approve(\n escrowAddress,\n collateralInfo._tokenId\n );\n collateralEscrow.depositAsset(\n CollateralType.ERC721,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n } else if (collateralInfo._collateralType == CollateralType.ERC1155) {\n bytes memory data;\n IERC1155Upgradeable(collateralInfo._collateralAddress)\n .safeTransferFrom(\n borrower,\n address(this),\n collateralInfo._tokenId,\n collateralInfo._amount,\n data\n );\n IERC1155Upgradeable(collateralInfo._collateralAddress)\n .setApprovalForAll(escrowAddress, true);\n collateralEscrow.depositAsset(\n CollateralType.ERC1155,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n }\n emit CollateralDeposited(\n _bidId,\n collateralInfo._collateralType,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n }\n\n /**\n * @notice Withdraws collateral to a given receiver's address.\n * @param _bidId The id of the bid to withdraw collateral for.\n * @param _receiver The address to withdraw the collateral to.\n */\n function _withdraw(uint256 _bidId, address _receiver) internal {\n for (\n uint256 i;\n i < _bidCollaterals[_bidId].collateralAddresses.length();\n i++\n ) {\n // Get collateral info\n Collateral storage collateralInfo = _bidCollaterals[_bidId]\n .collateralInfo[\n _bidCollaterals[_bidId].collateralAddresses.at(i)\n ];\n // Withdraw collateral from escrow and send it to bid lender\n ICollateralEscrowV1(_escrows[_bidId]).withdraw(\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n _receiver\n );\n emit CollateralWithdrawn(\n _bidId,\n collateralInfo._collateralType,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId,\n _receiver\n );\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function _commitCollateral(\n uint256 _bidId,\n Collateral memory _collateralInfo\n ) internal {\n CollateralInfo storage collateral = _bidCollaterals[_bidId];\n collateral.collateralAddresses.add(_collateralInfo._collateralAddress);\n collateral.collateralInfo[\n _collateralInfo._collateralAddress\n ] = _collateralInfo;\n emit CollateralCommitted(\n _bidId,\n _collateralInfo._collateralType,\n _collateralInfo._collateralAddress,\n _collateralInfo._amount,\n _collateralInfo._tokenId\n );\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral assets.\n */\n function _checkBalances(\n address _borrowerAddress,\n Collateral[] memory _collateralInfo,\n bool _shortCircut\n ) internal returns (bool validated_, bool[] memory checks_) {\n checks_ = new bool[](_collateralInfo.length);\n validated_ = true;\n for (uint256 i; i < _collateralInfo.length; i++) {\n bool isValidated = _checkBalance(\n _borrowerAddress,\n _collateralInfo[i]\n );\n checks_[i] = isValidated;\n if (!isValidated) {\n validated_ = false;\n if (_shortCircut) {\n return (validated_, checks_);\n }\n }\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's single collateral balance.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balances were validated.\n */\n function _checkBalance(\n address _borrowerAddress,\n Collateral memory _collateralInfo\n ) internal returns (bool) {\n CollateralType collateralType = _collateralInfo._collateralType;\n if (collateralType == CollateralType.ERC20) {\n return\n _collateralInfo._amount <=\n IERC20Upgradeable(_collateralInfo._collateralAddress).balanceOf(\n _borrowerAddress\n );\n }\n if (collateralType == CollateralType.ERC721) {\n return\n _borrowerAddress ==\n IERC721Upgradeable(_collateralInfo._collateralAddress).ownerOf(\n _collateralInfo._tokenId\n );\n }\n if (collateralType == CollateralType.ERC1155) {\n return\n _collateralInfo._amount <=\n IERC1155Upgradeable(_collateralInfo._collateralAddress)\n .balanceOf(_borrowerAddress, _collateralInfo._tokenId);\n }\n return false;\n }\n\n // On NFT Received handlers\n\n function onERC721Received(address, address, uint256, bytes calldata)\n external\n pure\n returns (bytes4)\n {\n return\n bytes4(\n keccak256(\"onERC721Received(address,address,uint256,bytes)\")\n );\n }\n\n function onERC1155Received(\n address,\n address,\n uint256 id,\n uint256 value,\n bytes calldata\n ) external returns (bytes4) {\n return\n bytes4(\n keccak256(\n \"onERC1155Received(address,address,uint256,uint256,bytes)\"\n )\n );\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata _ids,\n uint256[] calldata _values,\n bytes calldata\n ) external returns (bytes4) {\n require(\n _ids.length == 1,\n \"Only allowed one asset batch transfer per transaction.\"\n );\n return\n bytes4(\n keccak256(\n \"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"\n )\n );\n }\n}\n" - }, - "contracts/interfaces/ICollateralManager.sol": { - "content": "// SPDX-Licence-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nimport { Collateral } from \"./escrow/ICollateralEscrowV1.sol\";\n\ninterface ICollateralManager {\n /**\n * @notice Checks the validity of a borrower's collateral balance.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validation_);\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral calldata _collateralInfo\n ) external returns (bool validation_);\n\n function checkBalances(\n address _borrowerAddress,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validated_, bool[] memory checks_);\n\n /**\n * @notice Deploys a new collateral escrow.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function deployAndDeposit(uint256 _bidId) external;\n\n /**\n * @notice Gets the address of a deployed escrow.\n * @notice _bidId The bidId to return the escrow for.\n * @return The address of the escrow.\n */\n function getEscrow(uint256 _bidId) external view returns (address);\n\n /**\n * @notice Gets the collateral info for a given bid id.\n * @param _bidId The bidId to return the collateral info for.\n * @return The stored collateral info.\n */\n function getCollateralInfo(uint256 _bidId)\n external\n view\n returns (Collateral[] memory);\n\n /**\n * @notice Withdraws deposited collateral from the created escrow of a bid.\n * @param _bidId The id of the bid to withdraw collateral for.\n */\n function withdraw(uint256 _bidId) external;\n\n /**\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\n * @param _bidId The id of the associated bid.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function revalidateCollateral(uint256 _bidId) external returns (bool);\n\n /**\n * @notice Sends the deposited collateral to a liquidator of a bid.\n * @notice Can only be called by the protocol.\n * @param _bidId The id of the liquidated bid.\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\n */\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\n external;\n}\n" - }, - "contracts/interfaces/escrow/ICollateralEscrowV1.sol": { - "content": "// SPDX-Licence-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nenum CollateralType {\n ERC20,\n ERC721,\n ERC1155\n}\n\nstruct Collateral {\n CollateralType _collateralType;\n uint256 _amount;\n uint256 _tokenId;\n address _collateralAddress;\n}\n\ninterface ICollateralEscrowV1 {\n /**\n * @notice Deposits a collateral ERC20 token into the escrow.\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositToken(address _collateralAddress, uint256 _amount) external;\n\n /**\n * @notice Deposits a collateral asset into the escrow.\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositAsset(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) external payable;\n\n /**\n * @notice Withdraws a collateral asset from the escrow.\n * @param _collateralAddress The address of the collateral contract.\n * @param _amount The amount to withdraw.\n * @param _recipient The address to send the assets to.\n */\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) external;\n\n function getBid() external view returns (uint256);\n\n function initialize(uint256 _bidId) external;\n}\n" - }, - "contracts/interfaces/ITellerV2.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Payment, BidState } from \"../TellerV2Storage.sol\";\nimport { Collateral } from \"./escrow/ICollateralEscrowV1.sol\";\n\ninterface ITellerV2 {\n /**\n * @notice Function for a borrower to create a bid for a loan.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) external returns (uint256 bidId_);\n\n /**\n * @notice Function for a borrower to create a bid for a loan with Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) external returns (uint256 bidId_);\n\n /**\n * @notice Function for a lender to accept a proposed loan bid.\n * @param _bidId The id of the loan bid to accept.\n */\n function lenderAcceptBid(uint256 _bidId)\n external\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n );\n\n function calculateAmountDue(uint256 _bidId)\n external\n view\n returns (Payment memory due);\n\n /**\n * @notice Function for users to make the minimum amount due for an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanMinimum(uint256 _bidId) external;\n\n /**\n * @notice Function for users to repay an active loan in full.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanFull(uint256 _bidId) external;\n\n /**\n * @notice Function for users to make a payment towards an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _amount The amount of the payment.\n */\n function repayLoan(uint256 _bidId, uint256 _amount) external;\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isPaymentLate(uint256 _bidId) external view returns (bool);\n\n function getBidState(uint256 _bidId) external view returns (BidState);\n\n function getBorrowerActiveLoanIds(address _borrower)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @notice Returns the borrower address for a given bid.\n * @param _bidId The id of the bid/loan to get the borrower for.\n * @return borrower_ The address of the borrower associated with the bid.\n */\n function getLoanBorrower(uint256 _bidId)\n external\n view\n returns (address borrower_);\n\n /**\n * @notice Returns the lender address for a given bid.\n * @param _bidId The id of the bid/loan to get the lender for.\n * @return lender_ The address of the lender associated with the bid.\n */\n function getLoanLender(uint256 _bidId)\n external\n view\n returns (address lender_);\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_);\n\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^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 *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSetUpgradeable {\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 // 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) {\n // 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 if (lastIndex != toDeleteIndex) {\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] = valueIndex; // Replace lastValue's index to valueIndex\n }\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 return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 in 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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n" - }, - "contracts/TellerV2Storage.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport { IMarketRegistry } from \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/IReputationManager.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./interfaces/ICollateralManager.sol\";\nimport { PaymentType, PaymentCycleType } from \"./libraries/V2Calculations.sol\";\nimport \"./interfaces/ILenderManager.sol\";\n\nenum BidState {\n NONEXISTENT,\n PENDING,\n CANCELLED,\n ACCEPTED,\n PAID,\n LIQUIDATED\n}\n\n/**\n * @notice Represents a total amount for a payment.\n * @param principal Amount that counts towards the principal.\n * @param interest Amount that counts toward interest.\n */\nstruct Payment {\n uint256 principal;\n uint256 interest;\n}\n\n/**\n * @notice Details about a loan request.\n * @param borrower Account address who is requesting a loan.\n * @param receiver Account address who will receive the loan amount.\n * @param lender Account address who accepted and funded the loan request.\n * @param marketplaceId ID of the marketplace the bid was submitted to.\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\n * @param loanDetails Struct of the specific loan details.\n * @param terms Struct of the loan request terms.\n * @param state Represents the current state of the loan.\n */\nstruct Bid {\n address borrower;\n address receiver;\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\n uint256 marketplaceId;\n bytes32 _metadataURI; // DEPRECATED\n LoanDetails loanDetails;\n Terms terms;\n BidState state;\n PaymentType paymentType;\n}\n\n/**\n * @notice Details about the loan.\n * @param lendingToken The token address for the loan.\n * @param principal The amount of tokens initially lent out.\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\n * @param loanDuration The duration of the loan.\n */\nstruct LoanDetails {\n ERC20 lendingToken;\n uint256 principal;\n Payment totalRepaid;\n uint32 timestamp;\n uint32 acceptedTimestamp;\n uint32 lastRepaidTimestamp;\n uint32 loanDuration;\n}\n\n/**\n * @notice Information on the terms of a loan request\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\n */\nstruct Terms {\n uint256 paymentCycleAmount;\n uint32 paymentCycle;\n uint16 APR;\n}\n\nabstract contract TellerV2Storage_G0 {\n /** Storage Variables */\n\n // Current number of bids.\n uint256 public bidId = 0;\n\n // Mapping of bidId to bid information.\n mapping(uint256 => Bid) public bids;\n\n // Mapping of borrowers to borrower requests.\n mapping(address => uint256[]) public borrowerBids;\n\n // Mapping of volume filled by lenders.\n mapping(address => uint256) public _lenderVolumeFilled; // DEPRECIATED\n\n // Volume filled by all lenders.\n uint256 public _totalVolumeFilled; // DEPRECIATED\n\n // List of allowed lending tokens\n EnumerableSet.AddressSet internal lendingTokensSet;\n\n IMarketRegistry public marketRegistry;\n IReputationManager public reputationManager;\n\n // Mapping of borrowers to borrower requests.\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\n\n mapping(uint256 => uint32) public bidDefaultDuration;\n mapping(uint256 => uint32) public bidExpirationTime;\n\n // Mapping of volume filled by lenders.\n // Asset address => Lender address => Volume amount\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\n\n // Volume filled by all lenders.\n // Asset address => Volume amount\n mapping(address => uint256) public totalVolumeFilled;\n\n uint256 public version;\n\n // Mapping of metadataURIs by bidIds.\n // Bid Id => metadataURI string\n mapping(uint256 => string) public uris;\n}\n\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\n // market ID => trusted forwarder\n mapping(uint256 => address) internal _trustedMarketForwarders;\n // trusted forwarder => set of pre-approved senders\n mapping(address => EnumerableSet.AddressSet)\n internal _approvedForwarderSenders;\n}\n\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\n address public lenderCommitmentForwarder;\n}\n\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\n ICollateralManager public collateralManager;\n}\n\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\n // Address of the lender manager contract\n ILenderManager public lenderManager;\n // BidId to payment cycle type (custom or monthly)\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\n}\n\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\n" - }, - "contracts/interfaces/IMarketRegistry.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../EAS/TellerAS.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ninterface IMarketRegistry {\n function initialize(TellerAS tellerAs) external;\n\n function isVerifiedLender(uint256 _marketId, address _lender)\n external\n view\n returns (bool, bytes32);\n\n function isMarketClosed(uint256 _marketId) external view returns (bool);\n\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\n external\n view\n returns (bool, bytes32);\n\n function getMarketOwner(uint256 _marketId) external view returns (address);\n\n function getMarketFeeRecipient(uint256 _marketId)\n external\n view\n returns (address);\n\n function getMarketURI(uint256 _marketId)\n external\n view\n returns (string memory);\n\n function getPaymentCycle(uint256 _marketId)\n external\n view\n returns (uint32, PaymentCycleType);\n\n function getPaymentDefaultDuration(uint256 _marketId)\n external\n view\n returns (uint32);\n\n function getBidExpirationTime(uint256 _marketId)\n external\n view\n returns (uint32);\n\n function getMarketplaceFee(uint256 _marketId)\n external\n view\n returns (uint16);\n\n function getPaymentType(uint256 _marketId)\n external\n view\n returns (PaymentType);\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) external returns (uint256 marketId_);\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) external returns (uint256 marketId_);\n}\n" - }, - "contracts/interfaces/IReputationManager.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum RepMark {\n Good,\n Delinquent,\n Default\n}\n\ninterface IReputationManager {\n function initialize(address protocolAddress) external;\n\n function getDelinquentLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getDefaultedLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getCurrentDelinquentLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getCurrentDefaultLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function updateAccountReputation(address _account) external;\n\n function updateAccountReputation(address _account, uint256 _bidId)\n external\n returns (RepMark);\n}\n" - }, - "contracts/libraries/V2Calculations.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n// Libraries\nimport \"./NumbersLib.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport { Bid } from \"../TellerV2Storage.sol\";\n\nenum PaymentType {\n EMI,\n Bullet\n}\n\nenum PaymentCycleType {\n Seconds,\n Monthly\n}\n\nlibrary V2Calculations {\n using NumbersLib for uint256;\n\n /**\n * @notice Returns the timestamp of the last payment made for a loan.\n * @param _bid The loan bid struct to get the timestamp for.\n */\n function lastRepaidTimestamp(Bid storage _bid)\n internal\n view\n returns (uint32)\n {\n return\n _bid.loanDetails.lastRepaidTimestamp == 0\n ? _bid.loanDetails.acceptedTimestamp\n : _bid.loanDetails.lastRepaidTimestamp;\n }\n\n /**\n * @notice Calculates the amount owed for a loan.\n * @param _bid The loan bid struct to get the owed amount for.\n * @param _timestamp The timestamp at which to get the owed amount at.\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\n */\n function calculateAmountOwed(\n Bid storage _bid,\n uint256 _timestamp,\n PaymentCycleType _paymentCycleType\n )\n internal\n view\n returns (\n uint256 owedPrincipal_,\n uint256 duePrincipal_,\n uint256 interest_\n )\n {\n // Total principal left to pay\n return\n calculateAmountOwed(\n _bid,\n lastRepaidTimestamp(_bid),\n _timestamp,\n _paymentCycleType\n );\n }\n\n function calculateAmountOwed(\n Bid storage _bid,\n uint256 _lastRepaidTimestamp,\n uint256 _timestamp,\n PaymentCycleType _paymentCycleType\n )\n internal\n view\n returns (\n uint256 owedPrincipal_,\n uint256 duePrincipal_,\n uint256 interest_\n )\n {\n owedPrincipal_ =\n _bid.loanDetails.principal -\n _bid.loanDetails.totalRepaid.principal;\n\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\n ? 360 days\n : 365 days;\n\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\n\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\n int256 durationLeftOnLoan = int256(\n uint256(_bid.loanDetails.loanDuration)\n ) -\n (int256(_timestamp) -\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\n bool isLastPaymentCycle = durationLeftOnLoan <\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\n\n if (_bid.paymentType == PaymentType.Bullet) {\n if (isLastPaymentCycle) {\n duePrincipal_ = owedPrincipal_;\n }\n } else {\n // Default to PaymentType.EMI\n // Max payable amount in a cycle\n // NOTE: the last cycle could have less than the calculated payment amount\n uint256 maxCycleOwed = isLastPaymentCycle\n ? owedPrincipal_ + interest_\n : _bid.terms.paymentCycleAmount;\n\n // Calculate accrued amount due since last repayment\n uint256 owedAmount = (maxCycleOwed * owedTime) /\n _bid.terms.paymentCycle;\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\n }\n }\n\n /**\n * @notice Calculates the amount owed for a loan for the next payment cycle.\n * @param _type The payment type of the loan.\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\n * @param _principal The starting amount that is owed on the loan.\n * @param _duration The length of the loan.\n * @param _paymentCycle The length of the loan's payment cycle.\n * @param _apr The annual percentage rate of the loan.\n */\n function calculatePaymentCycleAmount(\n PaymentType _type,\n PaymentCycleType _cycleType,\n uint256 _principal,\n uint32 _duration,\n uint32 _paymentCycle,\n uint16 _apr\n ) internal returns (uint256) {\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\n ? 360 days\n : 365 days;\n if (_type == PaymentType.Bullet) {\n return\n _principal.percent(_apr).percent(\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\n 10\n );\n }\n // Default to PaymentType.EMI\n return\n NumbersLib.pmt(\n _principal,\n _duration,\n _paymentCycle,\n _apr,\n daysInYear\n );\n }\n}\n" - }, - "contracts/interfaces/ILenderManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\n\nabstract contract ILenderManager is IERC721Upgradeable {\n /**\n * @notice Registers a new active lender for a loan, minting the nft.\n * @param _bidId The id for the loan to set.\n * @param _newLender The address of the new active lender.\n */\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\n}\n" - }, - "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^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 *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\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 // 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) {\n // 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 if (lastIndex != toDeleteIndex) {\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] = valueIndex; // Replace lastValue's index to valueIndex\n }\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 return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 in 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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * 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, IERC20Metadata {\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\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override 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 override 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 this function is\n * overridden;\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 override returns (uint8) {\n return 18;\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 * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\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 address owner = _msgSender();\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\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 address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This 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 * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(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(\n address owner,\n address spender,\n uint256 amount\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\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 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after 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 * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" - }, - "contracts/EAS/TellerAS.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../Types.sol\";\nimport \"../interfaces/IEAS.sol\";\nimport \"../interfaces/IASRegistry.sol\";\n\n/**\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\n */\ncontract TellerAS is IEAS {\n error AccessDenied();\n error AlreadyRevoked();\n error InvalidAttestation();\n error InvalidExpirationTime();\n error InvalidOffset();\n error InvalidRegistry();\n error InvalidSchema();\n error InvalidVerifier();\n error NotFound();\n error NotPayable();\n\n string public constant VERSION = \"0.8\";\n\n // A terminator used when concatenating and hashing multiple fields.\n string private constant HASH_TERMINATOR = \"@\";\n\n // The AS global registry.\n IASRegistry private immutable _asRegistry;\n\n // The EIP712 verifier used to verify signed attestations.\n IEASEIP712Verifier private immutable _eip712Verifier;\n\n // A mapping between attestations and their related attestations.\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\n\n // A mapping between an account and its received attestations.\n mapping(address => mapping(bytes32 => bytes32[]))\n private _receivedAttestations;\n\n // A mapping between an account and its sent attestations.\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\n\n // A mapping between a schema and its attestations.\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\n\n // The global mapping between attestations and their UUIDs.\n mapping(bytes32 => Attestation) private _db;\n\n // The global counter for the total number of attestations.\n uint256 private _attestationsCount;\n\n bytes32 private _lastUUID;\n\n /**\n * @dev Creates a new EAS instance.\n *\n * @param registry The address of the global AS registry.\n * @param verifier The address of the EIP712 verifier.\n */\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\n if (address(registry) == address(0x0)) {\n revert InvalidRegistry();\n }\n\n if (address(verifier) == address(0x0)) {\n revert InvalidVerifier();\n }\n\n _asRegistry = registry;\n _eip712Verifier = verifier;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getASRegistry() external view override returns (IASRegistry) {\n return _asRegistry;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getEIP712Verifier()\n external\n view\n override\n returns (IEASEIP712Verifier)\n {\n return _eip712Verifier;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getAttestationsCount() external view override returns (uint256) {\n return _attestationsCount;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data\n ) public payable virtual override returns (bytes32) {\n return\n _attest(\n recipient,\n schema,\n expirationTime,\n refUUID,\n data,\n msg.sender\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function attestByDelegation(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public payable virtual override returns (bytes32) {\n _eip712Verifier.attest(\n recipient,\n schema,\n expirationTime,\n refUUID,\n data,\n attester,\n v,\n r,\n s\n );\n\n return\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function revoke(bytes32 uuid) public virtual override {\n return _revoke(uuid, msg.sender);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function revokeByDelegation(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n _eip712Verifier.revoke(uuid, attester, v, r, s);\n\n _revoke(uuid, attester);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getAttestation(bytes32 uuid)\n external\n view\n override\n returns (Attestation memory)\n {\n return _db[uuid];\n }\n\n /**\n * @inheritdoc IEAS\n */\n function isAttestationValid(bytes32 uuid)\n public\n view\n override\n returns (bool)\n {\n return _db[uuid].uuid != 0;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function isAttestationActive(bytes32 uuid)\n public\n view\n override\n returns (bool)\n {\n return\n isAttestationValid(uuid) &&\n _db[uuid].expirationTime >= block.timestamp &&\n _db[uuid].revocationTime == 0;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getReceivedAttestationUUIDs(\n address recipient,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _receivedAttestations[recipient][schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _receivedAttestations[recipient][schema].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSentAttestationUUIDs(\n address attester,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _sentAttestations[attester][schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _sentAttestations[recipient][schema].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getRelatedAttestationUUIDs(\n bytes32 uuid,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _relatedAttestations[uuid],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\n external\n view\n override\n returns (uint256)\n {\n return _relatedAttestations[uuid].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSchemaAttestationUUIDs(\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _schemaAttestations[schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSchemaAttestationUUIDsCount(bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _schemaAttestations[schema].length;\n }\n\n /**\n * @dev Attests to a specific AS.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n *\n * @return The UUID of the new attestation.\n */\n function _attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester\n ) private returns (bytes32) {\n if (expirationTime <= block.timestamp) {\n revert InvalidExpirationTime();\n }\n\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\n if (asRecord.uuid == EMPTY_UUID) {\n revert InvalidSchema();\n }\n\n IASResolver resolver = asRecord.resolver;\n if (address(resolver) != address(0x0)) {\n if (msg.value != 0 && !resolver.isPayable()) {\n revert NotPayable();\n }\n\n if (\n !resolver.resolve{ value: msg.value }(\n recipient,\n asRecord.schema,\n data,\n expirationTime,\n attester\n )\n ) {\n revert InvalidAttestation();\n }\n }\n\n Attestation memory attestation = Attestation({\n uuid: EMPTY_UUID,\n schema: schema,\n recipient: recipient,\n attester: attester,\n time: block.timestamp,\n expirationTime: expirationTime,\n revocationTime: 0,\n refUUID: refUUID,\n data: data\n });\n\n _lastUUID = _getUUID(attestation);\n attestation.uuid = _lastUUID;\n\n _receivedAttestations[recipient][schema].push(_lastUUID);\n _sentAttestations[attester][schema].push(_lastUUID);\n _schemaAttestations[schema].push(_lastUUID);\n\n _db[_lastUUID] = attestation;\n _attestationsCount++;\n\n if (refUUID != 0) {\n if (!isAttestationValid(refUUID)) {\n revert NotFound();\n }\n\n _relatedAttestations[refUUID].push(_lastUUID);\n }\n\n emit Attested(recipient, attester, _lastUUID, schema);\n\n return _lastUUID;\n }\n\n function getLastUUID() external view returns (bytes32) {\n return _lastUUID;\n }\n\n /**\n * @dev Revokes an existing attestation to a specific AS.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n */\n function _revoke(bytes32 uuid, address attester) private {\n Attestation storage attestation = _db[uuid];\n if (attestation.uuid == EMPTY_UUID) {\n revert NotFound();\n }\n\n if (attestation.attester != attester) {\n revert AccessDenied();\n }\n\n if (attestation.revocationTime != 0) {\n revert AlreadyRevoked();\n }\n\n attestation.revocationTime = block.timestamp;\n\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\n }\n\n /**\n * @dev Calculates a UUID for a given attestation.\n *\n * @param attestation The input attestation.\n *\n * @return Attestation UUID.\n */\n function _getUUID(Attestation memory attestation)\n private\n view\n returns (bytes32)\n {\n return\n keccak256(\n abi.encodePacked(\n attestation.schema,\n attestation.recipient,\n attestation.attester,\n attestation.time,\n attestation.expirationTime,\n attestation.data,\n HASH_TERMINATOR,\n _attestationsCount\n )\n );\n }\n\n /**\n * @dev Returns a slice in an array of attestation UUIDs.\n *\n * @param uuids The array of attestation UUIDs.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function _sliceUUIDs(\n bytes32[] memory uuids,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) private pure returns (bytes32[] memory) {\n uint256 attestationsLength = uuids.length;\n if (attestationsLength == 0) {\n return new bytes32[](0);\n }\n\n if (start >= attestationsLength) {\n revert InvalidOffset();\n }\n\n uint256 len = length;\n if (attestationsLength < start + length) {\n len = attestationsLength - start;\n }\n\n bytes32[] memory res = new bytes32[](len);\n\n for (uint256 i = 0; i < len; ++i) {\n res[i] = uuids[\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\n ];\n }\n\n return res;\n }\n}\n" - }, - "contracts/Types.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// A representation of an empty/uninitialized UUID.\nbytes32 constant EMPTY_UUID = 0;\n" - }, - "contracts/interfaces/IEAS.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./IASRegistry.sol\";\nimport \"./IEASEIP712Verifier.sol\";\n\n/**\n * @title EAS - Ethereum Attestation Service interface\n */\ninterface IEAS {\n /**\n * @dev A struct representing a single attestation.\n */\n struct Attestation {\n // A unique identifier of the attestation.\n bytes32 uuid;\n // A unique identifier of the AS.\n bytes32 schema;\n // The recipient of the attestation.\n address recipient;\n // The attester/sender of the attestation.\n address attester;\n // The time when the attestation was created (Unix timestamp).\n uint256 time;\n // The time when the attestation expires (Unix timestamp).\n uint256 expirationTime;\n // The time when the attestation was revoked (Unix timestamp).\n uint256 revocationTime;\n // The UUID of the related attestation.\n bytes32 refUUID;\n // Custom attestation data.\n bytes data;\n }\n\n /**\n * @dev Triggered when an attestation has been made.\n *\n * @param recipient The recipient of the attestation.\n * @param attester The attesting account.\n * @param uuid The UUID the revoked attestation.\n * @param schema The UUID of the AS.\n */\n event Attested(\n address indexed recipient,\n address indexed attester,\n bytes32 uuid,\n bytes32 indexed schema\n );\n\n /**\n * @dev Triggered when an attestation has been revoked.\n *\n * @param recipient The recipient of the attestation.\n * @param attester The attesting account.\n * @param schema The UUID of the AS.\n * @param uuid The UUID the revoked attestation.\n */\n event Revoked(\n address indexed recipient,\n address indexed attester,\n bytes32 uuid,\n bytes32 indexed schema\n );\n\n /**\n * @dev Returns the address of the AS global registry.\n *\n * @return The address of the AS global registry.\n */\n function getASRegistry() external view returns (IASRegistry);\n\n /**\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\n *\n * @return The address of the EIP712 verifier used to verify signed attestations.\n */\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\n\n /**\n * @dev Returns the global counter for the total number of attestations.\n *\n * @return The global counter for the total number of attestations.\n */\n function getAttestationsCount() external view returns (uint256);\n\n /**\n * @dev Attests to a specific AS.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n *\n * @return The UUID of the new attestation.\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data\n ) external payable returns (bytes32);\n\n /**\n * @dev Attests to a specific AS using a provided EIP712 signature.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n *\n * @return The UUID of the new attestation.\n */\n function attestByDelegation(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external payable returns (bytes32);\n\n /**\n * @dev Revokes an existing attestation to a specific AS.\n *\n * @param uuid The UUID of the attestation to revoke.\n */\n function revoke(bytes32 uuid) external;\n\n /**\n * @dev Attests to a specific AS using a provided EIP712 signature.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function revokeByDelegation(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns an existing attestation by UUID.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return The attestation data members.\n */\n function getAttestation(bytes32 uuid)\n external\n view\n returns (Attestation memory);\n\n /**\n * @dev Checks whether an attestation exists.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return Whether an attestation exists.\n */\n function isAttestationValid(bytes32 uuid) external view returns (bool);\n\n /**\n * @dev Checks whether an attestation is active.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return Whether an attestation is active.\n */\n function isAttestationActive(bytes32 uuid) external view returns (bool);\n\n /**\n * @dev Returns all received attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getReceivedAttestationUUIDs(\n address recipient,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of received attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all sent attestation UUIDs.\n *\n * @param attester The attesting account.\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getSentAttestationUUIDs(\n address attester,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of sent attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all attestations related to a specific attestation.\n *\n * @param uuid The UUID of the attestation to retrieve.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getRelatedAttestationUUIDs(\n bytes32 uuid,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of related attestation UUIDs.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return The number of related attestations.\n */\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all per-schema attestation UUIDs.\n *\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getSchemaAttestationUUIDs(\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of per-schema attestation UUIDs.\n *\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getSchemaAttestationUUIDsCount(bytes32 schema)\n external\n view\n returns (uint256);\n}\n" - }, - "contracts/interfaces/IASRegistry.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./IASResolver.sol\";\n\n/**\n * @title The global AS registry interface.\n */\ninterface IASRegistry {\n /**\n * @title A struct representing a record for a submitted AS (Attestation Schema).\n */\n struct ASRecord {\n // A unique identifier of the AS.\n bytes32 uuid;\n // Optional schema resolver.\n IASResolver resolver;\n // Auto-incrementing index for reference, assigned by the registry itself.\n uint256 index;\n // Custom specification of the AS (e.g., an ABI).\n bytes schema;\n }\n\n /**\n * @dev Triggered when a new AS has been registered\n *\n * @param uuid The AS UUID.\n * @param index The AS index.\n * @param schema The AS schema.\n * @param resolver An optional AS schema resolver.\n * @param attester The address of the account used to register the AS.\n */\n event Registered(\n bytes32 indexed uuid,\n uint256 indexed index,\n bytes schema,\n IASResolver resolver,\n address attester\n );\n\n /**\n * @dev Submits and reserve a new AS\n *\n * @param schema The AS data schema.\n * @param resolver An optional AS schema resolver.\n *\n * @return The UUID of the new AS.\n */\n function register(bytes calldata schema, IASResolver resolver)\n external\n returns (bytes32);\n\n /**\n * @dev Returns an existing AS by UUID\n *\n * @param uuid The UUID of the AS to retrieve.\n *\n * @return The AS data members.\n */\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\n\n /**\n * @dev Returns the global counter for the total number of attestations\n *\n * @return The global counter for the total number of attestations.\n */\n function getASCount() external view returns (uint256);\n}\n" - }, - "contracts/interfaces/IEASEIP712Verifier.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n/**\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\n */\ninterface IEASEIP712Verifier {\n /**\n * @dev Returns the current nonce per-account.\n *\n * @param account The requested accunt.\n *\n * @return The current nonce.\n */\n function getNonce(address account) external view returns (uint256);\n\n /**\n * @dev Verifies signed attestation.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Verifies signed revocations.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function revoke(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" - }, - "contracts/interfaces/IASResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n/**\n * @title The interface of an optional AS resolver.\n */\ninterface IASResolver {\n /**\n * @dev Returns whether the resolver supports ETH transfers\n */\n function isPayable() external pure returns (bool);\n\n /**\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The AS data schema.\n * @param data The actual attestation data.\n * @param expirationTime The expiration time of the attestation.\n * @param msgSender The sender of the original attestation message.\n *\n * @return Whether the data is valid according to the scheme.\n */\n function resolve(\n address recipient,\n bytes calldata schema,\n bytes calldata data,\n uint256 expirationTime,\n address msgSender\n ) external payable returns (bool);\n}\n" - }, - "contracts/libraries/NumbersLib.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// Libraries\nimport { SafeCast } from \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport { Math } from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./WadRayMath.sol\";\n\n/**\n * @dev Utility library for uint256 numbers\n *\n * @author develop@teller.finance\n */\nlibrary NumbersLib {\n using WadRayMath for uint256;\n\n /**\n * @dev It represents 100% with 2 decimal places.\n */\n uint16 internal constant PCT_100 = 10000;\n\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\n return 100 * (10**decimals);\n }\n\n /**\n * @notice Returns a percentage value of a number.\n * @param self The number to get a percentage of.\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\n */\n function percent(uint256 self, uint16 percentage)\n internal\n pure\n returns (uint256)\n {\n return percent(self, percentage, 2);\n }\n\n /**\n * @notice Returns a percentage value of a number.\n * @param self The number to get a percentage of.\n * @param percentage The percentage value to calculate with.\n * @param decimals The number of decimals the percentage value is in.\n */\n function percent(uint256 self, uint256 percentage, uint256 decimals)\n internal\n pure\n returns (uint256)\n {\n return (self * percentage) / percentFactor(decimals);\n }\n\n /**\n * @notice it returns the absolute number of a specified parameter\n * @param self the number to be returned in it's absolute\n * @return the absolute number\n */\n function abs(int256 self) internal pure returns (uint256) {\n return self >= 0 ? uint256(self) : uint256(-1 * self);\n }\n\n /**\n * @notice Returns a ratio percentage of {num1} to {num2}.\n * @dev Returned value is type uint16.\n * @param num1 The number used to get the ratio for.\n * @param num2 The number used to get the ratio from.\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\n */\n function ratioOf(uint256 num1, uint256 num2)\n internal\n pure\n returns (uint16)\n {\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\n }\n\n /**\n * @notice Returns a ratio percentage of {num1} to {num2}.\n * @param num1 The number used to get the ratio for.\n * @param num2 The number used to get the ratio from.\n * @param decimals The number of decimals the percentage value is returned in.\n * @return Ratio percentage value.\n */\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\n internal\n pure\n returns (uint256)\n {\n if (num2 == 0) return 0;\n return (num1 * percentFactor(decimals)) / num2;\n }\n\n /**\n * @notice Calculates the payment amount for a cycle duration.\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\n * @param principal The starting amount that is owed on the loan.\n * @param loanDuration The length of the loan.\n * @param cycleDuration The length of the loan's payment cycle.\n * @param apr The annual percentage rate of the loan.\n */\n function pmt(\n uint256 principal,\n uint32 loanDuration,\n uint32 cycleDuration,\n uint16 apr,\n uint256 daysInYear\n ) internal pure returns (uint256) {\n require(\n loanDuration >= cycleDuration,\n \"PMT: cycle duration < loan duration\"\n );\n if (apr == 0)\n return\n Math.mulDiv(\n principal,\n cycleDuration,\n loanDuration,\n Math.Rounding.Up\n );\n\n // Number of payment cycles for the duration of the loan\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\n\n uint256 one = WadRayMath.wad();\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\n daysInYear\n );\n uint256 exp = (one + r).wadPow(n);\n uint256 numerator = principal.wadMul(r).wadMul(exp);\n uint256 denominator = exp - one;\n\n return numerator.wadDiv(denominator);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" - }, - "contracts/libraries/WadRayMath.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\n/**\n * @title WadRayMath library\n * @author Multiplier Finance\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\n */\nlibrary WadRayMath {\n using SafeMath for uint256;\n\n uint256 internal constant WAD = 1e18;\n uint256 internal constant halfWAD = WAD / 2;\n\n uint256 internal constant RAY = 1e27;\n uint256 internal constant halfRAY = RAY / 2;\n\n uint256 internal constant WAD_RAY_RATIO = 1e9;\n uint256 internal constant PCT_WAD_RATIO = 1e14;\n uint256 internal constant PCT_RAY_RATIO = 1e23;\n\n function ray() internal pure returns (uint256) {\n return RAY;\n }\n\n function wad() internal pure returns (uint256) {\n return WAD;\n }\n\n function halfRay() internal pure returns (uint256) {\n return halfRAY;\n }\n\n function halfWad() internal pure returns (uint256) {\n return halfWAD;\n }\n\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\n return halfWAD.add(a.mul(b)).div(WAD);\n }\n\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 halfB = b / 2;\n\n return halfB.add(a.mul(WAD)).div(b);\n }\n\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\n return halfRAY.add(a.mul(b)).div(RAY);\n }\n\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 halfB = b / 2;\n\n return halfB.add(a.mul(RAY)).div(b);\n }\n\n function rayToWad(uint256 a) internal pure returns (uint256) {\n uint256 halfRatio = WAD_RAY_RATIO / 2;\n\n return halfRatio.add(a).div(WAD_RAY_RATIO);\n }\n\n function rayToPct(uint256 a) internal pure returns (uint16) {\n uint256 halfRatio = PCT_RAY_RATIO / 2;\n\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\n return SafeCast.toUint16(val);\n }\n\n function wadToPct(uint256 a) internal pure returns (uint16) {\n uint256 halfRatio = PCT_WAD_RATIO / 2;\n\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\n return SafeCast.toUint16(val);\n }\n\n function wadToRay(uint256 a) internal pure returns (uint256) {\n return a.mul(WAD_RAY_RATIO);\n }\n\n function pctToRay(uint16 a) internal pure returns (uint256) {\n return uint256(a).mul(RAY).div(1e4);\n }\n\n function pctToWad(uint16 a) internal pure returns (uint256) {\n return uint256(a).mul(WAD).div(1e4);\n }\n\n /**\n * @dev calculates base^duration. The code uses the ModExp precompile\n * @return z base^duration, in ray\n */\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\n return _pow(x, n, RAY, rayMul);\n }\n\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\n return _pow(x, n, WAD, wadMul);\n }\n\n function _pow(\n uint256 x,\n uint256 n,\n uint256 p,\n function(uint256, uint256) internal pure returns (uint256) mul\n ) internal pure returns (uint256 z) {\n z = n % 2 != 0 ? x : p;\n\n for (n /= 2; n != 0; n /= 2) {\n x = mul(x, x);\n\n if (n % 2 != 0) {\n z = mul(z, x);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeCast.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\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 unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction 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 unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\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 unchecked {\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 /**\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 unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\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 unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\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 return a + b;\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 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 return a * b;\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.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\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 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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\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 * 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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a / b;\n }\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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" - }, - "contracts/tests/TellerV2_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../escrow/CollateralEscrowV1.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\";\nimport \"../LenderCommitmentForwarder.sol\";\nimport \"./resolvers/TestERC20Token.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"../CollateralManager.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\nimport { BidState, Payment } from \"../TellerV2Storage.sol\";\nimport \"../MetaForwarder.sol\";\nimport { LenderManager } from \"../LenderManager.sol\";\n\ncontract TellerV2_Test is Testable {\n TellerV2User private marketOwner;\n TellerV2User private borrower;\n TellerV2User private lender;\n\n TellerV2 tellerV2;\n\n WethMock wethMock;\n TestERC20Token daiMock;\n CollateralManager collateralManager;\n\n uint256 marketId1;\n uint256 collateralAmount = 10;\n\n function setup_beforeAll() public {\n // Deploy test tokens\n wethMock = new WethMock();\n daiMock = new TestERC20Token(\"Dai\", \"DAI\", 10000000, 18);\n\n // Deploy Escrow beacon\n CollateralEscrowV1 escrowImplementation = new CollateralEscrowV1();\n UpgradeableBeacon escrowBeacon = new UpgradeableBeacon(\n address(escrowImplementation)\n );\n\n // Deploy protocol\n tellerV2 = new TellerV2(address(0));\n\n // Deploy MarketRegistry & ReputationManager\n IMarketRegistry marketRegistry = IMarketRegistry(new MarketRegistry());\n IReputationManager reputationManager = IReputationManager(\n new ReputationManager()\n );\n reputationManager.initialize(address(tellerV2));\n\n // Deploy Collateral manager\n collateralManager = new CollateralManager();\n collateralManager.initialize(address(escrowBeacon), address(tellerV2));\n\n // Deploy Lender manager\n MetaForwarder metaforwarder = new MetaForwarder();\n metaforwarder.initialize();\n LenderManager lenderManager = new LenderManager((marketRegistry));\n lenderManager.initialize();\n lenderManager.transferOwnership(address(tellerV2));\n\n // Deploy LenderCommitmentForwarder\n LenderCommitmentForwarder lenderCommitmentForwarder = new LenderCommitmentForwarder(\n address(tellerV2),\n address(marketRegistry)\n );\n\n address[] memory lendingTokens = new address[](2);\n lendingTokens[0] = address(wethMock);\n lendingTokens[1] = address(daiMock);\n\n // Initialize protocol\n tellerV2.initialize(\n 50,\n address(marketRegistry),\n address(reputationManager),\n address(lenderCommitmentForwarder),\n lendingTokens,\n address(collateralManager),\n address(lenderManager)\n );\n\n // Instantiate users & balances\n marketOwner = new TellerV2User(address(tellerV2), wethMock);\n borrower = new TellerV2User(address(tellerV2), wethMock);\n lender = new TellerV2User(address(tellerV2), wethMock);\n\n uint256 balance = 50000;\n payable(address(borrower)).transfer(balance);\n payable(address(lender)).transfer(balance * 10);\n borrower.depositToWeth(balance);\n lender.depositToWeth(balance * 10);\n\n daiMock.transfer(address(lender), balance * 10);\n daiMock.transfer(address(borrower), balance);\n // Approve Teller V2 for the lender's dai\n lender.addAllowance(address(daiMock), address(tellerV2), balance * 10);\n\n // Create a market\n marketId1 = marketOwner.createMarket(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n \"uri://\"\n );\n }\n\n function submitCollateralBid() public returns (uint256 bidId_) {\n Collateral memory info;\n info._amount = collateralAmount;\n info._tokenId = 0;\n info._collateralType = CollateralType.ERC20;\n info._collateralAddress = address(wethMock);\n\n Collateral[] memory collateralInfo = new Collateral[](1);\n collateralInfo[0] = info;\n\n uint256 bal = wethMock.balanceOf(address(borrower));\n\n // Increase allowance\n // Approve the collateral manager for the borrower's weth\n borrower.addAllowance(\n address(wethMock),\n address(collateralManager),\n info._amount\n );\n\n bidId_ = borrower.submitCollateralBid(\n address(daiMock),\n marketId1,\n 100,\n 10000,\n 500,\n \"metadataUri://\",\n address(borrower),\n collateralInfo\n );\n }\n\n function acceptBid(uint256 _bidId) public {\n // Accept bid\n lender.acceptBid(_bidId);\n }\n\n function collateralEscrow_test() public {\n // Submit bid as borrower\n uint256 bidId = submitCollateralBid();\n // Accept bid as lender\n acceptBid(bidId);\n\n // Get newly created escrow\n address escrowAddress = collateralManager._escrows(bidId);\n CollateralEscrowV1 escrow = CollateralEscrowV1(escrowAddress);\n\n uint256 storedBidId = escrow.getBid();\n\n // Test that the created escrow has the same bidId and collateral stored\n Test.eq(bidId, storedBidId, \"Collateral escrow was not created\");\n\n uint256 escrowBalance = wethMock.balanceOf(escrowAddress);\n\n Test.eq(collateralAmount, escrowBalance, \"Collateral was not stored\");\n\n // Repay loan\n uint256 borrowerBalanceBefore = wethMock.balanceOf(address(borrower));\n Payment memory amountOwed = tellerV2.calculateAmountOwed(bidId);\n borrower.addAllowance(\n address(daiMock),\n address(tellerV2),\n amountOwed.principal + amountOwed.interest\n );\n borrower.repayLoanFull(bidId);\n\n // Check escrow balance\n uint256 escrowBalanceAfter = wethMock.balanceOf(escrowAddress);\n Test.eq(\n 0,\n escrowBalanceAfter,\n \"Collateral was not withdrawn from escrow on repayment\"\n );\n\n // Check borrower balance for collateral\n uint256 borrowerBalanceAfter = wethMock.balanceOf(address(borrower));\n Test.eq(\n collateralAmount,\n borrowerBalanceAfter - borrowerBalanceBefore,\n \"Collateral was not sent to borrower after repayment\"\n );\n }\n}\n\ncontract TellerV2User is User {\n WethMock public immutable wethMock;\n\n constructor(address _tellerV2, WethMock _wethMock) User(_tellerV2) {\n wethMock = _wethMock;\n }\n\n function depositToWeth(uint256 amount) public {\n wethMock.deposit{ value: amount }();\n }\n}\n" - }, - "contracts/tests/Testable.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\nabstract contract Testable {\n receive() external payable {}\n}\n" - }, - "contracts/TellerV2.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./ProtocolFee.sol\";\nimport \"./TellerV2Storage.sol\";\nimport \"./TellerV2Context.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/IReputationManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport { Collateral } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\nimport { BokkyPooBahsDateTimeLibrary as BPBDTL } from \"./libraries/DateTimeLib.sol\";\nimport { V2Calculations, PaymentCycleType } from \"./libraries/V2Calculations.sol\";\n\n/* Errors */\n/**\n * @notice This error is reverted when the action isn't allowed\n * @param bidId The id of the bid.\n * @param action The action string (i.e: 'repayLoan', 'cancelBid', 'etc)\n * @param message The message string to return to the user explaining why the tx was reverted\n */\nerror ActionNotAllowed(uint256 bidId, string action, string message);\n\n/**\n * @notice This error is reverted when repayment amount is less than the required minimum\n * @param bidId The id of the bid the borrower is attempting to repay.\n * @param payment The payment made by the borrower\n * @param minimumOwed The minimum owed value\n */\nerror PaymentNotMinimum(uint256 bidId, uint256 payment, uint256 minimumOwed);\n\ncontract TellerV2 is\n ITellerV2,\n OwnableUpgradeable,\n ProtocolFee,\n PausableUpgradeable,\n TellerV2Storage,\n TellerV2Context\n{\n using Address for address;\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /** Events */\n\n /**\n * @notice This event is emitted when a new bid is submitted.\n * @param bidId The id of the bid submitted.\n * @param borrower The address of the bid borrower.\n * @param metadataURI URI for additional bid information as part of loan bid.\n */\n event SubmittedBid(\n uint256 indexed bidId,\n address indexed borrower,\n address receiver,\n bytes32 indexed metadataURI\n );\n\n /**\n * @notice This event is emitted when a bid has been accepted by a lender.\n * @param bidId The id of the bid accepted.\n * @param lender The address of the accepted bid lender.\n */\n event AcceptedBid(uint256 indexed bidId, address indexed lender);\n\n /**\n * @notice This event is emitted when a previously submitted bid has been cancelled.\n * @param bidId The id of the cancelled bid.\n */\n event CancelledBid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when market owner has cancelled a pending bid in their market.\n * @param bidId The id of the bid funded.\n *\n * Note: The `CancelledBid` event will also be emitted.\n */\n event MarketOwnerCancelledBid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a payment is made towards an active loan.\n * @param bidId The id of the bid/loan to which the payment was made.\n */\n event LoanRepayment(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a loan has been fully repaid.\n * @param bidId The id of the bid/loan which was repaid.\n */\n event LoanRepaid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a loan has been fully repaid.\n * @param bidId The id of the bid/loan which was repaid.\n */\n event LoanLiquidated(uint256 indexed bidId, address indexed liquidator);\n\n /**\n * @notice This event is emitted when a fee has been paid related to a bid.\n * @param bidId The id of the bid.\n * @param feeType The name of the fee being paid.\n * @param amount The amount of the fee being paid.\n */\n event FeePaid(\n uint256 indexed bidId,\n string indexed feeType,\n uint256 indexed amount\n );\n\n /** Modifiers */\n\n /**\n * @notice This modifier is used to check if the state of a bid is pending, before running an action.\n * @param _bidId The id of the bid to check the state for.\n * @param _action The desired action to run on the bid.\n */\n modifier pendingBid(uint256 _bidId, string memory _action) {\n if (bids[_bidId].state != BidState.PENDING) {\n revert ActionNotAllowed(_bidId, _action, \"Bid must be pending\");\n }\n\n _;\n }\n\n /**\n * @notice This modifier is used to check if the state of a loan has been accepted, before running an action.\n * @param _bidId The id of the bid to check the state for.\n * @param _action The desired action to run on the bid.\n */\n modifier acceptedLoan(uint256 _bidId, string memory _action) {\n if (bids[_bidId].state != BidState.ACCEPTED) {\n revert ActionNotAllowed(_bidId, _action, \"Loan must be accepted\");\n }\n\n _;\n }\n\n /** Constant Variables **/\n\n uint8 public constant CURRENT_CODE_VERSION = 8;\n\n /** Constructor **/\n\n constructor(address trustedForwarder) TellerV2Context(trustedForwarder) {}\n\n /** External Functions **/\n\n /**\n * @notice Initializes the proxy.\n * @param _protocolFee The fee collected by the protocol for loan processing.\n * @param _marketRegistry The address of the market registry contract for the protocol.\n * @param _reputationManager The address of the reputation manager contract.\n * @param _lenderCommitmentForwarder The address of the lender commitment forwarder contract.\n * @param _lendingTokens The list of tokens allowed as lending assets on the protocol.\n * @param _collateralManagerAddress The address of the collateral manager contracts.\n * @param _lenderManager The address of the lender manager contract for loans on the protocol.\n */\n function initialize(\n uint16 _protocolFee,\n address _marketRegistry,\n address _reputationManager,\n address _lenderCommitmentForwarder,\n address[] calldata _lendingTokens,\n address _collateralManagerAddress,\n address _lenderManager\n ) external initializer {\n __ProtocolFee_init(_protocolFee);\n\n __Pausable_init();\n\n lenderCommitmentForwarder = _lenderCommitmentForwarder;\n marketRegistry = IMarketRegistry(_marketRegistry);\n reputationManager = IReputationManager(_reputationManager);\n _setCollateralManager(_collateralManagerAddress);\n _setLenderManager(_lenderManager);\n\n require(_lendingTokens.length > 0, \"No lending tokens specified\");\n for (uint256 i = 0; i < _lendingTokens.length; i++) {\n require(\n _lendingTokens[i].isContract(),\n \"lending token not contract\"\n );\n addLendingToken(_lendingTokens[i]);\n }\n }\n\n function onUpgrade(address _lenderManager)\n external\n reinitializer(CURRENT_CODE_VERSION)\n onlyOwner\n {\n _setLenderManager(_lenderManager);\n }\n\n function _setCollateralManager(address _collateralManager)\n internal\n onlyInitializing\n {\n require(\n address(collateralManager) == address(0),\n \"Collateral Manager already set\"\n );\n require(\n _collateralManager.isContract(),\n \"Collateral Manager must be a contract\"\n );\n collateralManager = ICollateralManager(_collateralManager);\n }\n\n function _setLenderManager(address _lenderManager)\n internal\n onlyInitializing\n {\n require(\n address(lenderManager) == address(0),\n \"LenderManager already set\"\n );\n require(\n _lenderManager.isContract(),\n \"LenderManager must be a contract\"\n );\n lenderManager = ILenderManager(_lenderManager);\n }\n\n /**\n * @notice Gets the metadataURI for a bidId.\n * @param _bidId The id of the bid to return the metadataURI for\n * @return metadataURI_ The metadataURI for the bid, as a string.\n */\n function getMetadataURI(uint256 _bidId)\n public\n view\n returns (string memory metadataURI_)\n {\n // Check uri mapping first\n metadataURI_ = uris[_bidId];\n // If the URI is not present in the mapping\n if (\n keccak256(abi.encodePacked(metadataURI_)) ==\n 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 // hardcoded constant of keccak256('')\n ) {\n // Return depreciated bytes32 uri as a string\n uint256 convertedURI = uint256(bids[_bidId]._metadataURI);\n metadataURI_ = StringsUpgradeable.toHexString(convertedURI, 32);\n }\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol to set a new reputation manager contract.\n * @param _reputationManager The new contract address.\n */\n function setReputationManager(address _reputationManager) public onlyOwner {\n reputationManager = IReputationManager(_reputationManager);\n }\n\n /**\n * @notice Function for a borrower to create a bid for a loan without Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public override whenNotPaused returns (uint256 bidId_) {\n bidId_ = _submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n /**\n * @notice Function for a borrower to create a bid for a loan with Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public override whenNotPaused returns (uint256 bidId_) {\n bidId_ = _submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n\n bool validation = collateralManager.commitCollateral(\n bidId_,\n _collateralInfo\n );\n\n require(\n validation == true,\n \"Collateral balance could not be validated\"\n );\n }\n\n function _submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) internal returns (uint256 bidId_) {\n address sender = _msgSenderForMarket(_marketplaceId);\n (bool isVerified, ) = marketRegistry.isVerifiedBorrower(\n _marketplaceId,\n sender\n );\n require(isVerified, \"Not verified borrower\");\n require(\n !marketRegistry.isMarketClosed(_marketplaceId),\n \"Market is closed\"\n );\n require(\n lendingTokensSet.contains(_lendingToken),\n \"Lending token not authorized\"\n );\n\n // Set response bid ID.\n bidId_ = bidId;\n\n // Create and store our bid into the mapping\n Bid storage bid = bids[bidId];\n bid.borrower = sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketplaceId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n // Set payment cycle type based on market setting (custom or monthly)\n (bid.terms.paymentCycle, bidPaymentCycleType[bidId]) = marketRegistry\n .getPaymentCycle(_marketplaceId);\n\n bid.terms.APR = _APR;\n\n bidDefaultDuration[bidId] = marketRegistry.getPaymentDefaultDuration(\n _marketplaceId\n );\n\n bidExpirationTime[bidId] = marketRegistry.getBidExpirationTime(\n _marketplaceId\n );\n\n bid.paymentType = marketRegistry.getPaymentType(_marketplaceId);\n\n bid.terms.paymentCycleAmount = V2Calculations\n .calculatePaymentCycleAmount(\n bid.paymentType,\n bidPaymentCycleType[bidId],\n _principal,\n _duration,\n bid.terms.paymentCycle,\n _APR\n );\n\n uris[bidId] = _metadataURI;\n bid.state = BidState.PENDING;\n\n emit SubmittedBid(\n bidId,\n bid.borrower,\n bid.receiver,\n keccak256(abi.encodePacked(_metadataURI))\n );\n\n // Store bid inside borrower bids mapping\n borrowerBids[bid.borrower].push(bidId);\n\n // Increment bid id counter\n bidId++;\n }\n\n /**\n * @notice Function for a borrower to cancel their pending bid.\n * @param _bidId The id of the bid to cancel.\n */\n function cancelBid(uint256 _bidId) external {\n if (\n _msgSenderForMarket(bids[_bidId].marketplaceId) !=\n bids[_bidId].borrower\n ) {\n revert ActionNotAllowed({\n bidId: _bidId,\n action: \"cancelBid\",\n message: \"Only the bid owner can cancel!\"\n });\n }\n _cancelBid(_bidId);\n }\n\n /**\n * @notice Function for a market owner to cancel a bid in the market.\n * @param _bidId The id of the bid to cancel.\n */\n function marketOwnerCancelBid(uint256 _bidId) external {\n if (\n _msgSender() !=\n marketRegistry.getMarketOwner(bids[_bidId].marketplaceId)\n ) {\n revert ActionNotAllowed({\n bidId: _bidId,\n action: \"marketOwnerCancelBid\",\n message: \"Only the market owner can cancel!\"\n });\n }\n _cancelBid(_bidId);\n emit MarketOwnerCancelledBid(_bidId);\n }\n\n /**\n * @notice Function for users to cancel a bid.\n * @param _bidId The id of the bid to be cancelled.\n */\n function _cancelBid(uint256 _bidId)\n internal\n pendingBid(_bidId, \"cancelBid\")\n {\n // Set the bid state to CANCELLED\n bids[_bidId].state = BidState.CANCELLED;\n\n // Emit CancelledBid event\n emit CancelledBid(_bidId);\n }\n\n /**\n * @notice Function for a lender to accept a proposed loan bid.\n * @param _bidId The id of the loan bid to accept.\n */\n function lenderAcceptBid(uint256 _bidId)\n external\n override\n pendingBid(_bidId, \"lenderAcceptBid\")\n whenNotPaused\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n // Retrieve bid\n Bid storage bid = bids[_bidId];\n\n address sender = _msgSenderForMarket(bid.marketplaceId);\n\n (bool isVerified, ) = marketRegistry.isVerifiedLender(\n bid.marketplaceId,\n sender\n );\n require(isVerified, \"Not verified lender\");\n\n require(\n !marketRegistry.isMarketClosed(bid.marketplaceId),\n \"Market is closed\"\n );\n\n require(!isLoanExpired(_bidId), \"Bid has expired\");\n\n // Set timestamp\n bid.loanDetails.acceptedTimestamp = uint32(block.timestamp);\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\n\n // Mark borrower's request as accepted\n bid.state = BidState.ACCEPTED;\n\n // Declare the bid acceptor as the lender of the bid\n bid.lender = sender;\n\n // Tell the collateral manager to deploy the escrow and pull funds from the borrower if applicable\n collateralManager.deployAndDeposit(_bidId);\n\n // Transfer funds to borrower from the lender\n amountToProtocol = bid.loanDetails.principal.percent(protocolFee());\n amountToMarketplace = bid.loanDetails.principal.percent(\n marketRegistry.getMarketplaceFee(bid.marketplaceId)\n );\n amountToBorrower =\n bid.loanDetails.principal -\n amountToProtocol -\n amountToMarketplace;\n //transfer fee to protocol\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n owner(),\n amountToProtocol\n );\n\n //transfer fee to marketplace\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n marketRegistry.getMarketFeeRecipient(bid.marketplaceId),\n amountToMarketplace\n );\n\n //transfer funds to borrower\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n bid.receiver,\n amountToBorrower\n );\n\n // Record volume filled by lenders\n lenderVolumeFilled[address(bid.loanDetails.lendingToken)][sender] += bid\n .loanDetails\n .principal;\n totalVolumeFilled[address(bid.loanDetails.lendingToken)] += bid\n .loanDetails\n .principal;\n\n // Add borrower's active bid\n _borrowerBidsActive[bid.borrower].add(_bidId);\n\n // Emit AcceptedBid\n emit AcceptedBid(_bidId, sender);\n\n emit FeePaid(_bidId, \"protocol\", amountToProtocol);\n emit FeePaid(_bidId, \"marketplace\", amountToMarketplace);\n }\n\n function claimLoanNFT(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"claimLoanNFT\")\n whenNotPaused\n {\n // Retrieve bid\n Bid storage bid = bids[_bidId];\n\n address sender = _msgSenderForMarket(bid.marketplaceId);\n require(sender == bid.lender, \"only lender can claim NFT\");\n // mint an NFT with the lender manager\n lenderManager.registerLoan(_bidId, sender);\n // set lender address to the lender manager so we know to check the owner of the NFT for the true lender\n bid.lender = address(lenderManager);\n }\n\n /**\n * @notice Function for users to make the minimum amount due for an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanMinimum(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (\n uint256 owedPrincipal,\n uint256 duePrincipal,\n uint256 interest\n ) = V2Calculations.calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: duePrincipal, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n /**\n * @notice Function for users to repay an active loan in full.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanFull(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: owedPrincipal, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n // function that the borrower (ideally) sends to repay the loan\n /**\n * @notice Function for users to make a payment towards an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _amount The amount of the payment.\n */\n function repayLoan(uint256 _bidId, uint256 _amount)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (\n uint256 owedPrincipal,\n uint256 duePrincipal,\n uint256 interest\n ) = V2Calculations.calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n uint256 minimumOwed = duePrincipal + interest;\n\n // If amount is less than minimumOwed, we revert\n if (_amount < minimumOwed) {\n revert PaymentNotMinimum(_bidId, _amount, minimumOwed);\n }\n\n _repayLoan(\n _bidId,\n Payment({ principal: _amount - interest, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol implement an emergency stop mechanism.\n */\n function pauseProtocol() public virtual onlyOwner whenNotPaused {\n _pause();\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol undo a previously implemented emergency stop.\n */\n function unpauseProtocol() public virtual onlyOwner whenPaused {\n _unpause();\n }\n\n //TODO: add an incentive for liquidator\n /**\n * @notice Function for users to liquidate a defaulted loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function liquidateLoanFull(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"liquidateLoan\")\n {\n require(isLoanDefaulted(_bidId), \"Loan must be defaulted.\");\n\n Bid storage bid = bids[_bidId];\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bid,\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: owedPrincipal, interest: interest }),\n owedPrincipal + interest,\n false\n );\n\n bid.state = BidState.LIQUIDATED;\n\n // If loan is backed by collateral, withdraw and send to the liquidator\n address liquidator = _msgSenderForMarket(bid.marketplaceId);\n collateralManager.liquidateCollateral(_bidId, liquidator);\n\n emit LoanLiquidated(_bidId, liquidator);\n }\n\n /**\n * @notice Internal function to make a loan payment.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _payment The Payment struct with payments amounts towards principal and interest respectively.\n * @param _owedAmount The total amount owed on the loan.\n */\n function _repayLoan(\n uint256 _bidId,\n Payment memory _payment,\n uint256 _owedAmount,\n bool _shouldWithdrawCollateral\n ) internal {\n Bid storage bid = bids[_bidId];\n uint256 paymentAmount = _payment.principal + _payment.interest;\n\n RepMark mark = reputationManager.updateAccountReputation(\n bid.borrower,\n _bidId\n );\n\n // Check if we are sending a payment or amount remaining\n if (paymentAmount >= _owedAmount) {\n paymentAmount = _owedAmount;\n bid.state = BidState.PAID;\n\n // Remove borrower's active bid\n _borrowerBidsActive[bid.borrower].remove(_bidId);\n\n // If loan is is being liquidated and backed by collateral, withdraw and send to borrower\n if (_shouldWithdrawCollateral) {\n collateralManager.withdraw(_bidId);\n }\n\n emit LoanRepaid(_bidId);\n } else {\n emit LoanRepayment(_bidId);\n }\n\n address lender = getLoanLender(_bidId);\n\n // Send payment to the lender\n bid.loanDetails.lendingToken.safeTransferFrom(\n _msgSenderForMarket(bid.marketplaceId),\n lender,\n paymentAmount\n );\n\n // update our mappings\n bid.loanDetails.totalRepaid.principal += _payment.principal;\n bid.loanDetails.totalRepaid.interest += _payment.interest;\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\n\n // If the loan is paid in full and has a mark, we should update the current reputation\n if (mark != RepMark.Good) {\n reputationManager.updateAccountReputation(bid.borrower, _bidId);\n }\n }\n\n /**\n * @notice Calculates the total amount owed for a bid.\n * @param _bidId The id of the loan bid to calculate the owed amount for.\n */\n function calculateAmountOwed(uint256 _bidId)\n public\n view\n returns (Payment memory owed)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return owed;\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n owed.principal = owedPrincipal;\n owed.interest = interest;\n }\n\n /**\n * @notice Calculates the total amount owed for a loan bid at a specific timestamp.\n * @param _bidId The id of the loan bid to calculate the owed amount for.\n * @param _timestamp The timestamp at which to calculate the loan owed amount at.\n */\n function calculateAmountOwed(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory owed)\n {\n Bid storage bid = bids[_bidId];\n if (\n bid.state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return owed;\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n owed.principal = owedPrincipal;\n owed.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Returns the next due date for a loan payment.\n * @param _bidId The id of the loan bid.\n */\n function calculateNextDueDate(uint256 _bidId)\n public\n view\n returns (uint32 dueDate_)\n {\n Bid storage bid = bids[_bidId];\n if (bids[_bidId].state != BidState.ACCEPTED) return dueDate_;\n\n uint32 lastRepaidTimestamp = lastRepaidTimestamp(_bidId);\n\n // Calculate due date if payment cycle is set to monthly\n if (bidPaymentCycleType[_bidId] == PaymentCycleType.Monthly) {\n // Calculate the cycle number the last repayment was made\n uint256 lastPaymentCycle = BPBDTL.diffMonths(\n bid.loanDetails.acceptedTimestamp,\n lastRepaidTimestamp\n );\n if (\n BPBDTL.getDay(lastRepaidTimestamp) >\n BPBDTL.getDay(bid.loanDetails.acceptedTimestamp)\n ) {\n lastPaymentCycle += 2;\n } else {\n lastPaymentCycle += 1;\n }\n\n dueDate_ = uint32(\n BPBDTL.addMonths(\n bid.loanDetails.acceptedTimestamp,\n lastPaymentCycle\n )\n );\n } else if (bidPaymentCycleType[_bidId] == PaymentCycleType.Seconds) {\n // Start with the original due date being 1 payment cycle since bid was accepted\n dueDate_ =\n bid.loanDetails.acceptedTimestamp +\n bid.terms.paymentCycle;\n // Calculate the cycle number the last repayment was made\n uint32 delta = lastRepaidTimestamp -\n bid.loanDetails.acceptedTimestamp;\n if (delta > 0) {\n uint32 repaymentCycle = uint32(\n Math.ceilDiv(delta, bid.terms.paymentCycle)\n );\n dueDate_ += (repaymentCycle * bid.terms.paymentCycle);\n }\n }\n\n uint32 endOfLoan = bid.loanDetails.acceptedTimestamp +\n bid.loanDetails.loanDuration;\n //if we are in the last payment cycle, the next due date is the end of loan duration\n if (dueDate_ > endOfLoan) {\n dueDate_ = endOfLoan;\n }\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isPaymentLate(uint256 _bidId) public view override returns (bool) {\n if (bids[_bidId].state != BidState.ACCEPTED) return false;\n return uint32(block.timestamp) > calculateNextDueDate(_bidId);\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanDefaulted(uint256 _bidId)\n public\n view\n override\n returns (bool)\n {\n Bid storage bid = bids[_bidId];\n\n // Make sure loan cannot be liquidated if it is not active\n if (bid.state != BidState.ACCEPTED) return false;\n\n if (bidDefaultDuration[_bidId] == 0) return false;\n\n return (uint32(block.timestamp) - lastRepaidTimestamp(_bidId) >\n bidDefaultDuration[_bidId]);\n }\n\n function getBidState(uint256 _bidId)\n external\n view\n override\n returns (BidState)\n {\n return bids[_bidId].state;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n external\n view\n override\n returns (uint256[] memory)\n {\n return _borrowerBidsActive[_borrower].values();\n }\n\n function getBorrowerLoanIds(address _borrower)\n external\n view\n returns (uint256[] memory)\n {\n return borrowerBids[_borrower];\n }\n\n /**\n * @notice Checks to see if a pending loan has expired so it is no longer able to be accepted.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanExpired(uint256 _bidId) public view returns (bool) {\n Bid storage bid = bids[_bidId];\n\n if (bid.state != BidState.PENDING) return false;\n if (bidExpirationTime[_bidId] == 0) return false;\n\n return (uint32(block.timestamp) >\n bid.loanDetails.timestamp + bidExpirationTime[_bidId]);\n }\n\n /**\n * @notice Returns the last repaid timestamp for a loan.\n * @param _bidId The id of the loan bid to get the timestamp for.\n */\n function lastRepaidTimestamp(uint256 _bidId) public view returns (uint32) {\n return V2Calculations.lastRepaidTimestamp(bids[_bidId]);\n }\n\n /**\n * @notice Returns the list of authorized tokens on the protocol.\n */\n function getLendingTokens() public view returns (address[] memory) {\n return lendingTokensSet.values();\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol add an authorized lending token.\n * @param _lendingToken The contract address of the lending token.\n */\n function addLendingToken(address _lendingToken) public onlyOwner {\n require(_lendingToken.isContract(), \"Incorrect lending token address\");\n lendingTokensSet.add(_lendingToken);\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol remove an authorized lending token.\n * @param _lendingToken The contract address of the lending token.\n */\n function removeLendingToken(address _lendingToken) public onlyOwner {\n lendingTokensSet.remove(_lendingToken);\n }\n\n /**\n * @notice Returns the borrower address for a given bid.\n * @param _bidId The id of the bid/loan to get the borrower for.\n * @return borrower_ The address of the borrower associated with the bid.\n */\n function getLoanBorrower(uint256 _bidId)\n public\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n /**\n * @notice Returns the lender address for a given bid. If the stored lender address is the `LenderManager` NFT address, return the `ownerOf` for the bid ID.\n * @param _bidId The id of the bid/loan to get the lender for.\n * @return lender_ The address of the lender associated with the bid.\n */\n function getLoanLender(uint256 _bidId)\n public\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n\n if (lender_ == address(lenderManager)) {\n return lenderManager.ownerOf(_bidId);\n }\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n /** OpenZeppelin Override Functions **/\n\n function _msgSender()\n internal\n view\n virtual\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\n returns (address sender)\n {\n sender = ERC2771ContextUpgradeable._msgSender();\n }\n\n function _msgData()\n internal\n view\n virtual\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\n returns (bytes calldata)\n {\n return ERC2771ContextUpgradeable._msgData();\n }\n}\n" - }, - "contracts/MarketRegistry.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// Contracts\nimport \"./EAS/TellerAS.sol\";\nimport \"./EAS/TellerASResolver.sol\";\n\n//must continue to use this so storage slots are not broken\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n// Interfaces\nimport \"./interfaces/IMarketRegistry.sol\";\n\n// Libraries\nimport { EnumerableSet } from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport { PaymentType } from \"./libraries/V2Calculations.sol\";\n\ncontract MarketRegistry is\n IMarketRegistry,\n Initializable,\n Context,\n TellerASResolver\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /** Constant Variables **/\n\n uint256 public constant CURRENT_CODE_VERSION = 7;\n\n /* Storage Variables */\n\n struct Marketplace {\n address owner;\n string metadataURI;\n uint16 marketplaceFeePercent; // 10000 is 100%\n bool lenderAttestationRequired;\n EnumerableSet.AddressSet verifiedLendersForMarket;\n mapping(address => bytes32) lenderAttestationIds;\n uint32 paymentCycleDuration; // unix time (seconds)\n uint32 paymentDefaultDuration; //unix time\n uint32 bidExpirationTime; //unix time\n bool borrowerAttestationRequired;\n EnumerableSet.AddressSet verifiedBorrowersForMarket;\n mapping(address => bytes32) borrowerAttestationIds;\n address feeRecipient;\n PaymentType paymentType;\n PaymentCycleType paymentCycleType;\n }\n\n bytes32 public lenderAttestationSchemaId;\n\n mapping(uint256 => Marketplace) internal markets;\n mapping(bytes32 => uint256) internal __uriToId; //DEPRECATED\n uint256 public marketCount;\n bytes32 private _attestingSchemaId;\n bytes32 public borrowerAttestationSchemaId;\n\n uint256 public version;\n\n mapping(uint256 => bool) private marketIsClosed;\n\n TellerAS public tellerAS;\n\n /* Modifiers */\n\n modifier ownsMarket(uint256 _marketId) {\n require(markets[_marketId].owner == _msgSender(), \"Not the owner\");\n _;\n }\n\n modifier withAttestingSchema(bytes32 schemaId) {\n _attestingSchemaId = schemaId;\n _;\n _attestingSchemaId = bytes32(0);\n }\n\n /* Events */\n\n event MarketCreated(address indexed owner, uint256 marketId);\n event SetMarketURI(uint256 marketId, string uri);\n event SetPaymentCycleDuration(uint256 marketId, uint32 duration); // DEPRECATED - used for subgraph reference\n event SetPaymentCycle(\n uint256 marketId,\n PaymentCycleType paymentCycleType,\n uint32 value\n );\n event SetPaymentDefaultDuration(uint256 marketId, uint32 duration);\n event SetBidExpirationTime(uint256 marketId, uint32 duration);\n event SetMarketFee(uint256 marketId, uint16 feePct);\n event LenderAttestation(uint256 marketId, address lender);\n event BorrowerAttestation(uint256 marketId, address borrower);\n event LenderRevocation(uint256 marketId, address lender);\n event BorrowerRevocation(uint256 marketId, address borrower);\n event MarketClosed(uint256 marketId);\n event LenderExitMarket(uint256 marketId, address lender);\n event BorrowerExitMarket(uint256 marketId, address borrower);\n event SetMarketOwner(uint256 marketId, address newOwner);\n event SetMarketFeeRecipient(uint256 marketId, address newRecipient);\n event SetMarketLenderAttestation(uint256 marketId, bool required);\n event SetMarketBorrowerAttestation(uint256 marketId, bool required);\n event SetMarketPaymentType(uint256 marketId, PaymentType paymentType);\n\n /* External Functions */\n\n function initialize(TellerAS _tellerAS) external initializer {\n tellerAS = _tellerAS;\n\n lenderAttestationSchemaId = tellerAS.getASRegistry().register(\n \"(uint256 marketId, address lenderAddress)\",\n this\n );\n borrowerAttestationSchemaId = tellerAS.getASRegistry().register(\n \"(uint256 marketId, address borrowerAddress)\",\n this\n );\n }\n\n /**\n * @notice Sets the new tellerAS on upgrade\n */\n function onUpgrade() external {\n require(\n version != CURRENT_CODE_VERSION,\n \"Contract already upgraded to latest version!\"\n );\n version = CURRENT_CODE_VERSION;\n }\n\n /**\n * @notice Creates a new market.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _paymentType The payment type for loans in the market.\n * @param _uri URI string to get metadata details about the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @return marketId_ The market ID of the newly created market.\n */\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) external returns (uint256 marketId_) {\n marketId_ = _createMarket(\n _initialOwner,\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n _paymentCycleType,\n _uri\n );\n }\n\n /**\n * @notice Creates a new market.\n * @dev Uses the default EMI payment type.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _uri URI string to get metadata details about the market.\n * @return marketId_ The market ID of the newly created market.\n */\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) external returns (uint256 marketId_) {\n marketId_ = _createMarket(\n _initialOwner,\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n _uri\n );\n }\n\n /**\n * @notice Creates a new market.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _paymentType The payment type for loans in the market.\n * @param _uri URI string to get metadata details about the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @return marketId_ The market ID of the newly created market.\n */\n function _createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) internal returns (uint256 marketId_) {\n require(_initialOwner != address(0), \"Invalid owner address\");\n // Increment market ID counter\n marketId_ = ++marketCount;\n\n // Set the market owner\n markets[marketId_].owner = _initialOwner;\n\n // Initialize market settings\n _setMarketSettings(\n marketId_,\n _paymentCycleDuration,\n _paymentType,\n _paymentCycleType,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireBorrowerAttestation,\n _requireLenderAttestation,\n _uri\n );\n\n emit MarketCreated(_initialOwner, marketId_);\n }\n\n /**\n * @notice Closes a market so new bids cannot be added.\n * @param _marketId The market ID for the market to close.\n */\n\n function closeMarket(uint256 _marketId) public ownsMarket(_marketId) {\n if (!marketIsClosed[_marketId]) {\n marketIsClosed[_marketId] = true;\n\n emit MarketClosed(_marketId);\n }\n }\n\n /**\n * @notice Returns the status of a market being open or closed for new bids.\n * @param _marketId The market ID for the market to check.\n */\n function isMarketClosed(uint256 _marketId)\n public\n view\n override\n returns (bool)\n {\n return marketIsClosed[_marketId];\n }\n\n /**\n * @notice Adds a lender to a market.\n * @dev See {_attestStakeholder}.\n */\n function attestLender(\n uint256 _marketId,\n address _lenderAddress,\n uint256 _expirationTime\n ) external {\n _attestStakeholder(_marketId, _lenderAddress, _expirationTime, true);\n }\n\n /**\n * @notice Adds a lender to a market via delegated attestation.\n * @dev See {_attestStakeholderViaDelegation}.\n */\n function attestLender(\n uint256 _marketId,\n address _lenderAddress,\n uint256 _expirationTime,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _attestStakeholderViaDelegation(\n _marketId,\n _lenderAddress,\n _expirationTime,\n true,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Removes a lender from an market.\n * @dev See {_revokeStakeholder}.\n */\n function revokeLender(uint256 _marketId, address _lenderAddress) external {\n _revokeStakeholder(_marketId, _lenderAddress, true);\n }\n\n /**\n * @notice Removes a borrower from a market via delegated revocation.\n * @dev See {_revokeStakeholderViaDelegation}.\n */\n function revokeLender(\n uint256 _marketId,\n address _lenderAddress,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _revokeStakeholderViaDelegation(\n _marketId,\n _lenderAddress,\n true,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Allows a lender to voluntarily leave a market.\n * @param _marketId The market ID to leave.\n */\n function lenderExitMarket(uint256 _marketId) external {\n // Remove lender address from market set\n bool response = markets[_marketId].verifiedLendersForMarket.remove(\n _msgSender()\n );\n if (response) {\n emit LenderExitMarket(_marketId, _msgSender());\n }\n }\n\n /**\n * @notice Adds a borrower to a market.\n * @dev See {_attestStakeholder}.\n */\n function attestBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint256 _expirationTime\n ) external {\n _attestStakeholder(_marketId, _borrowerAddress, _expirationTime, false);\n }\n\n /**\n * @notice Adds a borrower to a market via delegated attestation.\n * @dev See {_attestStakeholderViaDelegation}.\n */\n function attestBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint256 _expirationTime,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _attestStakeholderViaDelegation(\n _marketId,\n _borrowerAddress,\n _expirationTime,\n false,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Removes a borrower from an market.\n * @dev See {_revokeStakeholder}.\n */\n function revokeBorrower(uint256 _marketId, address _borrowerAddress)\n external\n {\n _revokeStakeholder(_marketId, _borrowerAddress, false);\n }\n\n /**\n * @notice Removes a borrower from a market via delegated revocation.\n * @dev See {_revokeStakeholderViaDelegation}.\n */\n function revokeBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _revokeStakeholderViaDelegation(\n _marketId,\n _borrowerAddress,\n false,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Allows a borrower to voluntarily leave a market.\n * @param _marketId The market ID to leave.\n */\n function borrowerExitMarket(uint256 _marketId) external {\n // Remove borrower address from market set\n bool response = markets[_marketId].verifiedBorrowersForMarket.remove(\n _msgSender()\n );\n if (response) {\n emit BorrowerExitMarket(_marketId, _msgSender());\n }\n }\n\n /**\n * @notice Verifies an attestation is valid.\n * @dev This function must only be called by the `attestLender` function above.\n * @param recipient Lender's address who is being attested.\n * @param schema The schema used for the attestation.\n * @param data Data the must include the market ID and lender's address\n * @param\n * @param attestor Market owner's address who signed the attestation.\n * @return Boolean indicating the attestation was successful.\n */\n function resolve(\n address recipient,\n bytes calldata schema,\n bytes calldata data,\n uint256 /* expirationTime */,\n address attestor\n ) external payable override returns (bool) {\n bytes32 attestationSchemaId = keccak256(\n abi.encodePacked(schema, address(this))\n );\n (uint256 marketId, address lenderAddress) = abi.decode(\n data,\n (uint256, address)\n );\n return\n (_attestingSchemaId == attestationSchemaId &&\n recipient == lenderAddress &&\n attestor == markets[marketId].owner) ||\n attestor == address(this);\n }\n\n /**\n * @notice Transfers ownership of a marketplace.\n * @param _marketId The ID of a market.\n * @param _newOwner Address of the new market owner.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function transferMarketOwnership(uint256 _marketId, address _newOwner)\n public\n ownsMarket(_marketId)\n {\n markets[_marketId].owner = _newOwner;\n emit SetMarketOwner(_marketId, _newOwner);\n }\n\n /**\n * @notice Updates multiple market settings for a given market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleDuration Delinquency duration for new loans\n * @param _newPaymentType The payment type for the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @param _paymentDefaultDuration Default duration for new loans\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\n * @param _metadataURI A URI that points to a market's metadata.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function updateMarketSettings(\n uint256 _marketId,\n uint32 _paymentCycleDuration,\n PaymentType _newPaymentType,\n PaymentCycleType _paymentCycleType,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _borrowerAttestationRequired,\n bool _lenderAttestationRequired,\n string calldata _metadataURI\n ) public ownsMarket(_marketId) {\n _setMarketSettings(\n _marketId,\n _paymentCycleDuration,\n _newPaymentType,\n _paymentCycleType,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _borrowerAttestationRequired,\n _lenderAttestationRequired,\n _metadataURI\n );\n }\n\n /**\n * @notice Sets the fee recipient address for a market.\n * @param _marketId The ID of a market.\n * @param _recipient Address of the new fee recipient.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketFeeRecipient(uint256 _marketId, address _recipient)\n public\n ownsMarket(_marketId)\n {\n markets[_marketId].feeRecipient = _recipient;\n emit SetMarketFeeRecipient(_marketId, _recipient);\n }\n\n /**\n * @notice Sets the metadata URI for a market.\n * @param _marketId The ID of a market.\n * @param _uri A URI that points to a market's metadata.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketURI(uint256 _marketId, string calldata _uri)\n public\n ownsMarket(_marketId)\n {\n //We do string comparison by checking the hashes of the strings against one another\n if (\n keccak256(abi.encodePacked(_uri)) !=\n keccak256(abi.encodePacked(markets[_marketId].metadataURI))\n ) {\n markets[_marketId].metadataURI = _uri;\n\n emit SetMarketURI(_marketId, _uri);\n }\n }\n\n /**\n * @notice Sets the duration of new loans for this market before they turn delinquent.\n * @notice Changing this value does not change the terms of existing loans for this market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleType Cycle type (seconds or monthly)\n * @param _duration Delinquency duration for new loans\n */\n function setPaymentCycle(\n uint256 _marketId,\n PaymentCycleType _paymentCycleType,\n uint32 _duration\n ) public ownsMarket(_marketId) {\n require(\n (_paymentCycleType == PaymentCycleType.Seconds) ||\n (_paymentCycleType == PaymentCycleType.Monthly &&\n _duration == 0),\n \"monthly payment cycle duration cannot be set\"\n );\n Marketplace storage market = markets[_marketId];\n uint32 duration = _paymentCycleType == PaymentCycleType.Seconds\n ? _duration\n : 30 days;\n if (\n _paymentCycleType != market.paymentCycleType ||\n duration != market.paymentCycleDuration\n ) {\n markets[_marketId].paymentCycleType = _paymentCycleType;\n markets[_marketId].paymentCycleDuration = duration;\n\n emit SetPaymentCycle(_marketId, _paymentCycleType, duration);\n }\n }\n\n /**\n * @notice Sets the duration of new loans for this market before they turn defaulted.\n * @notice Changing this value does not change the terms of existing loans for this market.\n * @param _marketId The ID of a market.\n * @param _duration Default duration for new loans\n */\n function setPaymentDefaultDuration(uint256 _marketId, uint32 _duration)\n public\n ownsMarket(_marketId)\n {\n if (_duration != markets[_marketId].paymentDefaultDuration) {\n markets[_marketId].paymentDefaultDuration = _duration;\n\n emit SetPaymentDefaultDuration(_marketId, _duration);\n }\n }\n\n function setBidExpirationTime(uint256 _marketId, uint32 _duration)\n public\n ownsMarket(_marketId)\n {\n if (_duration != markets[_marketId].bidExpirationTime) {\n markets[_marketId].bidExpirationTime = _duration;\n\n emit SetBidExpirationTime(_marketId, _duration);\n }\n }\n\n /**\n * @notice Sets the fee for the market.\n * @param _marketId The ID of a market.\n * @param _newPercent The percentage fee in basis points.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketFeePercent(uint256 _marketId, uint16 _newPercent)\n public\n ownsMarket(_marketId)\n {\n require(_newPercent >= 0 && _newPercent <= 10000, \"invalid percent\");\n if (_newPercent != markets[_marketId].marketplaceFeePercent) {\n markets[_marketId].marketplaceFeePercent = _newPercent;\n emit SetMarketFee(_marketId, _newPercent);\n }\n }\n\n /**\n * @notice Set the payment type for the market.\n * @param _marketId The ID of the market.\n * @param _newPaymentType The payment type for the market.\n */\n function setMarketPaymentType(\n uint256 _marketId,\n PaymentType _newPaymentType\n ) public ownsMarket(_marketId) {\n if (_newPaymentType != markets[_marketId].paymentType) {\n markets[_marketId].paymentType = _newPaymentType;\n emit SetMarketPaymentType(_marketId, _newPaymentType);\n }\n }\n\n /**\n * @notice Enable/disables market whitelist for lenders.\n * @param _marketId The ID of a market.\n * @param _required Boolean indicating if the market requires whitelist.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setLenderAttestationRequired(uint256 _marketId, bool _required)\n public\n ownsMarket(_marketId)\n {\n if (_required != markets[_marketId].lenderAttestationRequired) {\n markets[_marketId].lenderAttestationRequired = _required;\n emit SetMarketLenderAttestation(_marketId, _required);\n }\n }\n\n /**\n * @notice Enable/disables market whitelist for borrowers.\n * @param _marketId The ID of a market.\n * @param _required Boolean indicating if the market requires whitelist.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setBorrowerAttestationRequired(uint256 _marketId, bool _required)\n public\n ownsMarket(_marketId)\n {\n if (_required != markets[_marketId].borrowerAttestationRequired) {\n markets[_marketId].borrowerAttestationRequired = _required;\n emit SetMarketBorrowerAttestation(_marketId, _required);\n }\n }\n\n /**\n * @notice Gets the data associated with a market.\n * @param _marketId The ID of a market.\n */\n function getMarketData(uint256 _marketId)\n public\n view\n returns (\n address owner,\n uint32 paymentCycleDuration,\n uint32 paymentDefaultDuration,\n uint32 loanExpirationTime,\n string memory metadataURI,\n uint16 marketplaceFeePercent,\n bool lenderAttestationRequired\n )\n {\n return (\n markets[_marketId].owner,\n markets[_marketId].paymentCycleDuration,\n markets[_marketId].paymentDefaultDuration,\n markets[_marketId].bidExpirationTime,\n markets[_marketId].metadataURI,\n markets[_marketId].marketplaceFeePercent,\n markets[_marketId].lenderAttestationRequired\n );\n }\n\n /**\n * @notice Gets the attestation requirements for a given market.\n * @param _marketId The ID of the market.\n */\n function getMarketAttestationRequirements(uint256 _marketId)\n public\n view\n returns (\n bool lenderAttestationRequired,\n bool borrowerAttestationRequired\n )\n {\n return (\n markets[_marketId].lenderAttestationRequired,\n markets[_marketId].borrowerAttestationRequired\n );\n }\n\n /**\n * @notice Gets the address of a market's owner.\n * @param _marketId The ID of a market.\n * @return The address of a market's owner.\n */\n function getMarketOwner(uint256 _marketId)\n public\n view\n override\n returns (address)\n {\n return markets[_marketId].owner;\n }\n\n /**\n * @notice Gets the fee recipient of a market.\n * @param _marketId The ID of a market.\n * @return The address of a market's fee recipient.\n */\n function getMarketFeeRecipient(uint256 _marketId)\n public\n view\n override\n returns (address)\n {\n address recipient = markets[_marketId].feeRecipient;\n\n if (recipient == address(0)) {\n return markets[_marketId].owner;\n }\n\n return recipient;\n }\n\n /**\n * @notice Gets the metadata URI of a market.\n * @param _marketId The ID of a market.\n * @return URI of a market's metadata.\n */\n function getMarketURI(uint256 _marketId)\n public\n view\n override\n returns (string memory)\n {\n return markets[_marketId].metadataURI;\n }\n\n /**\n * @notice Gets the loan delinquent duration of a market.\n * @param _marketId The ID of a market.\n * @return Duration of a loan until it is delinquent.\n * @return The type of payment cycle for loans in the market.\n */\n function getPaymentCycle(uint256 _marketId)\n public\n view\n override\n returns (uint32, PaymentCycleType)\n {\n return (\n markets[_marketId].paymentCycleDuration,\n markets[_marketId].paymentCycleType\n );\n }\n\n /**\n * @notice Gets the loan default duration of a market.\n * @param _marketId The ID of a market.\n * @return Duration of a loan repayment interval until it is default.\n */\n function getPaymentDefaultDuration(uint256 _marketId)\n public\n view\n override\n returns (uint32)\n {\n return markets[_marketId].paymentDefaultDuration;\n }\n\n /**\n * @notice Get the payment type of a market.\n * @param _marketId the ID of the market.\n * @return The type of payment for loans in the market.\n */\n function getPaymentType(uint256 _marketId)\n public\n view\n override\n returns (PaymentType)\n {\n return markets[_marketId].paymentType;\n }\n\n function getBidExpirationTime(uint256 marketId)\n public\n view\n override\n returns (uint32)\n {\n return markets[marketId].bidExpirationTime;\n }\n\n /**\n * @notice Gets the marketplace fee in basis points\n * @param _marketId The ID of a market.\n * @return fee in basis points\n */\n function getMarketplaceFee(uint256 _marketId)\n public\n view\n override\n returns (uint16 fee)\n {\n return markets[_marketId].marketplaceFeePercent;\n }\n\n /**\n * @notice Checks if a lender has been attested and added to a market.\n * @param _marketId The ID of a market.\n * @param _lenderAddress Address to check.\n * @return isVerified_ Boolean indicating if a lender has been added to a market.\n * @return uuid_ Bytes32 representing the UUID of the lender.\n */\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\n public\n view\n override\n returns (bool isVerified_, bytes32 uuid_)\n {\n return\n _isVerified(\n _lenderAddress,\n markets[_marketId].lenderAttestationRequired,\n markets[_marketId].lenderAttestationIds,\n markets[_marketId].verifiedLendersForMarket\n );\n }\n\n /**\n * @notice Checks if a borrower has been attested and added to a market.\n * @param _marketId The ID of a market.\n * @param _borrowerAddress Address of the borrower to check.\n * @return isVerified_ Boolean indicating if a borrower has been added to a market.\n * @return uuid_ Bytes32 representing the UUID of the borrower.\n */\n function isVerifiedBorrower(uint256 _marketId, address _borrowerAddress)\n public\n view\n override\n returns (bool isVerified_, bytes32 uuid_)\n {\n return\n _isVerified(\n _borrowerAddress,\n markets[_marketId].borrowerAttestationRequired,\n markets[_marketId].borrowerAttestationIds,\n markets[_marketId].verifiedBorrowersForMarket\n );\n }\n\n /**\n * @notice Gets addresses of all attested lenders.\n * @param _marketId The ID of a market.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return Array of addresses that have been added to a market.\n */\n function getAllVerifiedLendersForMarket(\n uint256 _marketId,\n uint256 _page,\n uint256 _perPage\n ) public view returns (address[] memory) {\n EnumerableSet.AddressSet storage set = markets[_marketId]\n .verifiedLendersForMarket;\n\n return _getStakeholdersForMarket(set, _page, _perPage);\n }\n\n /**\n * @notice Gets addresses of all attested borrowers.\n * @param _marketId The ID of the market.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return Array of addresses that have been added to a market.\n */\n function getAllVerifiedBorrowersForMarket(\n uint256 _marketId,\n uint256 _page,\n uint256 _perPage\n ) public view returns (address[] memory) {\n EnumerableSet.AddressSet storage set = markets[_marketId]\n .verifiedBorrowersForMarket;\n return _getStakeholdersForMarket(set, _page, _perPage);\n }\n\n /**\n * @notice Sets multiple market settings for a given market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleDuration Delinquency duration for new loans\n * @param _newPaymentType The payment type for the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @param _paymentDefaultDuration Default duration for new loans\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\n * @param _metadataURI A URI that points to a market's metadata.\n */\n function _setMarketSettings(\n uint256 _marketId,\n uint32 _paymentCycleDuration,\n PaymentType _newPaymentType,\n PaymentCycleType _paymentCycleType,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _borrowerAttestationRequired,\n bool _lenderAttestationRequired,\n string calldata _metadataURI\n ) internal {\n setMarketURI(_marketId, _metadataURI);\n setPaymentDefaultDuration(_marketId, _paymentDefaultDuration);\n setBidExpirationTime(_marketId, _bidExpirationTime);\n setMarketFeePercent(_marketId, _feePercent);\n setLenderAttestationRequired(_marketId, _lenderAttestationRequired);\n setBorrowerAttestationRequired(_marketId, _borrowerAttestationRequired);\n setMarketPaymentType(_marketId, _newPaymentType);\n setPaymentCycle(_marketId, _paymentCycleType, _paymentCycleDuration);\n }\n\n /**\n * @notice Gets addresses of all attested relevant stakeholders.\n * @param _set The stored set of stakeholders to index from.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return stakeholders_ Array of addresses that have been added to a market.\n */\n function _getStakeholdersForMarket(\n EnumerableSet.AddressSet storage _set,\n uint256 _page,\n uint256 _perPage\n ) internal view returns (address[] memory stakeholders_) {\n uint256 len = _set.length();\n\n uint256 start = _page * _perPage;\n if (start <= len) {\n uint256 end = start + _perPage;\n // Ensure we do not go out of bounds\n if (end > len) {\n end = len;\n }\n\n stakeholders_ = new address[](end - start);\n for (uint256 i = start; i < end; i++) {\n stakeholders_[i] = _set.at(i);\n }\n }\n }\n\n /* Internal Functions */\n\n /**\n * @notice Adds a stakeholder (lender or borrower) to a market.\n * @param _marketId The market ID to add a borrower to.\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\n * @param _expirationTime The expiration time of the attestation.\n * @param _expirationTime The expiration time of the attestation.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _attestStakeholder(\n uint256 _marketId,\n address _stakeholderAddress,\n uint256 _expirationTime,\n bool _isLender\n )\n internal\n withAttestingSchema(\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\n )\n {\n require(\n _msgSender() == markets[_marketId].owner,\n \"Not the market owner\"\n );\n\n // Submit attestation for borrower to join a market\n bytes32 uuid = tellerAS.attest(\n _stakeholderAddress,\n _attestingSchemaId, // set by the modifier\n _expirationTime,\n 0,\n abi.encode(_marketId, _stakeholderAddress)\n );\n _attestStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n uuid,\n _isLender\n );\n }\n\n /**\n * @notice Adds a stakeholder (lender or borrower) to a market via delegated attestation.\n * @dev The signature must match that of the market owner.\n * @param _marketId The market ID to add a lender to.\n * @param _stakeholderAddress The address of the lender to add to the market.\n * @param _expirationTime The expiration time of the attestation.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @param _v Signature value\n * @param _r Signature value\n * @param _s Signature value\n */\n function _attestStakeholderViaDelegation(\n uint256 _marketId,\n address _stakeholderAddress,\n uint256 _expirationTime,\n bool _isLender,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n internal\n withAttestingSchema(\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\n )\n {\n // NOTE: block scope to prevent stack too deep!\n bytes32 uuid;\n {\n bytes memory data = abi.encode(_marketId, _stakeholderAddress);\n address attestor = markets[_marketId].owner;\n // Submit attestation for stakeholder to join a market (attestation must be signed by market owner)\n uuid = tellerAS.attestByDelegation(\n _stakeholderAddress,\n _attestingSchemaId, // set by the modifier\n _expirationTime,\n 0,\n data,\n attestor,\n _v,\n _r,\n _s\n );\n }\n _attestStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n uuid,\n _isLender\n );\n }\n\n /**\n * @notice Adds a stakeholder (borrower/lender) to a market.\n * @param _marketId The market ID to add a stakeholder to.\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\n * @param _uuid The UUID of the attestation created.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _attestStakeholderVerification(\n uint256 _marketId,\n address _stakeholderAddress,\n bytes32 _uuid,\n bool _isLender\n ) internal {\n if (_isLender) {\n // Store the lender attestation ID for the market ID\n markets[_marketId].lenderAttestationIds[\n _stakeholderAddress\n ] = _uuid;\n // Add lender address to market set\n markets[_marketId].verifiedLendersForMarket.add(\n _stakeholderAddress\n );\n\n emit LenderAttestation(_marketId, _stakeholderAddress);\n } else {\n // Store the lender attestation ID for the market ID\n markets[_marketId].borrowerAttestationIds[\n _stakeholderAddress\n ] = _uuid;\n // Add lender address to market set\n markets[_marketId].verifiedBorrowersForMarket.add(\n _stakeholderAddress\n );\n\n emit BorrowerAttestation(_marketId, _stakeholderAddress);\n }\n }\n\n /**\n * @notice Removes a stakeholder from an market.\n * @dev The caller must be the market owner.\n * @param _marketId The market ID to remove the borrower from.\n * @param _stakeholderAddress The address of the borrower to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _revokeStakeholder(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender\n ) internal {\n require(\n _msgSender() == markets[_marketId].owner,\n \"Not the market owner\"\n );\n\n bytes32 uuid = _revokeStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n _isLender\n );\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\n // tellerAS.revoke(uuid);\n }\n\n /**\n * @notice Removes a stakeholder from an market via delegated revocation.\n * @param _marketId The market ID to remove the borrower from.\n * @param _stakeholderAddress The address of the borrower to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @param _v Signature value\n * @param _r Signature value\n * @param _s Signature value\n */\n function _revokeStakeholderViaDelegation(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) internal {\n bytes32 uuid = _revokeStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n _isLender\n );\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\n // address attestor = markets[_marketId].owner;\n // tellerAS.revokeByDelegation(uuid, attestor, _v, _r, _s);\n }\n\n /**\n * @notice Removes a stakeholder (borrower/lender) from a market.\n * @param _marketId The market ID to remove the lender from.\n * @param _stakeholderAddress The address of the stakeholder to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @return uuid_ The ID of the previously verified attestation.\n */\n function _revokeStakeholderVerification(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender\n ) internal returns (bytes32 uuid_) {\n if (_isLender) {\n uuid_ = markets[_marketId].lenderAttestationIds[\n _stakeholderAddress\n ];\n // Remove lender address from market set\n markets[_marketId].verifiedLendersForMarket.remove(\n _stakeholderAddress\n );\n\n emit LenderRevocation(_marketId, _stakeholderAddress);\n } else {\n uuid_ = markets[_marketId].borrowerAttestationIds[\n _stakeholderAddress\n ];\n // Remove borrower address from market set\n markets[_marketId].verifiedBorrowersForMarket.remove(\n _stakeholderAddress\n );\n\n emit BorrowerRevocation(_marketId, _stakeholderAddress);\n }\n }\n\n /**\n * @notice Checks if a stakeholder has been attested and added to a market.\n * @param _stakeholderAddress Address of the stakeholder to check.\n * @param _attestationRequired Stored boolean indicating if attestation is required for the stakeholder class.\n * @param _stakeholderAttestationIds Mapping of attested Ids for the stakeholder class.\n */\n function _isVerified(\n address _stakeholderAddress,\n bool _attestationRequired,\n mapping(address => bytes32) storage _stakeholderAttestationIds,\n EnumerableSet.AddressSet storage _verifiedStakeholderForMarket\n ) internal view returns (bool isVerified_, bytes32 uuid_) {\n if (_attestationRequired) {\n isVerified_ =\n _verifiedStakeholderForMarket.contains(_stakeholderAddress) &&\n tellerAS.isAttestationActive(\n _stakeholderAttestationIds[_stakeholderAddress]\n );\n uuid_ = _stakeholderAttestationIds[_stakeholderAddress];\n } else {\n isVerified_ = true;\n }\n }\n}\n" - }, - "contracts/ReputationManager.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n// Interfaces\nimport \"./interfaces/IReputationManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract ReputationManager is IReputationManager, Initializable {\n using EnumerableSet for EnumerableSet.UintSet;\n\n bytes32 public constant CONTROLLER = keccak256(\"CONTROLLER\");\n\n ITellerV2 public tellerV2;\n mapping(address => EnumerableSet.UintSet) private _delinquencies;\n mapping(address => EnumerableSet.UintSet) private _defaults;\n mapping(address => EnumerableSet.UintSet) private _currentDelinquencies;\n mapping(address => EnumerableSet.UintSet) private _currentDefaults;\n\n event MarkAdded(\n address indexed account,\n RepMark indexed repMark,\n uint256 bidId\n );\n event MarkRemoved(\n address indexed account,\n RepMark indexed repMark,\n uint256 bidId\n );\n\n /**\n * @notice Initializes the proxy.\n */\n function initialize(address _tellerV2) external initializer {\n tellerV2 = ITellerV2(_tellerV2);\n }\n\n function getDelinquentLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _delinquencies[_account].values();\n }\n\n function getDefaultedLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _defaults[_account].values();\n }\n\n function getCurrentDelinquentLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _currentDelinquencies[_account].values();\n }\n\n function getCurrentDefaultLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _currentDefaults[_account].values();\n }\n\n function updateAccountReputation(address _account) public override {\n uint256[] memory activeBidIds = tellerV2.getBorrowerActiveLoanIds(\n _account\n );\n for (uint256 i; i < activeBidIds.length; i++) {\n _applyReputation(_account, activeBidIds[i]);\n }\n }\n\n function updateAccountReputation(address _account, uint256 _bidId)\n public\n override\n returns (RepMark)\n {\n return _applyReputation(_account, _bidId);\n }\n\n function _applyReputation(address _account, uint256 _bidId)\n internal\n returns (RepMark mark_)\n {\n mark_ = RepMark.Good;\n\n if (tellerV2.isLoanDefaulted(_bidId)) {\n mark_ = RepMark.Default;\n\n // Remove delinquent status\n _removeMark(_account, _bidId, RepMark.Delinquent);\n } else if (tellerV2.isPaymentLate(_bidId)) {\n mark_ = RepMark.Delinquent;\n }\n\n // Mark status if not \"Good\"\n if (mark_ != RepMark.Good) {\n _addMark(_account, _bidId, mark_);\n }\n }\n\n function _addMark(address _account, uint256 _bidId, RepMark _mark)\n internal\n {\n if (_mark == RepMark.Delinquent) {\n _delinquencies[_account].add(_bidId);\n _currentDelinquencies[_account].add(_bidId);\n } else if (_mark == RepMark.Default) {\n _defaults[_account].add(_bidId);\n _currentDefaults[_account].add(_bidId);\n }\n\n emit MarkAdded(_account, _mark, _bidId);\n }\n\n function _removeMark(address _account, uint256 _bidId, RepMark _mark)\n internal\n {\n if (_mark == RepMark.Delinquent) {\n _currentDelinquencies[_account].remove(_bidId);\n } else if (_mark == RepMark.Default) {\n _currentDefaults[_account].remove(_bidId);\n }\n\n emit MarkRemoved(_account, _mark, _bidId);\n }\n}\n" - }, - "contracts/mock/WethMock.sol": { - "content": "/**\n *Submitted for verification at Etherscan.io on 2017-12-12\n */\n\n// Copyright (C) 2015, 2016, 2017 Dapphub\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\ncontract WethMock {\n string public name = \"Wrapped Ether\";\n string public symbol = \"WETH\";\n uint8 public decimals = 18;\n\n event Approval(address indexed src, address indexed guy, uint256 wad);\n event Transfer(address indexed src, address indexed dst, uint256 wad);\n event Deposit(address indexed dst, uint256 wad);\n event Withdrawal(address indexed src, uint256 wad);\n\n mapping(address => uint256) public balanceOf;\n mapping(address => mapping(address => uint256)) public allowance;\n\n function deposit() public payable {\n balanceOf[msg.sender] += msg.value;\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 wad) public {\n require(balanceOf[msg.sender] >= wad);\n balanceOf[msg.sender] -= wad;\n payable(msg.sender).transfer(wad);\n emit Withdrawal(msg.sender, wad);\n }\n\n function totalSupply() public view returns (uint256) {\n return address(this).balance;\n }\n\n function approve(address guy, uint256 wad) public returns (bool) {\n allowance[msg.sender][guy] = wad;\n emit Approval(msg.sender, guy, wad);\n return true;\n }\n\n function transfer(address dst, uint256 wad) public returns (bool) {\n return transferFrom(msg.sender, dst, wad);\n }\n\n function transferFrom(address src, address dst, uint256 wad)\n public\n returns (bool)\n {\n require(balanceOf[src] >= wad, \"insufficient balance\");\n\n if (src != msg.sender) {\n require(\n allowance[src][msg.sender] >= wad,\n \"insufficient allowance\"\n );\n allowance[src][msg.sender] -= wad;\n }\n\n balanceOf[src] -= wad;\n balanceOf[dst] += wad;\n\n emit Transfer(src, dst, wad);\n\n return true;\n }\n}\n" - }, - "contracts/interfaces/IWETH.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @notice It is the interface of functions that we use for the canonical WETH contract.\n *\n * @author develop@teller.finance\n */\ninterface IWETH {\n /**\n * @notice It withdraws ETH from the contract by sending it to the caller and reducing the caller's internal balance of WETH.\n * @param amount The amount of ETH to withdraw.\n */\n function withdraw(uint256 amount) external;\n\n /**\n * @notice It deposits ETH into the contract and increases the caller's internal balance of WETH.\n */\n function deposit() external payable;\n\n /**\n * @notice It gets the ETH deposit balance of an {account}.\n * @param account Address to get balance of.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @notice It transfers the WETH amount specified to the given {account}.\n * @param to Address to transfer to\n * @param value Amount of WETH to transfer\n */\n function transfer(address to, uint256 value) external returns (bool);\n}\n" - }, - "contracts/tests/Test_Helpers.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/ITellerV2.sol\";\nimport \"../interfaces/ITellerV2Context.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ncontract User {\n address public immutable tellerV2;\n\n constructor(address _tellerV2 /*, WethMock _wethMock*/) {\n tellerV2 = _tellerV2;\n }\n\n function addAllowance(\n address _assetContractAddress,\n address _spender,\n uint256 _amount\n ) public {\n IERC20(_assetContractAddress).approve(_spender, _amount);\n }\n\n function createMarket(\n address marketRegistry,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) public returns (uint256) {\n return\n IMarketRegistry(marketRegistry).createMarket(\n address(this),\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n _paymentCycleType,\n _uri\n );\n }\n\n function acceptBid(uint256 _bidId) public {\n ITellerV2(tellerV2).lenderAcceptBid(_bidId);\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n function submitCollateralBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver,\n _collateralInfo\n );\n }\n\n function repayLoanFull(uint256 _bidId) public {\n return ITellerV2(tellerV2).repayLoanFull(_bidId);\n }\n\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n ITellerV2Context(tellerV2).setTrustedMarketForwarder(\n _marketId,\n _forwarder\n );\n }\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n ITellerV2Context(tellerV2).approveMarketForwarder(\n _marketId,\n _forwarder\n );\n }\n\n receive() external payable {}\n}\n" - }, - "contracts/escrow/CollateralEscrowV1.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\n// Interfaces\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\";\nimport \"../interfaces/escrow/ICollateralEscrowV1.sol\";\n\ncontract CollateralEscrowV1 is OwnableUpgradeable, ICollateralEscrowV1 {\n uint256 public bidId;\n /* Mappings */\n mapping(address => Collateral) public collateralBalances; // collateral address -> collateral\n\n /* Events */\n event CollateralDeposited(address _collateralAddress, uint256 _amount);\n event CollateralWithdrawn(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n );\n\n /**\n * @notice Initializes an escrow.\n * @notice The id of the associated bid.\n */\n function initialize(uint256 _bidId) public initializer {\n __Ownable_init();\n bidId = _bidId;\n }\n\n function getBid() external view returns (uint256) {\n return bidId;\n }\n\n /**\n * @notice Deposits a collateral ERC20 token into the escrow.\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositToken(address _collateralAddress, uint256 _amount)\n external\n onlyOwner\n {\n require(_amount > 0, \"Deposit amount cannot be zero\");\n _depositCollateral(\n CollateralType.ERC20,\n _collateralAddress,\n _amount,\n 0\n );\n Collateral storage collateral = collateralBalances[_collateralAddress];\n collateral._collateralType = CollateralType.ERC20;\n collateral._amount = _amount;\n emit CollateralDeposited(_collateralAddress, _amount);\n }\n\n /**\n * @notice Deposits a collateral asset into the escrow.\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositAsset(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) external payable onlyOwner {\n require(_amount > 0, \"Deposit amount cannot be zero\");\n _depositCollateral(\n _collateralType,\n _collateralAddress,\n _amount,\n _tokenId\n );\n Collateral storage collateral = collateralBalances[_collateralAddress];\n collateral._collateralType = _collateralType;\n collateral._amount = _amount;\n collateral._tokenId = _tokenId;\n emit CollateralDeposited(_collateralAddress, _amount);\n }\n\n /**\n * @notice Withdraws a collateral asset from the escrow.\n * @param _collateralAddress The address of the collateral contract.\n * @param _amount The amount to withdraw.\n * @param _recipient The address to send the assets to.\n */\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) external onlyOwner {\n require(_amount > 0, \"Withdraw amount cannot be zero\");\n Collateral storage collateral = collateralBalances[_collateralAddress];\n require(\n collateral._amount >= _amount,\n \"No collateral balance for asset\"\n );\n _withdrawCollateral(\n collateral,\n _collateralAddress,\n _amount,\n _recipient\n );\n collateral._amount -= _amount;\n emit CollateralWithdrawn(_collateralAddress, _amount, _recipient);\n }\n\n function _depositCollateral(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) internal {\n // Deposit ERC20\n if (_collateralType == CollateralType.ERC20) {\n SafeERC20Upgradeable.safeTransferFrom(\n IERC20Upgradeable(_collateralAddress),\n _msgSender(),\n address(this),\n _amount\n );\n }\n // Deposit ERC721\n else if (_collateralType == CollateralType.ERC721) {\n require(_amount == 1, \"Incorrect deposit amount\");\n IERC721Upgradeable(_collateralAddress).transferFrom(\n _msgSender(),\n address(this),\n _tokenId\n );\n }\n // Deposit ERC1155\n else if (_collateralType == CollateralType.ERC1155) {\n bytes memory data;\n\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\n _msgSender(),\n address(this),\n _tokenId,\n _amount,\n data\n );\n }\n }\n\n function _withdrawCollateral(\n Collateral memory _collateral,\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) internal {\n // Withdraw ERC20\n if (_collateral._collateralType == CollateralType.ERC20) {\n IERC20Upgradeable(_collateralAddress).transfer(\n _recipient,\n _collateral._amount\n );\n }\n // Withdraw ERC721\n else if (_collateral._collateralType == CollateralType.ERC721) {\n require(_amount == 1, \"Incorrect withdrawal amount\");\n IERC721Upgradeable(_collateralAddress).transferFrom(\n address(this),\n _recipient,\n _collateral._tokenId\n );\n }\n // Withdraw ERC1155\n else if (_collateral._collateralType == CollateralType.ERC1155) {\n bytes memory data;\n\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\n address(this),\n _recipient,\n _collateral._tokenId,\n _amount,\n data\n );\n }\n }\n\n // On NFT Received handlers\n\n function onERC721Received(address, address, uint256, bytes calldata)\n external\n pure\n returns (bytes4)\n {\n return\n bytes4(\n keccak256(\"onERC721Received(address,address,uint256,bytes)\")\n );\n }\n\n function onERC1155Received(\n address,\n address,\n uint256 id,\n uint256 value,\n bytes calldata\n ) external returns (bytes4) {\n return\n bytes4(\n keccak256(\n \"onERC1155Received(address,address,uint256,uint256,bytes)\"\n )\n );\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata _ids,\n uint256[] calldata _values,\n bytes calldata\n ) external returns (bytes4) {\n require(\n _ids.length == 1,\n \"Only allowed one asset batch transfer per transaction.\"\n );\n return\n bytes4(\n keccak256(\n \"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"\n )\n );\n }\n}\n" - }, - "contracts/LenderCommitmentForwarder.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./TellerV2MarketForwarder.sol\";\n\n// Interfaces\nimport \"./interfaces/ICollateralManager.sol\";\nimport { Collateral, CollateralType } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n// Libraries\nimport { MathUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\ncontract LenderCommitmentForwarder is TellerV2MarketForwarder {\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n\n enum CommitmentCollateralType {\n NONE, // no collateral required\n ERC20,\n ERC721,\n ERC1155,\n ERC721_ANY_ID,\n ERC1155_ANY_ID\n }\n\n /**\n * @notice Details about a lender's capital commitment.\n * @param maxPrincipal Amount of tokens being committed by the lender. Max amount that can be loaned.\n * @param expiration Expiration time in seconds, when the commitment expires.\n * @param maxDuration Length of time, in seconds that the lender's capital can be lent out for.\n * @param minInterestRate Minimum Annual percentage to be applied for loans using the lender's capital.\n * @param collateralTokenAddress The address for the token contract that must be used to provide collateral for loans for this commitment.\n * @param maxPrincipalPerCollateralAmount The amount of principal that can be used for a loan per each unit of collateral, expanded additionally by principal decimals.\n * @param collateralTokenType The type of asset of the collateralTokenAddress (ERC20, ERC721, or ERC1155).\n * @param lender The address of the lender for this commitment.\n * @param marketId The market id for this commitment.\n * @param principalTokenAddress The address for the token contract that will be used to provide principal for loans of this commitment.\n */\n struct Commitment {\n uint256 maxPrincipal;\n uint32 expiration;\n uint32 maxDuration;\n uint16 minInterestRate;\n address collateralTokenAddress;\n uint256 collateralTokenId;\n uint256 maxPrincipalPerCollateralAmount;\n CommitmentCollateralType collateralTokenType;\n address lender;\n uint256 marketId;\n address principalTokenAddress;\n }\n\n // CommitmentId => commitment\n mapping(uint256 => Commitment) public commitments;\n\n uint256 commitmentCount;\n\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet)\n internal commitmentBorrowersList;\n\n /**\n * @notice This event is emitted when a lender's commitment is created.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event CreatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when a lender's commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event UpdatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when the allowed borrowers for a commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n */\n event UpdatedCommitmentBorrowers(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment has been deleted.\n * @param commitmentId The id of the commitment that was deleted.\n */\n event DeletedCommitment(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment is exercised for a loan.\n * @param commitmentId The id of the commitment that was exercised.\n * @param borrower The address of the borrower.\n * @param tokenAmount The amount of the asset being committed.\n * @param bidId The bid id for the loan from TellerV2.\n */\n event ExercisedCommitment(\n uint256 indexed commitmentId,\n address borrower,\n uint256 tokenAmount,\n uint256 bidId\n );\n\n error InsufficientCommitmentAllocation(\n uint256 allocated,\n uint256 requested\n );\n error InsufficientBorrowerCollateral(uint256 required, uint256 actual);\n\n /** Modifiers **/\n\n modifier commitmentLender(uint256 _commitmentId) {\n require(\n commitments[_commitmentId].lender == _msgSender(),\n \"unauthorized commitment lender\"\n );\n _;\n }\n\n function validateCommitment(Commitment storage _commitment) internal {\n require(\n _commitment.expiration > uint32(block.timestamp),\n \"expired commitment\"\n );\n require(\n _commitment.maxPrincipal > 0,\n \"commitment principal allocation 0\"\n );\n\n if (_commitment.collateralTokenType != CommitmentCollateralType.NONE) {\n require(\n _commitment.maxPrincipalPerCollateralAmount > 0,\n \"commitment collateral ratio 0\"\n );\n\n if (\n _commitment.collateralTokenType ==\n CommitmentCollateralType.ERC20\n ) {\n require(\n _commitment.collateralTokenId == 0,\n \"commitment collateral token id must be 0 for ERC20\"\n );\n }\n }\n }\n\n /** External Functions **/\n\n constructor(address _protocolAddress, address _marketRegistry)\n TellerV2MarketForwarder(_protocolAddress, _marketRegistry)\n {}\n\n /**\n * @notice Creates a loan commitment from a lender for a market.\n * @param _commitment The new commitment data expressed as a struct\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\n * @return commitmentId_ returns the commitmentId for the created commitment\n */\n function createCommitment(\n Commitment calldata _commitment,\n address[] calldata _borrowerAddressList\n ) public returns (uint256 commitmentId_) {\n commitmentId_ = commitmentCount++;\n\n require(\n _commitment.lender == _msgSender(),\n \"unauthorized commitment creator\"\n );\n\n commitments[commitmentId_] = _commitment;\n\n validateCommitment(commitments[commitmentId_]);\n\n _addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList);\n\n emit CreatedCommitment(\n commitmentId_,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n /**\n * @notice Updates the commitment of a lender to a market.\n * @param _commitmentId The Id of the commitment to update.\n * @param _commitment The new commitment data expressed as a struct\n */\n function updateCommitment(\n uint256 _commitmentId,\n Commitment calldata _commitment\n ) public commitmentLender(_commitmentId) {\n require(\n _commitment.principalTokenAddress ==\n commitments[_commitmentId].principalTokenAddress,\n \"Principal token address cannot be updated.\"\n );\n require(\n _commitment.marketId == commitments[_commitmentId].marketId,\n \"Market Id cannot be updated.\"\n );\n\n commitments[_commitmentId] = _commitment;\n\n validateCommitment(commitments[_commitmentId]);\n\n emit UpdatedCommitment(\n _commitmentId,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n /**\n * @notice Updates the borrowers allowed to accept a commitment\n * @param _commitmentId The Id of the commitment to update.\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\n */\n function updateCommitmentBorrowers(\n uint256 _commitmentId,\n address[] calldata _borrowerAddressList\n ) public commitmentLender(_commitmentId) {\n delete commitmentBorrowersList[_commitmentId];\n _addBorrowersToCommitmentAllowlist(_commitmentId, _borrowerAddressList);\n\n emit UpdatedCommitmentBorrowers(_commitmentId);\n }\n\n /**\n * @notice Adds a borrower to the allowlist for a commmitment.\n * @param _commitmentId The id of the commitment that will allow the new borrower\n * @param _borrowerArray the address array of the borrowers that will be allowed to accept loans using the commitment\n */\n function _addBorrowersToCommitmentAllowlist(\n uint256 _commitmentId,\n address[] calldata _borrowerArray\n ) internal {\n for (uint256 i = 0; i < _borrowerArray.length; i++) {\n commitmentBorrowersList[_commitmentId].add(_borrowerArray[i]);\n }\n }\n\n /**\n * @notice Removes the commitment of a lender to a market.\n * @param _commitmentId The id of the commitment to delete.\n */\n function deleteCommitment(uint256 _commitmentId)\n public\n commitmentLender(_commitmentId)\n {\n delete commitments[_commitmentId];\n delete commitmentBorrowersList[_commitmentId];\n emit DeletedCommitment(_commitmentId);\n }\n\n /**\n * @notice Reduces the commitment amount for a lender to a market.\n * @param _commitmentId The id of the commitment to modify.\n * @param _tokenAmountDelta The amount of change in the maxPrincipal.\n */\n function _decrementCommitment(\n uint256 _commitmentId,\n uint256 _tokenAmountDelta\n ) internal {\n commitments[_commitmentId].maxPrincipal -= _tokenAmountDelta;\n }\n\n /**\n * @notice Accept the commitment to submitBid and acceptBid using the funds\n * @dev LoanDuration must be longer than the market payment cycle\n * @param _commitmentId The id of the commitment being accepted.\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId of collateral to use for the loan if ERC721 or ERC1155.\n * @param _collateralTokenAddress The contract address to use for the loan collateral token.s\n * @param _interestRate The interest rate APY to use for the loan in basis points.\n * @param _loanDuration The overall duratiion for the loan. Must be longer than market payment cycle duration.\n * @return bidId The ID of the loan that was created on TellerV2\n */\n function acceptCommitment(\n uint256 _commitmentId,\n uint256 _principalAmount,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n address _collateralTokenAddress,\n uint16 _interestRate,\n uint32 _loanDuration\n ) external returns (uint256 bidId) {\n address borrower = _msgSender();\n\n Commitment storage commitment = commitments[_commitmentId];\n\n validateCommitment(commitment);\n\n require(\n _collateralTokenAddress == commitment.collateralTokenAddress,\n \"Mismatching collateral token\"\n );\n require(\n _interestRate >= commitment.minInterestRate,\n \"Invalid interest rate\"\n );\n require(\n _loanDuration <= commitment.maxDuration,\n \"Invalid loan max duration\"\n );\n\n require(\n commitmentBorrowersList[_commitmentId].length() == 0 ||\n commitmentBorrowersList[_commitmentId].contains(borrower),\n \"unauthorized commitment borrower\"\n );\n\n if (_principalAmount > commitment.maxPrincipal) {\n revert InsufficientCommitmentAllocation({\n allocated: commitment.maxPrincipal,\n requested: _principalAmount\n });\n }\n\n uint256 requiredCollateral = getRequiredCollateral(\n _principalAmount,\n commitment.maxPrincipalPerCollateralAmount,\n commitment.collateralTokenType,\n commitment.collateralTokenAddress,\n commitment.principalTokenAddress\n );\n if (_collateralAmount < requiredCollateral) {\n revert InsufficientBorrowerCollateral({\n required: requiredCollateral,\n actual: _collateralAmount\n });\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType ==\n CommitmentCollateralType.ERC721_ANY_ID\n ) {\n require(\n _collateralAmount == 1,\n \"invalid commitment collateral amount for ERC721\"\n );\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType == CommitmentCollateralType.ERC1155\n ) {\n require(\n commitment.collateralTokenId == _collateralTokenId,\n \"invalid commitment collateral tokenId\"\n );\n }\n\n bidId = _submitBidFromCommitment(\n borrower,\n commitment.marketId,\n commitment.principalTokenAddress,\n _principalAmount,\n commitment.collateralTokenAddress,\n _collateralAmount,\n _collateralTokenId,\n commitment.collateralTokenType,\n _loanDuration,\n _interestRate\n );\n\n _acceptBid(bidId, commitment.lender);\n\n _decrementCommitment(_commitmentId, _principalAmount);\n\n emit ExercisedCommitment(\n _commitmentId,\n borrower,\n _principalAmount,\n bidId\n );\n }\n\n /**\n * @notice Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _maxPrincipalPerCollateralAmount The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\n * @param _collateralTokenType The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\n * @param _collateralTokenAddress The contract address for the collateral for the loan.\n * @param _principalTokenAddress The contract address for the principal for the loan.\n */\n function getRequiredCollateral(\n uint256 _principalAmount,\n uint256 _maxPrincipalPerCollateralAmount,\n CommitmentCollateralType _collateralTokenType,\n address _collateralTokenAddress,\n address _principalTokenAddress\n ) public view virtual returns (uint256) {\n if (_collateralTokenType == CommitmentCollateralType.NONE) {\n return 0;\n }\n\n uint8 collateralDecimals;\n uint8 principalDecimals = IERC20MetadataUpgradeable(\n _principalTokenAddress\n ).decimals();\n\n if (_collateralTokenType == CommitmentCollateralType.ERC20) {\n collateralDecimals = IERC20MetadataUpgradeable(\n _collateralTokenAddress\n ).decimals();\n }\n\n /*\n * The principalAmount is expanded by (collateralDecimals+principalDecimals) to increase precision\n * and then it is divided by _maxPrincipalPerCollateralAmount which should already been expanded by principalDecimals\n */\n return\n MathUpgradeable.mulDiv(\n _principalAmount,\n (10**(collateralDecimals + principalDecimals)),\n _maxPrincipalPerCollateralAmount,\n MathUpgradeable.Rounding.Up\n );\n }\n\n /**\n * @notice Return the array of borrowers that are allowlisted for a commitment\n * @param _commitmentId The commitment id for the commitment to query.\n * @return borrowers_ An array of addresses restricted to accept the commitment. Empty array means unrestricted.\n */\n function getCommitmentBorrowers(uint256 _commitmentId)\n external\n view\n returns (address[] memory borrowers_)\n {\n borrowers_ = commitmentBorrowersList[_commitmentId].values();\n }\n\n /**\n * @notice Internal function to submit a bid to the lending protocol using a commitment\n * @param _borrower The address of the borrower for the loan.\n * @param _marketId The id for the market of the loan in the lending protocol.\n * @param _principalTokenAddress The contract address for the principal token.\n * @param _principalAmount The amount of principal to borrow for the loan.\n * @param _collateralTokenAddress The contract address for the collateral token.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId for the collateral (if it is ERC721 or ERC1155).\n * @param _collateralTokenType The type of collateral token (ERC20,ERC721,ERC1177,None).\n * @param _loanDuration The duration of the loan in seconds delta. Must be longer than loan payment cycle for the market.\n * @param _interestRate The amount of interest APY for the loan expressed in basis points.\n */\n function _submitBidFromCommitment(\n address _borrower,\n uint256 _marketId,\n address _principalTokenAddress,\n uint256 _principalAmount,\n address _collateralTokenAddress,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n CommitmentCollateralType _collateralTokenType,\n uint32 _loanDuration,\n uint16 _interestRate\n ) internal returns (uint256 bidId) {\n CreateLoanArgs memory createLoanArgs;\n createLoanArgs.marketId = _marketId;\n createLoanArgs.lendingToken = _principalTokenAddress;\n createLoanArgs.principal = _principalAmount;\n createLoanArgs.duration = _loanDuration;\n createLoanArgs.interestRate = _interestRate;\n\n Collateral[] memory collateralInfo;\n if (_collateralTokenType != CommitmentCollateralType.NONE) {\n collateralInfo = new Collateral[](1);\n collateralInfo[0] = Collateral({\n _collateralType: _getEscrowCollateralType(_collateralTokenType),\n _tokenId: _collateralTokenId,\n _amount: _collateralAmount,\n _collateralAddress: _collateralTokenAddress\n });\n }\n\n bidId = _submitBidWithCollateral(\n createLoanArgs,\n collateralInfo,\n _borrower\n );\n }\n\n /**\n * @notice Return the collateral type based on the commitmentcollateral type. Collateral type is used in the base lending protocol.\n * @param _type The type of collateral to be used for the loan.\n */\n function _getEscrowCollateralType(CommitmentCollateralType _type)\n internal\n pure\n returns (CollateralType)\n {\n if (_type == CommitmentCollateralType.ERC20) {\n return CollateralType.ERC20;\n }\n if (\n _type == CommitmentCollateralType.ERC721 ||\n _type == CommitmentCollateralType.ERC721_ANY_ID\n ) {\n return CollateralType.ERC721;\n }\n if (\n _type == CommitmentCollateralType.ERC1155 ||\n _type == CommitmentCollateralType.ERC1155_ANY_ID\n ) {\n return CollateralType.ERC1155;\n }\n\n revert(\"Unknown Collateral Type\");\n }\n}\n" - }, - "contracts/tests/resolvers/TestERC20Token.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract TestERC20Token is ERC20 {\n uint8 private immutable DECIMALS;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint8 _decimals\n ) ERC20(_name, _symbol) {\n DECIMALS = _decimals;\n _mint(msg.sender, _totalSupply);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return DECIMALS;\n }\n}\n" - }, - "contracts/MetaForwarder.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol\";\n\ncontract MetaForwarder is MinimalForwarderUpgradeable {\n function initialize() external initializer {\n __EIP712_init_unchained(\"TellerMetaForwarder\", \"0.0.1\");\n }\n}\n" - }, - "contracts/LenderManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/ILenderManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/IMarketRegistry.sol\";\n\ncontract LenderManager is\n Initializable,\n OwnableUpgradeable,\n ERC721Upgradeable,\n ILenderManager\n{\n IMarketRegistry public immutable marketRegistry;\n\n constructor(IMarketRegistry _marketRegistry) {\n marketRegistry = _marketRegistry;\n }\n\n function initialize() external initializer {\n __LenderManager_init();\n }\n\n function __LenderManager_init() internal onlyInitializing {\n __Ownable_init();\n __ERC721_init(\"TellerLoan\", \"TLN\");\n }\n\n /**\n * @notice Registers a new active lender for a loan, minting the nft\n * @param _bidId The id for the loan to set.\n * @param _newLender The address of the new active lender.\n */\n function registerLoan(uint256 _bidId, address _newLender)\n public\n override\n onlyOwner\n {\n _mint(_newLender, _bidId);\n }\n\n /**\n * @notice Returns the address of the lender that owns a given loan/bid.\n * @param _bidId The id of the bid of which to return the market id\n */\n function _getLoanMarketId(uint256 _bidId) internal view returns (uint256) {\n return ITellerV2(owner()).getLoanMarketId(_bidId);\n }\n\n /**\n * @notice Returns the verification status of a lender for a market.\n * @param _lender The address of the lender which should be verified by the market\n * @param _bidId The id of the bid of which to return the market id\n */\n function _hasMarketVerification(address _lender, uint256 _bidId)\n internal\n view\n virtual\n returns (bool isVerified_)\n {\n uint256 _marketId = _getLoanMarketId(_bidId);\n\n (isVerified_, ) = marketRegistry.isVerifiedLender(_marketId, _lender);\n }\n\n /** ERC721 Functions **/\n\n function _beforeTokenTransfer(address, address to, uint256 tokenId, uint256)\n internal\n override\n {\n require(_hasMarketVerification(to, tokenId), \"Not approved by market\");\n }\n\n function _baseURI() internal view override returns (string memory) {\n return \"\";\n }\n}\n" - }, - "@mangrovedao/hardhat-test-solidity/test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0;\n\n// Should be kept in sync with ./lib.js\n\nlibrary Test {\n /* \n * Expect events from contracts\n */\n event ExpectFrom(address from);\n event StopExpecting();\n\n // Usage: from a test contract `t`, call `expectFrom(a)`. \n // Any subsequent non-special event emitted by `t` will mean \n // \"I expect `a` to emit the exact same event\". \n // The order of expectations must be respected.\n function expectFrom(address from) internal {\n emit ExpectFrom(from);\n }\n\n // After using `expectFrom` and emitting some events you expect\n // to see emitted elsewhere, you can use `stopExpecting` to emit \n // further, normal events from your test.\n function stopExpecting() internal {\n emit StopExpecting();\n }\n\n\n /* \n * Boolean test\n */\n event TestTrue(bool success, string message);\n\n // Succeed iff success is true\n function check(bool success, string memory message) internal {\n emit TestTrue(success, message);\n }\n\n\n /* \n * Always fail, always succeed\n */\n function fail(string memory message) internal {\n emit TestTrue(false, message);\n }\n\n function succeed() internal {\n emit TestTrue(true, \"Success\");\n }\n\n /* \n * Equality testing\n * ! overloaded as `eq` for everything except for bytes use `eq0`.\n */\n\n // Bytes\n event TestEqBytes(bool success, bytes actual, bytes expected, string message);\n\n function eq0(\n bytes memory actual,\n bytes memory expected,\n string memory message\n ) internal returns (bool) {\n bool success = keccak256((actual)) == keccak256((expected));\n emit TestEqBytes(success, actual, expected, message);\n return success;\n }\n\n // Byte32\n event TestEqBytes32(\n bool success,\n bytes32 actual,\n bytes32 expected,\n string message\n );\n\n function eq(\n bytes32 actual,\n bytes32 expected,\n string memory message\n ) internal returns (bool) {\n bool success = (actual == expected);\n emit TestEqBytes32(success, actual, expected, message);\n return success;\n }\n\n // Bool\n event TestEqBool(bool success, bool actual, bool expected, string message);\n function eq(\n bool actual,\n bool expected,\n string memory message\n ) internal returns (bool) {\n bool success = (actual == expected);\n emit TestEqBool(success, actual, expected, message);\n return success;\n }\n\n // uints\n event TestEqUint(bool success, uint actual, uint expected, string message);\n\n function eq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual == expected;\n emit TestEqUint(success, actual, expected, message);\n return success;\n }\n\n // strings\n event TestEqString(\n bool success,\n string actual,\n string expected,\n string message\n );\n\n function eq(\n string memory actual,\n string memory expected,\n string memory message\n ) internal returns (bool) {\n bool success = keccak256(bytes((actual))) == keccak256(bytes((expected)));\n emit TestEqString(success, actual, expected, message);\n return success;\n }\n\n // addresses\n event TestEqAddress(\n bool success,\n address actual,\n address expected,\n string message\n );\n\n\n function eq(\n address actual,\n address expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual == expected;\n emit TestEqAddress(success, actual, expected, message);\n return success;\n }\n\n /* \n * Inequality testing\n */\n event TestLess(bool success, uint actual, uint expected, string message);\n function less(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual < expected;\n emit TestLess(success, actual, expected, message);\n return success;\n }\n\n event TestLessEq(bool success, uint actual, uint expected, string message);\n function lessEq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual <= expected;\n emit TestLessEq(success, actual, expected, message);\n return success;\n }\n\n event TestMore(bool success, uint actual, uint expected, string message);\n function more(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual > expected;\n emit TestMore(success, actual, expected, message);\n return success;\n }\n\n event TestMoreEq(bool success, uint actual, uint expected, string message);\n function moreEq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual >= expected;\n emit TestMoreEq(success, actual, expected, message);\n return success;\n }\n}\n\n// /* Either cast your arguments to address when you call balanceOf logging functions\n// or add `is address` to your ERC20s\n// or use the overloads with `address` types */\ninterface ERC20BalanceOf {\n function balanceOf(address account) view external returns (uint);\n}\n\n\nlibrary Display {\n /* ****************************************************************\n * Register/read address->name mappings to make logs easier to read.\n *****************************************************************/\n /* \n * Names are stored in the contract using the library.\n */\n\n // Disgusting hack so a library can manipulate storage refs.\n bytes32 constant NAMES_POS = keccak256(\"Display.NAMES_POS\");\n // Store mapping in library caller's storage.\n // That's quite fragile.\n struct Registers {\n mapping(address => string) map;\n }\n\n // Also send mapping to javascript test interpreter. The interpreter COULD\n // just make an EVM call to map every name but that would probably be very\n // slow. So we cache locally.\n event Register(address addr, string name);\n\n function registers() internal view returns (Registers storage) {\n this; // silence warning about pure mutability\n Registers storage regs;\n bytes32 _slot = NAMES_POS;\n assembly {\n regs.slot := _slot\n }\n return regs;\n }\n\n /*\n * Give a name to an address for logging purposes\n * @example\n * ```solidity\n * address addr = address(new Contract());\n * register(addr,\"My Contract instance\");\n * ```\n */\n\n function register(address addr, string memory name) internal {\n registers().map[addr] = name;\n emit Register(addr, name);\n }\n\n /*\n * Read the name of a registered address. Default: \"\". \n */\n function nameOf(address addr) internal view returns (string memory) {\n string memory s = registers().map[addr];\n if (keccak256(bytes(s)) != keccak256(bytes(\"\"))) {\n return s;\n } else {\n return \"\";\n }\n }\n\n /* 1 arg logging (string/uint) */\n\n event LogString(string a);\n\n function log(string memory a) internal {\n emit LogString(a);\n }\n\n event LogUint(uint a);\n\n function log(uint a) internal {\n emit LogUint(a);\n }\n\n /* 2 arg logging (string/uint) */\n\n event LogStringString(string a, string b);\n\n function log(string memory a, string memory b) internal {\n emit LogStringString(a, b);\n }\n\n event LogStringUint(string a, uint b);\n\n function log(string memory a, uint b) internal {\n emit LogStringUint(a, b);\n }\n\n event LogUintUint(uint a, uint b);\n\n function log(uint a, uint b) internal {\n emit LogUintUint(a, b);\n }\n\n event LogUintString(uint a, string b);\n\n function log(uint a, string memory b) internal {\n emit LogUintString(a, b);\n }\n\n /* 3 arg logging (string/uint) */\n\n event LogStringStringString(string a, string b, string c);\n\n function log(\n string memory a,\n string memory b,\n string memory c\n ) internal {\n emit LogStringStringString(a, b, c);\n }\n\n event LogStringStringUint(string a, string b, uint c);\n\n function log(\n string memory a,\n string memory b,\n uint c\n ) internal {\n emit LogStringStringUint(a, b, c);\n }\n\n event LogStringUintUint(string a, uint b, uint c);\n\n function log(\n string memory a,\n uint b,\n uint c\n ) internal {\n emit LogStringUintUint(a, b, c);\n }\n\n event LogStringUintString(string a, uint b, string c);\n\n function log(\n string memory a,\n uint b,\n string memory c\n ) internal {\n emit LogStringUintString(a, b, c);\n }\n\n event LogUintUintUint(uint a, uint b, uint c);\n\n function log(\n uint a,\n uint b,\n uint c\n ) internal {\n emit LogUintUintUint(a, b, c);\n }\n\n event LogUintStringUint(uint a, string b, uint c);\n\n function log(\n uint a,\n string memory b,\n uint c\n ) internal {\n emit LogUintStringUint(a, b, c);\n }\n\n event LogUintStringString(uint a, string b, string c);\n\n function log(\n uint a,\n string memory b,\n string memory c\n ) internal {\n emit LogUintStringString(a, b, c);\n }\n\n /* End of register/read section */\n event ERC20Balances(address[] tokens, address[] accounts, uint[] balances);\n\n function logBalances(\n address[1] memory _tokens, \n address _a0\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](1);\n accounts[0] = _a0;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[1] memory _tokens,\n address _a0,\n address _a1\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](2);\n accounts[0] = _a0;\n accounts[1] = _a1;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[1] memory _tokens,\n address _a0,\n address _a1,\n address _a2\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](3);\n accounts[0] = _a0;\n accounts[1] = _a1;\n accounts[2] = _a2;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](1);\n accounts[0] = _a0;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0,\n address _a1\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](2);\n accounts[0] = _a0;\n accounts[1] = _a1;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0,\n address _a1,\n address _a2\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](3);\n accounts[0] = _a0;\n accounts[1] = _a1;\n accounts[2] = _a2;\n logBalances(tokens, accounts);\n }\n\n /* takes [t1,...,tM], [a1,...,aN]\n logs also [...b(t1,aj) ... b(tM,aj) ...] */\n\n function logBalances(address[] memory tokens, address[] memory accounts)\n internal\n {\n uint[] memory balances = new uint[](tokens.length * accounts.length);\n for (uint i = 0; i < tokens.length; i++) {\n for (uint j = 0; j < accounts.length; j++) {\n uint bal = ERC20BalanceOf(tokens[i]).balanceOf(accounts[j]);\n balances[i * accounts.length + j] = bal;\n //console.log(tokens[i].symbol(),nameOf(accounts[j]),bal);\n }\n }\n emit ERC20Balances(tokens, accounts, balances);\n }\n\n}" - }, - "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n constructor(address implementation_) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" - }, - "contracts/ProtocolFee.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract ProtocolFee is OwnableUpgradeable {\n // Protocol fee set for loan processing.\n uint16 private _protocolFee;\n\n /**\n * @notice This event is emitted when the protocol fee has been updated.\n * @param newFee The new protocol fee set.\n * @param oldFee The previously set protocol fee.\n */\n event ProtocolFeeSet(uint16 newFee, uint16 oldFee);\n\n /**\n * @notice Initialized the protocol fee.\n * @param initFee The initial protocol fee to be set on the protocol.\n */\n function __ProtocolFee_init(uint16 initFee) internal onlyInitializing {\n __Ownable_init();\n __ProtocolFee_init_unchained(initFee);\n }\n\n function __ProtocolFee_init_unchained(uint16 initFee)\n internal\n onlyInitializing\n {\n setProtocolFee(initFee);\n }\n\n /**\n * @notice Returns the current protocol fee.\n */\n function protocolFee() public view virtual returns (uint16) {\n return _protocolFee;\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol to set a new protocol fee.\n * @param newFee The new protocol fee to be set.\n */\n function setProtocolFee(uint16 newFee) public virtual onlyOwner {\n // Skip if the fee is the same\n if (newFee == _protocolFee) return;\n\n uint16 oldFee = _protocolFee;\n _protocolFee = newFee;\n emit ProtocolFeeSet(newFee, oldFee);\n }\n}\n" - }, - "contracts/TellerV2Context.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2Storage.sol\";\nimport \"./ERC2771ContextUpgradeable.sol\";\n\n/**\n * @dev This contract should not use any storage\n */\n\nabstract contract TellerV2Context is\n ERC2771ContextUpgradeable,\n TellerV2Storage\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n event TrustedMarketForwarderSet(\n uint256 indexed marketId,\n address forwarder,\n address sender\n );\n event MarketForwarderApproved(\n uint256 indexed marketId,\n address indexed forwarder,\n address sender\n );\n\n constructor(address trustedForwarder)\n ERC2771ContextUpgradeable(trustedForwarder)\n {}\n\n /**\n * @notice Checks if an address is a trusted forwarder contract for a given market.\n * @param _marketId An ID for a lending market.\n * @param _trustedMarketForwarder An address to check if is a trusted forwarder in the given market.\n * @return A boolean indicating the forwarder address is trusted in a market.\n */\n function isTrustedMarketForwarder(\n uint256 _marketId,\n address _trustedMarketForwarder\n ) public view returns (bool) {\n return\n _trustedMarketForwarders[_marketId] == _trustedMarketForwarder ||\n lenderCommitmentForwarder == _trustedMarketForwarder;\n }\n\n /**\n * @notice Checks if an account has approved a forwarder for a market.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n * @param _account The address to verify set an approval.\n * @return A boolean indicating if an approval was set.\n */\n function hasApprovedMarketForwarder(\n uint256 _marketId,\n address _forwarder,\n address _account\n ) public view returns (bool) {\n return\n isTrustedMarketForwarder(_marketId, _forwarder) &&\n _approvedForwarderSenders[_forwarder].contains(_account);\n }\n\n /**\n * @notice Sets a trusted forwarder for a lending market.\n * @notice The caller must owner the market given. See {MarketRegistry}\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n marketRegistry.getMarketOwner(_marketId) == _msgSender(),\n \"Caller must be the market owner\"\n );\n _trustedMarketForwarders[_marketId] = _forwarder;\n emit TrustedMarketForwarderSet(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Approves a forwarder contract to use their address as a sender for a specific market.\n * @notice The forwarder given must be trusted by the market given.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n isTrustedMarketForwarder(_marketId, _forwarder),\n \"Forwarder must be trusted by the market\"\n );\n _approvedForwarderSenders[_forwarder].add(_msgSender());\n emit MarketForwarderApproved(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Retrieves the function caller address by checking the appended calldata if the _actual_ caller is a trusted forwarder.\n * @param _marketId An ID for a lending market.\n * @return sender The address to use as the function caller.\n */\n function _msgSenderForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (address)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n address sender;\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n // Ensure the appended sender address approved the forwarder\n require(\n _approvedForwarderSenders[_msgSender()].contains(sender),\n \"Sender must approve market forwarder\"\n );\n return sender;\n }\n\n return _msgSender();\n }\n\n /**\n * @notice Retrieves the actual function calldata from a trusted forwarder call.\n * @param _marketId An ID for a lending market to verify if the caller is a trusted forwarder.\n * @return calldata The modified bytes array of the function calldata without the appended sender's address.\n */\n function _msgDataForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (bytes calldata)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n return msg.data[:msg.data.length - 20];\n } else {\n return _msgData();\n }\n }\n}\n" - }, - "contracts/libraries/DateTimeLib.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint constant SECONDS_PER_DAY = 24 * 60 * 60;\n uint constant SECONDS_PER_HOUR = 60 * 60;\n uint constant SECONDS_PER_MINUTE = 60;\n int constant OFFSET19700101 = 2440588;\n\n uint constant DOW_MON = 1;\n uint constant DOW_TUE = 2;\n uint constant DOW_WED = 3;\n uint constant DOW_THU = 4;\n uint constant DOW_FRI = 5;\n uint constant DOW_SAT = 6;\n uint constant DOW_SUN = 7;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(uint year, uint month, uint day)\n internal\n pure\n returns (uint _days)\n {\n require(year >= 1970);\n int _year = int(year);\n int _month = int(month);\n int _day = int(day);\n\n int __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n OFFSET19700101;\n\n _days = uint(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint _days)\n internal\n pure\n returns (uint year, uint month, uint day)\n {\n int __days = int(_days);\n\n int L = __days + 68569 + OFFSET19700101;\n int N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int _month = (80 * L) / 2447;\n int _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint(_year);\n month = uint(_month);\n day = uint(_day);\n }\n\n function timestampFromDate(uint year, uint month, uint day)\n internal\n pure\n returns (uint timestamp)\n {\n timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n ) internal pure returns (uint timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n hour *\n SECONDS_PER_HOUR +\n minute *\n SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint timestamp)\n internal\n pure\n returns (uint year, uint month, uint day)\n {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint timestamp)\n internal\n pure\n returns (\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n )\n {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n uint secs = timestamp % SECONDS_PER_DAY;\n hour = secs / SECONDS_PER_HOUR;\n secs = secs % SECONDS_PER_HOUR;\n minute = secs / SECONDS_PER_MINUTE;\n second = secs % SECONDS_PER_MINUTE;\n }\n\n function isValidDate(uint year, uint month, uint day)\n internal\n pure\n returns (bool valid)\n {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint timestamp) internal pure returns (bool leapYear) {\n (uint year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint year) internal pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= DOW_FRI;\n }\n\n function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;\n }\n\n function getDaysInMonth(uint timestamp)\n internal\n pure\n returns (uint daysInMonth)\n {\n (uint year, uint month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint year, uint month)\n internal\n pure\n returns (uint daysInMonth)\n {\n if (\n month == 1 ||\n month == 3 ||\n month == 5 ||\n month == 7 ||\n month == 8 ||\n month == 10 ||\n month == 12\n ) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint timestamp)\n internal\n pure\n returns (uint dayOfWeek)\n {\n uint _days = timestamp / SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint timestamp) internal pure returns (uint year) {\n (year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getMonth(uint timestamp) internal pure returns (uint month) {\n (, month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getDay(uint timestamp) internal pure returns (uint day) {\n (, , day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getHour(uint timestamp) internal pure returns (uint hour) {\n uint secs = timestamp % SECONDS_PER_DAY;\n hour = secs / SECONDS_PER_HOUR;\n }\n\n function getMinute(uint timestamp) internal pure returns (uint minute) {\n uint secs = timestamp % SECONDS_PER_HOUR;\n minute = secs / SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint timestamp) internal pure returns (uint second) {\n second = timestamp % SECONDS_PER_MINUTE;\n }\n\n function addYears(uint timestamp, uint _years)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n year += _years;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint timestamp, uint _months)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint timestamp, uint _days)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _days * SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint timestamp, uint _hours)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint timestamp, uint _minutes)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint timestamp, uint _seconds)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint timestamp, uint _years)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n year -= _years;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint timestamp, uint _months)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n uint yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint timestamp, uint _days)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _days * SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint timestamp, uint _hours)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint timestamp, uint _minutes)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint timestamp, uint _seconds)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _years)\n {\n require(fromTimestamp <= toTimestamp);\n (uint fromYear, , ) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);\n (uint toYear, , ) = _daysToDate(toTimestamp / SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _months)\n {\n require(fromTimestamp <= toTimestamp);\n (uint fromYear, uint fromMonth, ) = _daysToDate(\n fromTimestamp / SECONDS_PER_DAY\n );\n (uint toYear, uint toMonth, ) = _daysToDate(\n toTimestamp / SECONDS_PER_DAY\n );\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _days)\n {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;\n }\n\n function diffHours(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _hours)\n {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _minutes)\n {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _seconds)\n {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = MathUpgradeable.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, MathUpgradeable.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "contracts/ERC2771ContextUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n * @dev This is modified from the OZ library to remove the gap of storage variables at the end.\n */\nabstract contract ERC2771ContextUpgradeable is\n Initializable,\n ContextUpgradeable\n{\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address private immutable _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder)\n public\n view\n virtual\n returns (bool)\n {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender()\n internal\n view\n virtual\n override\n returns (address sender)\n {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData()\n internal\n view\n virtual\n override\n returns (bytes calldata)\n {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "contracts/EAS/TellerASResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IASResolver.sol\";\n\n/**\n * @title A base resolver contract\n */\nabstract contract TellerASResolver is IASResolver {\n error NotPayable();\n\n function isPayable() public pure virtual override returns (bool) {\n return false;\n }\n\n receive() external payable virtual {\n if (!isPayable()) {\n revert NotPayable();\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" - }, - "contracts/interfaces/ITellerV2Context.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Context {\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external;\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "contracts/TellerV2MarketForwarder.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\n\nimport \"./interfaces/IMarketRegistry.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\n\n/**\n * @dev Simple helper contract to forward an encoded function call to the TellerV2 contract. See {TellerV2Context}\n */\nabstract contract TellerV2MarketForwarder is Initializable, ContextUpgradeable {\n using AddressUpgradeable for address;\n\n address public immutable _tellerV2;\n address public immutable _marketRegistry;\n\n struct CreateLoanArgs {\n uint256 marketId;\n address lendingToken;\n uint256 principal;\n uint32 duration;\n uint16 interestRate;\n string metadataURI;\n address recipient;\n }\n\n constructor(address _protocolAddress, address _marketRegistryAddress) {\n _tellerV2 = _protocolAddress;\n _marketRegistry = _marketRegistryAddress;\n }\n\n function getTellerV2() public view returns (address) {\n return _tellerV2;\n }\n\n function getMarketRegistry() public view returns (address) {\n return _marketRegistry;\n }\n\n function getTellerV2MarketOwner(uint256 marketId) public returns (address) {\n return IMarketRegistry(getMarketRegistry()).getMarketOwner(marketId);\n }\n\n /**\n * @dev Performs function call to the TellerV2 contract by appending an address to the calldata.\n * @param _data The encoded function calldata on TellerV2.\n * @param _msgSender The address that should be treated as the underlying function caller.\n * @return The encoded response from the called function.\n *\n * Requirements:\n * - The {_msgSender} address must set an approval on TellerV2 for this forwarder contract __before__ making this call.\n */\n function _forwardCall(bytes memory _data, address _msgSender)\n internal\n returns (bytes memory)\n {\n return\n address(_tellerV2).functionCall(\n abi.encodePacked(_data, _msgSender)\n );\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBid(\n CreateLoanArgs memory _createLoanArgs,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address)\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBidWithCollateral(\n CreateLoanArgs memory _createLoanArgs,\n Collateral[] memory _collateralInfo,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient,\n _collateralInfo\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Accepts a new loan using the TellerV2 lending protocol.\n * @param _bidId The id of the new loan.\n * @param _lender The address of the lender who will provide funds for the new loan.\n */\n function _acceptBid(uint256 _bidId, address _lender)\n internal\n virtual\n returns (bool)\n {\n // Approve the borrower's loan\n _forwardCall(\n abi.encodeWithSelector(ITellerV2.lenderAcceptBid.selector, _bidId),\n _lender\n );\n\n return true;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (metatx/MinimalForwarder.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../utils/cryptography/EIP712Upgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Simple minimal forwarder to be used together with an ERC2771 compatible contract. See {ERC2771Context}.\n *\n * MinimalForwarder is mainly meant for testing, as it is missing features to be a good production-ready forwarder. This\n * contract does not intend to have all the properties that are needed for a sound forwarding system. A fully\n * functioning forwarding system with good properties requires more complexity. We suggest you look at other projects\n * such as the GSN which do have the goal of building a system like that.\n */\ncontract MinimalForwarderUpgradeable is Initializable, EIP712Upgradeable {\n using ECDSAUpgradeable for bytes32;\n\n struct ForwardRequest {\n address from;\n address to;\n uint256 value;\n uint256 gas;\n uint256 nonce;\n bytes data;\n }\n\n bytes32 private constant _TYPEHASH =\n keccak256(\"ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data)\");\n\n mapping(address => uint256) private _nonces;\n\n function __MinimalForwarder_init() internal onlyInitializing {\n __EIP712_init_unchained(\"MinimalForwarder\", \"0.0.1\");\n }\n\n function __MinimalForwarder_init_unchained() internal onlyInitializing {}\n\n function getNonce(address from) public view returns (uint256) {\n return _nonces[from];\n }\n\n function verify(ForwardRequest calldata req, bytes calldata signature) public view returns (bool) {\n address signer = _hashTypedDataV4(\n keccak256(abi.encode(_TYPEHASH, req.from, req.to, req.value, req.gas, req.nonce, keccak256(req.data)))\n ).recover(signature);\n return _nonces[req.from] == req.nonce && signer == req.from;\n }\n\n function execute(ForwardRequest calldata req, bytes calldata signature)\n public\n payable\n returns (bool, bytes memory)\n {\n require(verify(req, signature), \"MinimalForwarder: signature does not match request\");\n _nonces[req.from] = req.nonce + 1;\n\n (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}(\n abi.encodePacked(req.data, req.from)\n );\n\n // Validate that the relayer has sent enough gas for the call.\n // See https://ronan.eth.limo/blog/ethereum-gas-dangers/\n if (gasleft() <= req.gas / 63) {\n // We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since\n // neither revert or assert consume all gas since Solidity 0.8.0\n // https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require\n /// @solidity memory-safe-assembly\n assembly {\n invalid()\n }\n }\n\n return (success, returndata);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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 if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC721_init_unchained(name_, symbol_);\n }\n\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721Upgradeable.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256, /* firstTokenId */\n uint256 batchSize\n ) internal virtual {\n if (batchSize > 1) {\n if (from != address(0)) {\n _balances[from] -= batchSize;\n }\n if (to != address(0)) {\n _balances[to] += batchSize;\n }\n }\n }\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 firstTokenId,\n uint256 batchSize\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[44] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Arrays.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Arrays.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./StorageSlot.sol\";\nimport \"./math/Math.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary Arrays {\n using StorageSlot for bytes32;\n\n /**\n * @dev Searches a sorted `array` and returns the first index that contains\n * a value greater or equal to `element`. If no such index exists (i.e. all\n * values in the array are strictly less than `element`), the array length is\n * returned. Time complexity O(log n).\n *\n * `array` is expected to be sorted in ascending order, and to contain no\n * repeated elements.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n if (array.length == 0) {\n return 0;\n }\n\n uint256 low = 0;\n uint256 high = array.length;\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n // because Math.average rounds down (it does integer division with truncation).\n if (unsafeAccess(array, mid).value > element) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.\n if (low > 0 && unsafeAccess(array, low - 1).value == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getAddressSlot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getBytes32Slot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getUint256Slot();\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "contracts/tests/LenderManager_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\nimport \"../TellerV2MarketForwarder.sol\";\nimport { Testable } from \"./Testable.sol\";\nimport { LenderManager } from \"../LenderManager.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\n\ncontract LenderManager_Test is Testable, LenderManager {\n LenderManagerUser private marketOwner;\n LenderManagerUser private lender;\n LenderManagerUser private borrower;\n\n LenderCommitmentTester mockTellerV2;\n MarketRegistryMock mockMarketRegistry;\n\n bool mockedHasMarketVerification;\n\n constructor()\n LenderManager(\n //address(0),\n new MarketRegistryMock(address(0))\n )\n {}\n\n function setup_beforeAll() public {\n mockTellerV2 = new LenderCommitmentTester();\n\n marketOwner = new LenderManagerUser(\n address(mockTellerV2),\n address(this)\n );\n borrower = new LenderManagerUser(address(mockTellerV2), address(this));\n lender = new LenderManagerUser(address(mockTellerV2), address(this));\n\n mockMarketRegistry = new MarketRegistryMock(address(marketOwner));\n\n delete mockedHasMarketVerification;\n }\n\n function registerLoan_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n\n super.registerLoan(bidId, address(lender));\n\n Test.eq(\n super._exists(bidId),\n true,\n \"Loan registration did not mint nft\"\n );\n }\n\n function transferFrom_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n\n super._mint(address(lender), bidId);\n\n lender.transferLoan(bidId, address(borrower));\n\n Test.eq(\n super.ownerOf(bidId),\n address(borrower),\n \"Loan nft was not transferred\"\n );\n }\n\n function transferFromToInvalidRecipient_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n super._mint(address(lender), bidId);\n\n mockedHasMarketVerification = false;\n\n bool transferFailed;\n\n //I want to expect this to fail !!\n try lender.transferLoan(bidId, address(address(borrower))) {} catch {\n transferFailed = true;\n }\n\n Test.eq(transferFailed, true, \"Loan transfer should have failed\");\n\n Test.eq(\n super.ownerOf(bidId),\n address(lender),\n \"Loan nft is no longer owned by lender\"\n );\n }\n\n //override\n function _hasMarketVerification(address _lender, uint256 _bidId)\n internal\n view\n override\n returns (bool)\n {\n return mockedHasMarketVerification;\n }\n\n //should be able to test the negative case-- use foundry\n function _checkOwner() internal view override {\n // do nothing\n }\n}\n\ncontract LenderManagerUser is User {\n address lenderManager;\n\n constructor(address _tellerV2, address _lenderManager) User(_tellerV2) {\n lenderManager = _lenderManager;\n }\n\n function transferLoan(uint256 bidId, address to) public {\n IERC721(lenderManager).transferFrom(address(this), to, bidId);\n }\n}\n\n//Move to a helper or change it\ncontract LenderCommitmentTester is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "contracts/mock/MarketRegistryMock.sol": { - "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport { PaymentType } from \"../libraries/V2Calculations.sol\";\n\ncontract MarketRegistryMock is IMarketRegistry {\n address marketOwner;\n\n constructor(address _marketOwner) {\n marketOwner = _marketOwner;\n }\n\n function initialize(TellerAS _tellerAS) external {}\n\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\n public\n view\n returns (bool isVerified_, bytes32 uuid_)\n {\n isVerified_ = true;\n }\n\n function isMarketClosed(uint256 _marketId) public view returns (bool) {\n return false;\n }\n\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\n public\n view\n returns (bool isVerified_, bytes32 uuid_)\n {\n isVerified_ = true;\n }\n\n function getMarketOwner(uint256 _marketId) public view returns (address) {\n return address(marketOwner);\n }\n\n function getMarketFeeRecipient(uint256 _marketId)\n public\n view\n returns (address)\n {\n return address(marketOwner);\n }\n\n function getMarketURI(uint256 _marketId)\n public\n view\n returns (string memory)\n {\n return \"url://\";\n }\n\n function getPaymentCycle(uint256 _marketId)\n public\n view\n returns (uint32, PaymentCycleType)\n {\n return (1000, PaymentCycleType.Seconds);\n }\n\n function getPaymentDefaultDuration(uint256 _marketId)\n public\n view\n returns (uint32)\n {\n return 1000;\n }\n\n function getBidExpirationTime(uint256 _marketId)\n public\n view\n returns (uint32)\n {\n return 1000;\n }\n\n function getMarketplaceFee(uint256 _marketId) public view returns (uint16) {\n return 1000;\n }\n\n function setMarketOwner(address _owner) public {\n marketOwner = _owner;\n }\n\n function getPaymentType(uint256 _marketId)\n public\n view\n returns (PaymentType)\n {}\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) public returns (uint256) {}\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) public returns (uint256) {}\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../security/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(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/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() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.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 /**\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 _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetMinterPauser.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../extensions/ERC20Burnable.sol\";\nimport \"../extensions/ERC20Pausable.sol\";\nimport \"../../../access/AccessControlEnumerable.sol\";\nimport \"../../../utils/Context.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 *\n * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._\n */\ncontract ERC20PresetMinterPauser is Context, AccessControlEnumerable, 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) 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\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 virtual override returns (address) {\n return _roleMembers[role].at(index);\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 virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\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) external view returns (address);\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) external view returns (uint256);\n}\n" - }, - "contracts/tests/V2Calculations_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/Arrays.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nimport \"hardhat/console.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\nimport { Bid } from \"../TellerV2Storage.sol\";\nimport { PaymentType } from \"../libraries/V2Calculations.sol\";\n\ncontract V2Calculations_Test is Testable {\n using Arrays for uint256[];\n using EnumerableSet for EnumerableSet.UintSet;\n\n Bid __bid;\n EnumerableSet.UintSet cyclesToSkip;\n uint256[] cyclesWithExtraPayments;\n uint256[] cyclesWithExtraPaymentsAmounts;\n\n constructor() {\n __bid.loanDetails.principal = 100000e6; // 100k\n __bid.loanDetails.loanDuration = 365 days * 3; // 3 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 1000; // 10.0%\n }\n\n function setup_beforeAll() public {\n delete cyclesToSkip;\n delete cyclesWithExtraPayments;\n delete cyclesWithExtraPaymentsAmounts;\n }\n\n // EMI loan\n function _01_calculateAmountOwed_test() public {\n cyclesToSkip.add(2);\n cyclesWithExtraPayments = [3, 4];\n cyclesWithExtraPaymentsAmounts = [25000e6, 25000e6];\n\n calculateAmountOwed_runner(\n 18,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan\n function _02_calculateAmountOwed_test() public {\n cyclesToSkip.add(3);\n cyclesToSkip.add(4);\n cyclesToSkip.add(5);\n\n calculateAmountOwed_runner(\n 36,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan\n function _03_calculateAmountOwed_test() public {\n cyclesWithExtraPayments = [3, 7];\n cyclesWithExtraPaymentsAmounts = [35000e6, 20000e6];\n\n calculateAmountOwed_runner(\n 16,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan - Monthly payment cycle\n function _04_calculateAmountOwed_test() public {\n cyclesToSkip.add(5);\n cyclesToSkip.add(7);\n\n calculateAmountOwed_runner(\n 36,\n PaymentType.EMI,\n PaymentCycleType.Monthly\n );\n }\n\n // EMI loan - Monthly payment cycle\n function _05_calculateAmountOwed_test() public {\n cyclesWithExtraPayments = [2, 6];\n cyclesWithExtraPaymentsAmounts = [35000e6, 20000e6];\n\n calculateAmountOwed_runner(\n 16,\n PaymentType.EMI,\n PaymentCycleType.Monthly\n );\n }\n\n // Bullet loan\n function _06_calculateAmountOwed_test() public {\n cyclesToSkip.add(6);\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Seconds\n );\n }\n\n // Bullet loan\n function _07_calculateAmountOwed_test() public {\n cyclesToSkip.add(12);\n cyclesWithExtraPayments = [1, 8];\n cyclesWithExtraPaymentsAmounts = [15000e6, 10000e6];\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Seconds\n );\n }\n\n // Bullet loan - Monthly payment cycle\n function _08_calculateAmountOwed_test() public {\n cyclesToSkip.add(5);\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Monthly\n );\n }\n\n // Bullet loan - Monthly paymenty cycle\n function _09_calculateAmountOwed_test() public {\n cyclesToSkip.add(8);\n cyclesWithExtraPayments = [3];\n cyclesWithExtraPaymentsAmounts = [13000e6];\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Monthly\n );\n }\n\n function calculateAmountOwed_runner(\n uint256 expectedTotalCycles,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType\n ) private {\n // Calculate payment cycle amount\n uint256 paymentCycleAmount = V2Calculations.calculatePaymentCycleAmount(\n _paymentType,\n _paymentCycleType,\n __bid.loanDetails.principal,\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle,\n __bid.terms.APR\n );\n\n // Set the bid's payment cycle amount\n __bid.terms.paymentCycleAmount = paymentCycleAmount;\n // Set accepted bid timestamp to now\n __bid.loanDetails.acceptedTimestamp = uint32(block.timestamp);\n\n uint256 nowTimestamp = block.timestamp;\n uint256 skippedPaymentCounter;\n uint256 owedPrincipal = __bid.loanDetails.principal;\n uint256 cycleCount = Math.ceilDiv(\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle\n );\n uint256 cycleIndex;\n while (owedPrincipal > 0) {\n // Increment cycle index\n cycleIndex++;\n\n // Increase timestamp\n nowTimestamp += __bid.terms.paymentCycle;\n\n uint256 duePrincipal;\n uint256 interest;\n (owedPrincipal, duePrincipal, interest) = V2Calculations\n .calculateAmountOwed(__bid, nowTimestamp, _paymentCycleType);\n\n // Check if we should skip this cycle for payments\n if (cyclesToSkip.length() > 0) {\n if (cyclesToSkip.contains(cycleIndex)) {\n // Add this cycle's payment amount to the next cycle's expected payment\n skippedPaymentCounter++;\n continue;\n }\n }\n\n skippedPaymentCounter = 0;\n\n uint256 extraPaymentAmount;\n // Add additional payment amounts for cycles\n if (cyclesWithExtraPayments.length > 0) {\n uint256 index = cyclesWithExtraPayments.findUpperBound(\n cycleIndex\n );\n if (\n index < cyclesWithExtraPayments.length &&\n cyclesWithExtraPayments[index] == cycleIndex\n ) {\n extraPaymentAmount = cyclesWithExtraPaymentsAmounts[index];\n }\n }\n\n // Mark repayment amounts\n uint256 principalPayment;\n principalPayment = duePrincipal + extraPaymentAmount;\n if (principalPayment > 0) {\n __bid.loanDetails.totalRepaid.principal += principalPayment;\n // Subtract principal owed for while loop execution check\n owedPrincipal -= principalPayment;\n }\n\n __bid.loanDetails.totalRepaid.interest += interest;\n\n // Set last repaid time\n __bid.loanDetails.lastRepaidTimestamp = uint32(nowTimestamp);\n }\n Test.eq(\n cycleIndex,\n expectedTotalCycles,\n \"Expected number of cycles incorrect\"\n );\n Test.eq(\n cycleIndex <= cycleCount + 1,\n true,\n \"Payment cycle exceeded agreed terms\"\n );\n }\n\n function calculateAmountOwed_test() public {\n uint256 principal = 24486571879936808846;\n uint256 repaidPrincipal = 23410087846643631232;\n uint16 interestRate = 3000;\n __bid.loanDetails.principal = principal;\n __bid.terms.APR = interestRate;\n __bid.loanDetails.totalRepaid.principal = repaidPrincipal;\n __bid.terms.paymentCycleAmount = 8567977538702439153;\n __bid.terms.paymentCycle = 2592000;\n __bid.loanDetails.acceptedTimestamp = 1646159355;\n __bid.paymentType = PaymentType.EMI;\n\n (uint256 _owedPrincipal, uint256 _duePrincipal, uint256 _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n 1658159355, // last repaid timestamp\n 1663189241, //timestamp\n PaymentCycleType.Seconds\n );\n\n console.log(\"calc amt owed test \");\n console.log(_owedPrincipal);\n console.log(_duePrincipal);\n\n Test.eq(\n _owedPrincipal,\n 1076484033293177614,\n \"Expected number of cycles incorrect\"\n );\n Test.eq(\n _duePrincipal,\n 1076484033293177614,\n \"Expected number of cycles incorrect\"\n );\n }\n\n function calculateBulletAmountOwed_test() public {\n uint256 _principal = 100000e6;\n uint256 _repaidPrincipal = 0;\n uint16 _apr = 3000;\n uint256 _acceptedTimestamp = 1646159355;\n uint256 _lastRepaidTimestamp = _acceptedTimestamp;\n __bid.loanDetails.principal = _principal;\n __bid.terms.APR = _apr;\n __bid.loanDetails.totalRepaid.principal = _repaidPrincipal;\n __bid.terms.paymentCycleAmount = 8567977538702439153;\n __bid.terms.paymentCycle = 2592000;\n __bid.loanDetails.acceptedTimestamp = uint32(_acceptedTimestamp);\n __bid.paymentType = PaymentType.Bullet;\n uint256 _paymentCycleAmount = V2Calculations\n .calculatePaymentCycleAmount(\n PaymentType.Bullet,\n PaymentCycleType.Seconds,\n _principal,\n 365 days,\n 365 days / 12,\n _apr\n );\n __bid.terms.paymentCycleAmount = _paymentCycleAmount;\n\n // Within the first payment cycle\n uint256 _timestamp = _acceptedTimestamp + ((365 days / 12) / 2);\n\n (\n uint256 _owedPrincipal,\n uint256 _duePrincipal,\n uint256 _interest\n ) = V2Calculations.calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"First cycle bullet owed principal incorrect\"\n );\n Test.eq(_duePrincipal, 0, \"First cycle bullet due principal incorrect\");\n Test.eq(_interest, 1250000000, \"First cycle bullet interest incorrect\");\n\n // Within random payment cycle\n _timestamp = _acceptedTimestamp + ((365 days / 12) * 3);\n\n __bid.terms.paymentCycle = 365 days / 12;\n __bid.loanDetails.loanDuration = 365 days;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Second cycle bullet Owed principal incorrect\"\n );\n Test.eq(_duePrincipal, 0, \"Second cycle bullet principal incorrect\");\n Test.eq(\n _interest,\n 7500000000,\n \"Second cycle bullet interest incorrect\"\n );\n\n // Last payment cycle\n _timestamp = _acceptedTimestamp + 360 days;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Final cycle bullet Owed principal incorrect\"\n );\n Test.eq(\n _duePrincipal,\n _principal,\n \"Final cycle bullet principal incorrect\"\n );\n Test.eq(\n _interest,\n 29589041095,\n \"Final cycle bullet interest incorrect\"\n );\n\n // Beyond last payment cycle (checks for overflow protection)\n _timestamp = _acceptedTimestamp + 365 days * 2;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Final cycle bullet Owed principal incorrect\"\n );\n Test.eq(\n _duePrincipal,\n _principal,\n \"Final cycle bullet principal incorrect\"\n );\n Test.eq(\n _interest,\n ((_principal * _apr) / 10000) * 2,\n \"Final cycle bullet interest incorrect\"\n );\n }\n}\n" - }, - "hardhat/console.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >= 0.4.22 <0.9.0;\n\nlibrary console {\n\taddress constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n\tfunction _sendLogPayload(bytes memory payload) private view {\n\t\tuint256 payloadLength = payload.length;\n\t\taddress consoleAddress = CONSOLE_ADDRESS;\n\t\tassembly {\n\t\t\tlet payloadStart := add(payload, 32)\n\t\t\tlet r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n\t\t}\n\t}\n\n\tfunction log() internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log()\"));\n\t}\n\n\tfunction logInt(int256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n\t}\n\n\tfunction logUint(uint256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n\t}\n\n\tfunction logString(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction logBool(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction logAddress(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction logBytes(bytes memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n\t}\n\n\tfunction logBytes1(bytes1 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n\t}\n\n\tfunction logBytes2(bytes2 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n\t}\n\n\tfunction logBytes3(bytes3 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n\t}\n\n\tfunction logBytes4(bytes4 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n\t}\n\n\tfunction logBytes5(bytes5 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n\t}\n\n\tfunction logBytes6(bytes6 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n\t}\n\n\tfunction logBytes7(bytes7 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n\t}\n\n\tfunction logBytes8(bytes8 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n\t}\n\n\tfunction logBytes9(bytes9 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n\t}\n\n\tfunction logBytes10(bytes10 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n\t}\n\n\tfunction logBytes11(bytes11 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n\t}\n\n\tfunction logBytes12(bytes12 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n\t}\n\n\tfunction logBytes13(bytes13 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n\t}\n\n\tfunction logBytes14(bytes14 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n\t}\n\n\tfunction logBytes15(bytes15 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n\t}\n\n\tfunction logBytes16(bytes16 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n\t}\n\n\tfunction logBytes17(bytes17 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n\t}\n\n\tfunction logBytes18(bytes18 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n\t}\n\n\tfunction logBytes19(bytes19 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n\t}\n\n\tfunction logBytes20(bytes20 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n\t}\n\n\tfunction logBytes21(bytes21 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n\t}\n\n\tfunction logBytes22(bytes22 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n\t}\n\n\tfunction logBytes23(bytes23 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n\t}\n\n\tfunction logBytes24(bytes24 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n\t}\n\n\tfunction logBytes25(bytes25 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n\t}\n\n\tfunction logBytes26(bytes26 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n\t}\n\n\tfunction logBytes27(bytes27 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n\t}\n\n\tfunction logBytes28(bytes28 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n\t}\n\n\tfunction logBytes29(bytes29 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n\t}\n\n\tfunction logBytes30(bytes30 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n\t}\n\n\tfunction logBytes31(bytes31 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n\t}\n\n\tfunction logBytes32(bytes32 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n\t}\n\n\tfunction log(uint256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n\t}\n\n\tfunction log(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction log(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction log(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n\t}\n\n\tfunction log(address p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n\t}\n\n\tfunction log(address p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n\t}\n\n\tfunction log(address p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n\t}\n\n\tfunction log(address p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n}\n" - }, - "contracts/tests/TellerV2Context_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport { Testable } from \"./Testable.sol\";\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\nimport { IMarketRegistry } from \"../interfaces/IMarketRegistry.sol\";\nimport { TellerV2MarketForwarder } from \"../TellerV2MarketForwarder.sol\";\nimport { LenderCommitmentForwarder } from \"../LenderCommitmentForwarder.sol\";\n\ncontract TellerV2Context_Test is Testable, TellerV2Context {\n uint256 private marketId;\n /*User private marketOwner;\n User private user1;\n User private user2;*/\n User private marketOwner;\n User private user1;\n\n constructor() TellerV2Context(address(0)) {}\n\n function setup_beforeAll() public {\n marketOwner = new User(TellerV2Context(this));\n\n marketRegistry = IMarketRegistry(\n address(new MockMarketRegistry(marketOwner))\n );\n\n Test.eq(\n marketRegistry.getMarketOwner(5),\n address(marketOwner),\n \"should have set marketOwner\"\n );\n }\n\n function isTrustedMarketForwarder_test() public returns (bool) {\n Test.eq(\n super.isTrustedMarketForwarder(89, lenderCommitmentForwarder),\n true,\n \"lenderCommitmentForwarder should be a trusted forwarder for all markets\"\n );\n //Test.eq(super.isTrustedMarketForwarder(1, address(0)) , false, \"by default address(0) should not be a trusted forwarder\");\n\n address stubbedMarketForwarder = address(\n 0xB11ca87E32075817C82Cc471994943a4290f4a14\n );\n Test.eq(\n super.isTrustedMarketForwarder(7, stubbedMarketForwarder),\n false,\n \"by default an address should not be a trusted forwarder\"\n );\n\n marketOwner.setTrustedMarketForwarder(7, stubbedMarketForwarder);\n\n Test.eq(\n super.isTrustedMarketForwarder(7, stubbedMarketForwarder),\n true,\n \" address should be a trusted forwarder after setting \"\n );\n }\n}\n\ncontract User {\n TellerV2Context public immutable context;\n\n constructor(TellerV2Context _context) {\n context = _context;\n }\n\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n context.setTrustedMarketForwarder(_marketId, _forwarder);\n }\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n context.approveMarketForwarder(_marketId, _forwarder);\n }\n}\n\ncontract MockMarketRegistry {\n User private immutable marketOwner;\n\n constructor(User _marketOwner) {\n marketOwner = _marketOwner;\n }\n\n function getMarketOwner(uint256) external view returns (address) {\n return address(marketOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/cryptography/EIP712.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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 if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Counters.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-ERC20Permit.sol\";\nimport \"../../../utils/math/Math.sol\";\nimport \"../../../governance/utils/IVotes.sol\";\nimport \"../../../utils/math/SafeCast.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n *\n * _Available since v4.2._\n */\nabstract contract ERC20Votes is IVotes, ERC20Permit {\n struct Checkpoint {\n uint32 fromBlock;\n uint224 votes;\n }\n\n bytes32 private constant _DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address => address) private _delegates;\n mapping(address => Checkpoint[]) private _checkpoints;\n Checkpoint[] private _totalSupplyCheckpoints;\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n return _checkpoints[account][pos];\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return SafeCast.toUint32(_checkpoints[account].length);\n }\n\n /**\n * @dev Get the address `account` is currently delegating to.\n */\n function delegates(address account) public view virtual override returns (address) {\n return _delegates[account];\n }\n\n /**\n * @dev Gets the current votes balance for `account`\n */\n function getVotes(address account) public view virtual override returns (uint256) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\n }\n\n /**\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_checkpoints[account], blockNumber);\n }\n\n /**\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\n * It is but NOT the sum of all the delegated votes!\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n }\n\n /**\n * @dev Lookup a value in a list of (sorted) checkpoints.\n */\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n //\n // Initially we check if the block is recent to narrow the search range.\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n // out of bounds (in which case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n // the same.\n uint256 length = ckpts.length;\n\n uint256 low = 0;\n uint256 high = length;\n\n if (length > 5) {\n uint256 mid = length - Math.sqrt(length);\n if (_unsafeAccess(ckpts, mid).fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(ckpts, mid).fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : _unsafeAccess(ckpts, high - 1).votes;\n }\n\n /**\n * @dev Delegate votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual override {\n _delegate(_msgSender(), delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= expiry, \"ERC20Votes: signature expired\");\n address signer = ECDSA.recover(\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n require(nonce == _useNonce(signer), \"ERC20Votes: invalid nonce\");\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n */\n function _maxSupply() internal view virtual returns (uint224) {\n return type(uint224).max;\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been increased.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n super._mint(account, amount);\n require(totalSupply() <= _maxSupply(), \"ERC20Votes: total supply risks overflowing votes\");\n\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been decreased.\n */\n function _burn(address account, uint256 amount) internal virtual override {\n super._burn(account, amount);\n\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {IVotes-DelegateVotesChanged} event.\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._afterTokenTransfer(from, to, amount);\n\n _moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Change delegation for `delegator` to `delegatee`.\n *\n * Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.\n */\n function _delegate(address delegator, address delegatee) internal virtual {\n address currentDelegate = delegates(delegator);\n uint256 delegatorBalance = balanceOf(delegator);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) private {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n function _writeCheckpoint(\n Checkpoint[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) private returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n\n Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);\n\n oldWeight = oldCkpt.votes;\n newWeight = op(oldWeight, delta);\n\n if (pos > 0 && oldCkpt.fromBlock == block.number) {\n _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);\n } else {\n ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));\n }\n }\n\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\n return a + b;\n }\n\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.\n */\n function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result) {\n assembly {\n mstore(0, ckpts.slot)\n result.slot := add(keccak256(0, 0x20), pos)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/governance/utils/IVotes.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotes {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" - }, - "contracts/tests/PMT_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract PMT_Test is Testable, TellerV2 {\n Bid __bid;\n\n constructor() TellerV2(address(0)) {}\n\n function _01_pmt_test() public {\n __bid.loanDetails.principal = 10000e6; // 10k USDC\n __bid.loanDetails.loanDuration = 365 days * 3; // 3 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 300; // 3.0%\n pmt_runner(290812096, 365 days);\n }\n\n function _02_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 365 days * 10; // 10 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 800; // 8.0%\n pmt_runner(1213275944, 365 days);\n }\n\n function _03_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 365 days * 10; // 10 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 0; // 0.0%\n pmt_runner(833333334, 365 days);\n }\n\n function _04_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 45 days; // 45 days\n __bid.terms.paymentCycle = 30 days; // 1 month\n __bid.terms.APR = 600; // 6.0%\n pmt_runner(50370166243, 365 days);\n }\n\n function pmt_runner(uint256 _expected, uint256 _daysInYear) private {\n uint256 pmt = NumbersLib.pmt(\n __bid.loanDetails.principal,\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle,\n __bid.terms.APR,\n _daysInYear\n );\n Test.eq(pmt, _expected, \"Loan payment for cycle incorrect\");\n }\n}\n" - }, - "contracts/tests/resolvers/TestASTokenResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether a specific amount of tokens was approved to be included in an attestation.\n */\ncontract TestASTokenResolver is TellerASResolver {\n using SafeERC20 for IERC20;\n\n IERC20 private immutable _targetToken;\n uint256 private immutable _targetAmount;\n\n constructor(IERC20 targetToken, uint256 targetAmount) {\n _targetToken = targetToken;\n _targetAmount = targetAmount;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address msgSender\n ) external payable virtual override returns (bool) {\n _targetToken.safeTransferFrom(msgSender, address(this), _targetAmount);\n\n return true;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASValueResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether a specific amount of ETH was sent with an attestation.\n */\ncontract TestASValueResolver is TellerASResolver {\n uint256 private immutable _targetValue;\n\n constructor(uint256 targetValue) {\n _targetValue = targetValue;\n }\n\n function isPayable() public pure override returns (bool) {\n return true;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n return msg.value == _targetValue;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASRecipientResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether the attestation is to a specific recipient.\n */\ncontract TestASRecipientResolver is TellerASResolver {\n address private immutable _targetRecipient;\n\n constructor(address targetRecipient) {\n _targetRecipient = targetRecipient;\n }\n\n function resolve(\n address recipient,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n return recipient == _targetRecipient;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASPayingResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that pays attesters\n */\ncontract TestASPayingResolver is TellerASResolver {\n uint256 private immutable _incentive;\n\n constructor(uint256 incentive) {\n _incentive = incentive;\n }\n\n function isPayable() public pure override returns (bool) {\n return true;\n }\n\n function resolve(\n address recipient,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n payable(recipient).transfer(_incentive);\n\n return true;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASExpirationTimeResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether the expiration time is later than a specific timestamp.\n */\ncontract TestASExpirationTimeResolver is TellerASResolver {\n uint256 private immutable _validAfter;\n\n constructor(uint256 validAfter) {\n _validAfter = validAfter;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 expirationTime,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n return expirationTime >= _validAfter;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASDataResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether an attestation data is either \\x00 or \\x01.\n */\ncontract TestASDataResolver is TellerASResolver {\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata data,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n // Verifies that the data is either 0 or 1.\n return data.length == 1 && (data[0] == \"\\x00\" || data[0] == \"\\x01\");\n }\n}\n" - }, - "contracts/tests/resolvers/TestASAttesterResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether the attestation is from a specific attester.\n */\ncontract TestASAttesterResolver is TellerASResolver {\n address private immutable _targetAttester;\n\n constructor(address targetAttester) {\n _targetAttester = targetAttester;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address msgSender\n ) external payable virtual override returns (bool) {\n return msgSender == _targetAttester;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASAttestationResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\nimport \"../../EAS/TellerAS.sol\";\n\n/**\n * @title A sample AS resolver that checks whether an attestations attest to an existing attestation.\n */\ncontract TestASAttestationResolver is TellerASResolver {\n error Overflow();\n error OutOfBounds();\n\n TellerAS private immutable _eas;\n\n constructor(TellerAS eas) {\n _eas = eas;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata data,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n return _eas.isAttestationValid(_toBytes32(data, 0));\n }\n\n function _toBytes32(bytes memory data, uint256 start)\n private\n pure\n returns (bytes32)\n {\n if (start + 32 < start) {\n revert Overflow();\n }\n\n if (data.length < start + 32) {\n revert OutOfBounds();\n }\n\n bytes32 tempBytes32;\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n tempBytes32 := mload(add(add(data, 0x20), start))\n }\n\n return tempBytes32;\n }\n}\n" - }, - "contracts/tests/TellerV2Autopay_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2Autopay } from \"../TellerV2Autopay.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport \"../TellerV2Storage.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\n\nimport \"../mock/TellerV2SolMock.sol\";\nimport \"../mock/MarketRegistryMock.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"../interfaces/ITellerV2Autopay.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ncontract TellerV2Autopay_Test is Testable, TellerV2Autopay {\n User private marketOwner;\n User private borrower;\n User private lender;\n User private contractOwner;\n\n WethMock wethMock;\n\n address marketRegistry;\n\n constructor() TellerV2Autopay(address(new TellerV2SolMock())) {\n marketRegistry = address(new MarketRegistryMock(address(0)));\n TellerV2SolMock(address(tellerV2)).setMarketRegistry(marketRegistry);\n }\n\n function setup_beforeAll() public {\n wethMock = new WethMock();\n\n marketOwner = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n borrower = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n lender = new User(address(this), address(tellerV2), address(wethMock));\n\n contractOwner = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n\n contractOwner.initialize(5, address(contractOwner));\n }\n\n function setAutoPayEnabled_before() public {\n uint256 marketplaceId = 1;\n marketOwner.createMarketWithinRegistry(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n \"uri://\"\n );\n\n uint256 bidId = borrower.submitBid(\n address(wethMock),\n marketplaceId,\n 100,\n 4000,\n 300,\n \"ipfs://\",\n address(borrower)\n );\n }\n\n function setAutoPayEnabled_test() public {\n uint256 bidId = 0;\n\n borrower.enableAutoPay(bidId, true);\n\n Test.eq(\n loanAutoPayEnabled[bidId],\n true,\n \"Autopay not enabled after setAutoPayEnabled\"\n );\n }\n\n function setAutopayFee_test() public {\n _setAutopayFee(4);\n Test.eq(4, getAutopayFee(), \"Auto pay fee not set\");\n }\n\n function setAutopayFeeOnlyOwner_test() public {\n User user = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n try user.setAutopayFee(4) {\n Test.fail(\"Auto pay fee set by non owner\");\n } catch Error(string memory reason) {\n Test.eq(\n reason,\n \"Ownable: caller is not the owner\",\n \"Should not be able to set autopay fee\"\n );\n } catch {\n Test.fail(\"Unknown error\");\n }\n }\n\n function autoPayLoanMinimum_before() public {\n uint256 marketplaceId = 1;\n\n uint256 lenderNewBalance = 500000;\n\n payable(address(lender)).transfer(lenderNewBalance);\n\n //lender approves for acceptBid\n lender.depositToWeth(lenderNewBalance);\n lender.approveWeth(address(tellerV2), lenderNewBalance);\n\n uint256 bidId = borrower.submitBid(\n address(wethMock),\n marketplaceId,\n 1000,\n 4000,\n 300,\n \"ipfs://\",\n address(borrower)\n );\n\n borrower.enableAutoPay(bidId, true);\n\n uint256 lenderBalance = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n\n lender.acceptBid(bidId);\n\n uint256 borrowerNewBalance = 500000;\n\n payable(address(borrower)).transfer(borrowerNewBalance);\n\n //borrower approve to do repay\n borrower.depositToWeth(borrowerNewBalance);\n borrower.approveWeth(address(this), borrowerNewBalance);\n }\n\n function autoPayLoanMinimum_test() public {\n uint256 bidId = 0;\n\n uint256 lenderBalanceBefore = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n uint256 borrowerBalanceBefore = ERC20(address(wethMock)).balanceOf(\n address(borrower)\n );\n\n lender.autoPayLoanMinimum(bidId);\n\n uint256 lenderBalanceAfter = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n uint256 borrowerBalanceAfter = ERC20(address(wethMock)).balanceOf(\n address(borrower)\n );\n\n uint256 lenderBalanceDelta = lenderBalanceAfter - lenderBalanceBefore;\n\n Test.eq(\n lenderBalanceDelta,\n 2,\n \"lender did not receive the auto pay charge\"\n );\n\n uint256 borrowerBalanceDelta = borrowerBalanceBefore -\n borrowerBalanceAfter;\n\n Test.eq(borrowerBalanceDelta, 4002, \"borrower did not autopay\");\n }\n\n function getEstimatedMinimumPayment(uint256 _bidId)\n public\n override\n returns (uint256 _amount)\n {\n return 4000; //stub this for this test since there is not a good way to fast forward timestamp\n }\n}\n\ncontract User {\n address public immutable tellerV2;\n address public immutable wethMock;\n address public immutable tellerV2Autopay;\n\n constructor(address _tellerV2Autopay, address _tellerV2, address _wethMock)\n {\n tellerV2Autopay = _tellerV2Autopay;\n tellerV2 = _tellerV2;\n wethMock = _wethMock;\n }\n\n function enableAutoPay(uint256 bidId, bool enabled) public {\n ITellerV2Autopay(tellerV2Autopay).setAutoPayEnabled(bidId, enabled);\n }\n\n function createMarketWithinRegistry(\n address marketRegistry,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n string calldata _uri\n ) public {\n IMarketRegistry(marketRegistry).createMarket(\n address(this),\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n PaymentCycleType.Seconds,\n _uri\n );\n }\n\n function autoPayLoanMinimum(uint256 bidId) public {\n ITellerV2Autopay(tellerV2Autopay).autoPayLoanMinimum(bidId);\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n function initialize(uint16 _newFee, address _newOwner) public {\n ITellerV2Autopay(tellerV2Autopay).initialize(_newFee, _newOwner);\n }\n\n function setAutopayFee(uint16 _newFee) public {\n ITellerV2Autopay(tellerV2Autopay).setAutopayFee(_newFee);\n }\n\n function acceptBid(uint256 _bidId) public {\n ITellerV2(tellerV2).lenderAcceptBid(_bidId);\n }\n\n function depositToWeth(uint256 amount) public {\n IWETH(wethMock).deposit{ value: amount }();\n }\n\n function approveWeth(address to, uint256 amount) public {\n ERC20(wethMock).approve(to, amount);\n }\n\n receive() external payable {}\n}\n" - }, - "contracts/TellerV2Autopay.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/ITellerV2Autopay.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { Payment } from \"./TellerV2Storage.sol\";\n\n/**\n * @dev Helper contract to autopay loans\n */\ncontract TellerV2Autopay is OwnableUpgradeable, ITellerV2Autopay {\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n\n ITellerV2 public immutable tellerV2;\n\n //bidId => enabled\n mapping(uint256 => bool) public loanAutoPayEnabled;\n\n // Autopay fee set for automatic loan payments\n uint16 private _autopayFee;\n\n /**\n * @notice This event is emitted when a loan is autopaid.\n * @param bidId The id of the bid/loan which was repaid.\n * @param msgsender The account that called the method\n */\n event AutoPaidLoanMinimum(uint256 indexed bidId, address indexed msgsender);\n\n /**\n * @notice This event is emitted when loan autopayments are enabled or disabled.\n * @param bidId The id of the bid/loan.\n * @param enabled Whether the autopayments are enabled or disabled\n */\n event AutoPayEnabled(uint256 indexed bidId, bool enabled);\n\n /**\n * @notice This event is emitted when the autopay fee has been updated.\n * @param newFee The new autopay fee set.\n * @param oldFee The previously set autopay fee.\n */\n event AutopayFeeSet(uint16 newFee, uint16 oldFee);\n\n constructor(address _protocolAddress) {\n tellerV2 = ITellerV2(_protocolAddress);\n }\n\n /**\n * @notice Initialized the proxy.\n * @param _fee The fee collected for automatic payment processing.\n * @param _owner The address of the ownership to be transferred to.\n */\n function initialize(uint16 _fee, address _owner) external initializer {\n _transferOwnership(_owner);\n _setAutopayFee(_fee);\n }\n\n /**\n * @notice Let the owner of the contract set a new autopay fee.\n * @param _newFee The new autopay fee to set.\n */\n function setAutopayFee(uint16 _newFee) public virtual onlyOwner {\n _setAutopayFee(_newFee);\n }\n\n function _setAutopayFee(uint16 _newFee) internal {\n // Skip if the fee is the same\n if (_newFee == _autopayFee) return;\n uint16 oldFee = _autopayFee;\n _autopayFee = _newFee;\n emit AutopayFeeSet(_newFee, oldFee);\n }\n\n /**\n * @notice Returns the current autopay fee.\n */\n function getAutopayFee() public view virtual returns (uint16) {\n return _autopayFee;\n }\n\n /**\n * @notice Function for a borrower to enable or disable autopayments\n * @param _bidId The id of the bid to cancel.\n * @param _autoPayEnabled boolean for allowing autopay on a loan\n */\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external {\n require(\n _msgSender() == tellerV2.getLoanBorrower(_bidId),\n \"Only the borrower can set autopay\"\n );\n\n loanAutoPayEnabled[_bidId] = _autoPayEnabled;\n\n emit AutoPayEnabled(_bidId, _autoPayEnabled);\n }\n\n /**\n * @notice Function for a minimum autopayment to be performed on a loan\n * @param _bidId The id of the bid to repay.\n */\n function autoPayLoanMinimum(uint256 _bidId) external {\n require(\n loanAutoPayEnabled[_bidId],\n \"Autopay is not enabled for that loan\"\n );\n\n address lendingToken = ITellerV2(tellerV2).getLoanLendingToken(_bidId);\n address borrower = ITellerV2(tellerV2).getLoanBorrower(_bidId);\n\n uint256 amountToRepayMinimum = getEstimatedMinimumPayment(_bidId);\n uint256 autopayFeeAmount = amountToRepayMinimum.percent(\n getAutopayFee()\n );\n\n // Pull lendingToken in from the borrower to this smart contract\n ERC20(lendingToken).safeTransferFrom(\n borrower,\n address(this),\n amountToRepayMinimum + autopayFeeAmount\n );\n\n // Transfer fee to msg sender\n ERC20(lendingToken).safeTransfer(_msgSender(), autopayFeeAmount);\n\n // Approve the lendingToken to tellerV2\n ERC20(lendingToken).approve(address(tellerV2), amountToRepayMinimum);\n\n // Use that lendingToken to repay the loan\n tellerV2.repayLoan(_bidId, amountToRepayMinimum);\n\n emit AutoPaidLoanMinimum(_bidId, msg.sender);\n }\n\n function getEstimatedMinimumPayment(uint256 _bidId)\n public\n virtual\n returns (uint256 _amount)\n {\n Payment memory estimatedPayment = tellerV2.calculateAmountDue(_bidId);\n\n _amount = estimatedPayment.principal + estimatedPayment.interest;\n }\n}\n" - }, - "contracts/mock/TellerV2SolMock.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"../TellerV2.sol\";\nimport \"../interfaces/ITellerV2.sol\";\nimport \"../TellerV2Context.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport { LoanDetails, Payment, BidState } from \"../TellerV2Storage.sol\";\n\n/*\nThis is only used for sol test so its named specifically to avoid being used for the typescript tests.\n*/\ncontract TellerV2SolMock is ITellerV2, TellerV2Storage {\n function setMarketRegistry(address _marketRegistry) public {\n marketRegistry = IMarketRegistry(_marketRegistry);\n }\n\n function getMarketRegistry() external view returns (IMarketRegistry) {\n return marketRegistry;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketId,\n uint256 _principal,\n uint32 _duration,\n uint16,\n string calldata,\n address _receiver\n ) public returns (uint256 bidId_) {\n bidId_ = bidId;\n\n Bid storage bid = bids[bidId];\n bid.borrower = msg.sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n bidId++;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public returns (uint256 bidId_) {}\n\n function repayLoanMinimum(uint256 _bidId) external {}\n\n function repayLoanFull(uint256 _bidId) external {}\n\n function repayLoan(uint256 _bidId, uint256 _amount) public {\n Bid storage bid = bids[_bidId];\n\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n msg.sender,\n address(this),\n _amount\n );\n }\n\n /*\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n function lenderAcceptBid(uint256 _bidId)\n public\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n Bid storage bid = bids[_bidId];\n\n bid.lender = msg.sender;\n\n //send tokens to caller\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n bid.lender,\n bid.receiver,\n bid.loanDetails.principal\n );\n //for the reciever\n\n return (0, bid.loanDetails.principal, 0);\n }\n\n function getBidState(uint256 _bidId) public view returns (BidState) {\n return bids[_bidId].state;\n }\n\n function getLoanDetails(uint256 _bidId)\n public\n view\n returns (LoanDetails memory)\n {\n return bids[_bidId].loanDetails;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n public\n view\n returns (uint256[] memory)\n {}\n\n function isLoanDefaulted(uint256 _bidId) public view returns (bool) {}\n\n function isPaymentLate(uint256 _bidId) public view returns (bool) {}\n\n function getLoanBorrower(uint256 _bidId)\n external\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n function getLoanLender(uint256 _bidId)\n external\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function setLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp) public {\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n}\n" - }, - "contracts/interfaces/ITellerV2Autopay.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Autopay {\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external;\n\n function autoPayLoanMinimum(uint256 _bidId) external;\n\n function initialize(uint16 _newFee, address _newOwner) external;\n\n function setAutopayFee(uint16 _newFee) external;\n}\n" - }, - "contracts/tests/MarketRegistry_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"../TellerV2Storage.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\nimport \"./Test_Helpers.sol\";\n\n/*\n\nThis should have more unit tests that operate on MarketRegistry.sol \n\n*/\n\ncontract MarketRegistry_Test is Testable, TellerV2 {\n User private marketOwner;\n User private borrower;\n User private lender;\n\n WethMock wethMock;\n\n constructor() TellerV2(address(address(0))) {}\n\n function setup_beforeAll() public {\n //wethMock = new WethMock();\n\n marketOwner = new User(address(this));\n borrower = new User(address(this));\n lender = new User(address(this));\n\n lenderCommitmentForwarder = address(0);\n marketRegistry = IMarketRegistry(new MarketRegistry());\n reputationManager = IReputationManager(new ReputationManager());\n }\n\n function createMarket_test() public {\n // Standard seconds payment cycle\n marketOwner.createMarket(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n \"uri://\"\n );\n (\n uint32 paymentCycleDuration,\n PaymentCycleType paymentCycle\n ) = marketRegistry.getPaymentCycle(1);\n\n require(\n paymentCycle == PaymentCycleType.Seconds,\n \"Market payment cycle type incorrectly created\"\n );\n\n require(\n paymentCycleDuration == 8000,\n \"Market payment cycle duration set incorrectly\"\n );\n\n // Monthly payment cycle\n marketOwner.createMarket(\n address(marketRegistry),\n 0,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Monthly,\n \"uri://\"\n );\n (paymentCycleDuration, paymentCycle) = marketRegistry.getPaymentCycle(\n 2\n );\n\n require(\n paymentCycle == PaymentCycleType.Monthly,\n \"Monthly market payment cycle type incorrectly created\"\n );\n\n require(\n paymentCycleDuration == 30 days,\n \"Monthly market payment cycle duration set incorrectly\"\n );\n\n // Monthly payment cycle should fail\n bool createFailed;\n try\n marketOwner.createMarket(\n address(marketRegistry),\n 3000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Monthly,\n \"uri://\"\n )\n {} catch {\n createFailed = true;\n }\n require(createFailed, \"Monthly market should not have been created\");\n }\n}\n" - }, - "contracts/tests/CollateralEscrow_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\n\nimport { CollateralEscrowV1 } from \"../escrow/CollateralEscrowV1.sol\";\nimport \"../mock/WethMock.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport { CollateralType, CollateralEscrowV1 } from \"../escrow/CollateralEscrowV1.sol\";\n\ncontract CollateralEscrow_Test is Testable {\n BeaconProxy private proxy_;\n User private borrower;\n WethMock wethMock;\n uint256 amount = 1000;\n\n function setup_beforeAll() public {\n // Deploy implementation\n CollateralEscrowV1 escrowImplementation = new CollateralEscrowV1();\n // Deploy beacon contract with implementation\n UpgradeableBeacon escrowBeacon = new UpgradeableBeacon(\n address(escrowImplementation)\n );\n // Deploy escrow\n wethMock = new WethMock();\n borrower = new User(escrowBeacon, address(wethMock));\n\n uint256 borrowerBalance = 50000;\n payable(address(borrower)).transfer(borrowerBalance);\n borrower.depositToWeth(borrowerBalance);\n }\n\n function depositAsset_test() public {\n _depositAsset();\n }\n\n function withdrawAsset_test() public {\n _depositAsset();\n\n borrower.withdraw(address(wethMock), amount, address(borrower));\n\n uint256 storedBalance = borrower.getBalance(address(wethMock));\n\n Test.eq(storedBalance, 0, \"Escrow withdraw unsuccessful\");\n\n try borrower.withdraw(address(wethMock), amount, address(borrower)) {\n Test.fail(\"No collateral balance for asset\");\n } catch Error(string memory reason) {\n Test.eq(\n reason,\n \"No collateral balance for asset\",\n \"Should not be able to withdraw already withdrawn assets\"\n );\n } catch {\n Test.fail(\"Unknown error\");\n }\n }\n\n function _depositAsset() internal {\n borrower.approveWeth(amount);\n\n borrower.deposit(CollateralType.ERC20, address(wethMock), amount, 0);\n\n uint256 storedBalance = borrower.getBalance(address(wethMock));\n\n Test.eq(storedBalance, amount, \"Escrow deposit unsuccessful\");\n }\n}\n\ncontract User {\n CollateralEscrowV1 public escrow;\n address public immutable wethMock;\n\n constructor(UpgradeableBeacon escrowBeacon, address _wethMock) {\n // Deploy escrow\n BeaconProxy proxy_ = new BeaconProxy(\n address(escrowBeacon),\n abi.encodeWithSelector(CollateralEscrowV1.initialize.selector, 0)\n );\n escrow = CollateralEscrowV1(address(proxy_));\n wethMock = _wethMock;\n }\n\n function deposit(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) public {\n escrow.depositAsset(\n _collateralType,\n _collateralAddress,\n _amount,\n _tokenId\n );\n }\n\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) public {\n escrow.withdraw(_collateralAddress, _amount, _recipient);\n }\n\n function depositToWeth(uint256 amount) public {\n IWETH(wethMock).deposit{ value: amount }();\n }\n\n function approveWeth(uint256 amount) public {\n ERC20(wethMock).approve(address(escrow), amount);\n }\n\n function getBalance(address _collateralAddress)\n public\n returns (uint256 amount_)\n {\n (, amount_, , ) = escrow.collateralBalances(_collateralAddress);\n }\n\n receive() external payable {}\n}\n" - }, - "contracts/tests/LenderCommitmentForwarder_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"./resolvers/TestERC20Token.sol\";\nimport \"../TellerV2MarketForwarder.sol\";\nimport \"../TellerV2Context.sol\";\nimport { Testable } from \"./Testable.sol\";\nimport { LenderCommitmentForwarder } from \"../LenderCommitmentForwarder.sol\";\n\nimport { Collateral, CollateralType } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\n/* \n add tests for each token type \n\n add test for conversion of collateral type -- simple \n\n */\n\ncontract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder {\n LenderCommitmentForwarderTest_TellerV2Mock private tellerV2Mock;\n MarketRegistryMock mockMarketRegistry;\n\n LenderCommitmentUser private marketOwner;\n LenderCommitmentUser private lender;\n LenderCommitmentUser private borrower;\n\n // address tokenAddress;\n uint256 marketId;\n uint256 maxAmount;\n\n address[] emptyArray;\n address[] borrowersArray;\n\n uint32 maxLoanDuration;\n uint16 minInterestRate;\n uint32 expiration;\n\n bool acceptBidWasCalled;\n bool submitBidWasCalled;\n bool submitBidWithCollateralWasCalled;\n\n TestERC20Token principalToken;\n uint8 constant principalTokenDecimals = 18;\n\n TestERC20Token collateralToken;\n uint8 constant collateralTokenDecimals = 6;\n\n constructor()\n LenderCommitmentForwarder(\n address(new LenderCommitmentForwarderTest_TellerV2Mock()), ///_protocolAddress\n address(new MarketRegistryMock(address(0)))\n )\n {}\n\n function setup_beforeAll() public {\n tellerV2Mock = LenderCommitmentForwarderTest_TellerV2Mock(\n address(getTellerV2())\n );\n mockMarketRegistry = MarketRegistryMock(address(getMarketRegistry()));\n\n marketOwner = new LenderCommitmentUser(address(tellerV2Mock), (this));\n borrower = new LenderCommitmentUser(address(tellerV2Mock), (this));\n lender = new LenderCommitmentUser(address(tellerV2Mock), (this));\n tellerV2Mock.__setMarketOwner(marketOwner);\n\n mockMarketRegistry.setMarketOwner(address(marketOwner));\n\n //tokenAddress = address(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);\n marketId = 2;\n maxAmount = 100000000000000000000;\n maxLoanDuration = 2480000;\n minInterestRate = 3000;\n expiration = uint32(block.timestamp) + uint32(64000);\n\n marketOwner.setTrustedMarketForwarder(marketId, address(this));\n lender.approveMarketForwarder(marketId, address(this));\n\n borrowersArray = new address[](1);\n borrowersArray[0] = address(borrower);\n\n principalToken = new TestERC20Token(\n \"Test Wrapped ETH\",\n \"TWETH\",\n 0,\n principalTokenDecimals\n );\n\n collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n collateralTokenDecimals\n );\n\n delete acceptBidWasCalled;\n delete submitBidWasCalled;\n delete submitBidWithCollateralWasCalled;\n\n delete commitmentCount;\n }\n\n function _createCommitment(\n CommitmentCollateralType _collateralType,\n uint256 _maxPrincipalPerCollateral\n ) internal returns (Commitment storage commitment_) {\n commitment_ = commitments[0];\n commitment_.marketId = marketId;\n commitment_.principalTokenAddress = address(principalToken);\n commitment_.maxPrincipal = maxAmount;\n commitment_.maxDuration = maxLoanDuration;\n commitment_.minInterestRate = minInterestRate;\n commitment_.expiration = expiration;\n commitment_.lender = address(lender);\n\n commitment_.collateralTokenType = _collateralType;\n commitment_.maxPrincipalPerCollateralAmount =\n _maxPrincipalPerCollateral *\n 10**principalTokenDecimals;\n\n if (_collateralType == CommitmentCollateralType.ERC20) {\n commitment_.collateralTokenAddress = address(collateralToken);\n } else if (_collateralType == CommitmentCollateralType.ERC721) {\n commitment_.collateralTokenAddress = address(\n 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\n );\n } else if (_collateralType == CommitmentCollateralType.ERC1155) {\n commitment_.collateralTokenAddress = address(\n 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\n );\n }\n }\n\n function createCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage existingCommitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6 * 1e18\n );\n\n lender._createCommitment(existingCommitment, emptyArray);\n }\n\n function updateCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage existingCommitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n Test.eq(\n address(lender),\n existingCommitment.lender,\n \"Not the owner of created commitment\"\n );\n\n lender._updateCommitment(commitmentId, existingCommitment);\n }\n\n function deleteCommitment_test() public {\n uint256 commitmentId = 0;\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n Test.eq(\n commitment.lender,\n address(lender),\n \"Not the owner of created commitment\"\n );\n\n lender._deleteCommitment(commitmentId);\n\n Test.eq(\n commitment.lender,\n address(0),\n \"The commitment was not deleted\"\n );\n }\n\n function acceptCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n Test.eq(\n acceptBidWasCalled,\n false,\n \"Expect accept bid not called before exercise\"\n );\n\n uint256 bidId = borrower._acceptCommitment(\n commitmentId,\n maxAmount - 100, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n\n Test.eq(\n commitment.maxPrincipal == 100,\n true,\n \"Commitment max principal was not decremented\"\n );\n\n bidId = borrower._acceptCommitment(\n commitmentId,\n 100, //principalAmount\n 100, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(commitment.maxPrincipal == 0, true, \"commitment not accepted\");\n\n bool acceptCommitTwiceFails;\n\n try\n borrower._acceptCommitment(\n commitmentId,\n 100, //principalAmount\n 100, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n acceptCommitTwiceFails = true;\n }\n\n Test.eq(\n acceptCommitTwiceFails,\n true,\n \"Should fail when accepting commit twice\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_valid_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n uint256 bidId = borrower._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_invalid_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n bool acceptCommitAsMarketOwnerFails;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n acceptCommitAsMarketOwnerFails = true;\n }\n\n Test.eq(\n acceptCommitAsMarketOwnerFails,\n true,\n \"Should fail when accepting as invalid borrower\"\n );\n\n lender._updateCommitmentBorrowers(commitmentId, emptyArray);\n\n acceptBidWasCalled = false;\n\n marketOwner._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_reset_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n lender._updateCommitmentBorrowers(commitmentId, emptyArray);\n\n marketOwner._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentFailsWithInsufficientCollateral_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n bool failedToAcceptCommitment;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n 0, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n failedToAcceptCommitment = true;\n }\n\n Test.eq(\n failedToAcceptCommitment,\n true,\n \"Should fail to accept commitment with insufficient collateral\"\n );\n }\n\n function acceptCommitmentFailsWithInvalidAmount_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC721,\n 1000e6\n );\n\n bool failedToAcceptCommitment;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n 2, //collateralAmount\n 22, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n failedToAcceptCommitment = true;\n }\n\n Test.eq(\n failedToAcceptCommitment,\n true,\n \"Should fail to accept commitment with invalid amount for ERC721\"\n );\n }\n\n function decrementCommitment_before() public {}\n\n function decrementCommitment_test() public {\n uint256 commitmentId = 0;\n uint256 _decrementAmount = 22;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n _decrementCommitment(commitmentId, _decrementAmount);\n\n Test.eq(\n commitment.maxPrincipal == maxAmount - _decrementAmount,\n true,\n \"Commitment max principal was not decremented\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 700 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_700_USDC__500_per_WETH_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test Wrapped ETH\",\n \"TWETH\",\n 0,\n 18\n );\n Test.eq(\n super.getRequiredCollateral(\n 700 * (1e6), // 700 USDC loan\n 500 * (1e6) * (1e6), // 500 USDC loan allowed per WETH, expanded by principal token decimals\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 14e17, // 1.4 WETH\n \"expected 1.4 WETH collateral\"\n );\n }\n\n /**\n * collateral token = NFT (10**0)\n * principal token = USDC (10**6)\n * principal = 700 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_700_USDC_loan__500_per_ERC1155_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 700e6, // 700 USDC loan\n 500e6 * (10**6) * (10**0), // 500 USDC per NFT\n CommitmentCollateralType.ERC1155,\n address(0),\n address(usdcToken)\n ),\n 2, // 2 NFTs\n \"expected 2 NFTs collateral\"\n );\n }\n\n /**\n * collateral token = NFT (10**0)\n * principal token = USDC (10**6)\n * principal = 500 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_500_USDC_loan__500_per_ERC721_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 500e6, // 7500 USDC loan\n 500e6 * (1e6), // 500 USDC per NFT, expanded by principal token decimals\n CommitmentCollateralType.ERC721,\n address(0),\n address(usdcToken)\n ),\n 1, // 1 NFT\n \"expected 1 NFT collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 WETH\n * max principal per collateral = 0.00059 WETH\n */\n function getRequiredCollateral_1_WETH_loan__00059_per_USDC_test() public {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e18, // 1 WETH loan\n 59e13 * (1e18), // 0.00059 WETH per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1_694_915_255, // 1,694.915255 USDC (1694.915254237 rounded up to 6 decimals)\n \"expected 1,694.915255 USDC collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 1000 USDC $\n * max principal per collateral = 1.0 WETH\n */\n function getRequiredCollateral_1000_USDC_loan_9_gwei_per_usdc_unit_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 1000 * (1e6), // 1000 USDC loan //principal\n 1e9 * (1e6), // 1000000000 wei per USDC base unit //ratio\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 1e18, // 1 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 8888 USDC $\n * max principal per collateral = 1 gwei per USDDC base unit\n */\n function getRequiredCollateral_8888_USDC_loan__9_gwei_per_usdc_unit_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 8888 * (1e6), // 8888 USDC loan //principal\n 1e9 * (1e6), // 1000000000 wei per USDC base unit //ratio\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 8888e15, // 8.888 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**8)\n * principal = 8888 USDC\n * max principal per collateral = 8888000000 wei per USDC base unit\n */\n function getRequiredCollateral_8888_USDC_loan__unit_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 8888 * (1e6), // 8888 USDC loan //principal\n 8888000000 * (1e6), // 8888000000 wei per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 1e18, // 1 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = GWEI (10**9)\n * principal = 6 GWEI\n * max principal per collateral = 0.00059 USDC per gwei\n */\n function getRequiredCollateral_6_GWEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token gweiToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 9\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 6 gwei, // 6 GWEI loan\n 59e13 * (1e9), // 0.00059 USDC per gwei\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(gweiToken)\n ),\n 11, // 0.000011 USDC (0.000010169 rounded up to 6 decimals)\n \"expected 0.000011 USDC collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WEI (10**0)\n * principal = 1 WEI\n * max principal per collateral = // 0.00059 WETH per usdc base unit\n */\n function getRequiredCollateral_1_WEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1, // 1 WEI loan\n 59e13 * 1e18, // 0.00059 WETH per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1, // 0.001695 USDC rounded up\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 GWEI\n * max principal per collateral = 0.00059 WETH per gwei\n */\n function getRequiredCollateral_1_GWEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e9, // 1 GWEI loan\n 59e13 * 1e18, // 0.00059 WETH per USDC base unit (hence why not multiplying by 1e6)\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 2,\n \"expected at least 2 units of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 GWEI\n * max principal per collateral = 1 wei per usdc $\n */\n function getRequiredCollateral_1_wei_loan__1_Wei_per_USDC_test() public {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e9, // 1 gwei\n (1 * 1e6) * 1e18, // must provide 1:1 ratio usdc $ to wei\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1e3 * 1e6, // 1000 usdc $\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 wei\n * max principal per collateral = 1 wei per usdc $\n */\n function getRequiredCollateral_1_wei_loan__1_Wei_per_USDC_unit_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1, // 1 wei\n (1 * 1e6) * 1e18, // must provide 1 usdc to get loan of 1 wei, expanded by principal decimals\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1, // 1 usdc base unit\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /*\n Overrider methods for exercise \n */\n\n function _submitBid(CreateLoanArgs memory, address)\n internal\n override\n returns (uint256 bidId)\n {\n submitBidWasCalled = true;\n return 1;\n }\n\n function _submitBidWithCollateral(\n CreateLoanArgs memory,\n Collateral[] memory,\n address\n ) internal override returns (uint256 bidId) {\n submitBidWithCollateralWasCalled = true;\n return 1;\n }\n\n function _acceptBid(uint256, address) internal override returns (bool) {\n acceptBidWasCalled = true;\n\n Test.eq(\n submitBidWithCollateralWasCalled,\n true,\n \"Submit bid must be called before accept bid\"\n );\n\n return true;\n }\n}\n\ncontract LenderCommitmentUser is User {\n LenderCommitmentForwarder public immutable commitmentForwarder;\n\n constructor(\n address _tellerV2,\n LenderCommitmentForwarder _commitmentForwarder\n ) User(_tellerV2) {\n commitmentForwarder = _commitmentForwarder;\n }\n\n function _createCommitment(\n LenderCommitmentForwarder.Commitment calldata _commitment,\n address[] calldata borrowerAddressList\n ) public returns (uint256) {\n return\n commitmentForwarder.createCommitment(\n _commitment,\n borrowerAddressList\n );\n }\n\n function _updateCommitment(\n uint256 commitmentId,\n LenderCommitmentForwarder.Commitment calldata _commitment\n ) public {\n commitmentForwarder.updateCommitment(commitmentId, _commitment);\n }\n\n function _updateCommitmentBorrowers(\n uint256 commitmentId,\n address[] calldata borrowerAddressList\n ) public {\n commitmentForwarder.updateCommitmentBorrowers(\n commitmentId,\n borrowerAddressList\n );\n }\n\n function _acceptCommitment(\n uint256 commitmentId,\n uint256 principal,\n uint256 collateralAmount,\n uint256 collateralTokenId,\n address collateralTokenAddress,\n uint16 interestRate,\n uint32 loanDuration\n ) public returns (uint256) {\n return\n commitmentForwarder.acceptCommitment(\n commitmentId,\n principal,\n collateralAmount,\n collateralTokenId,\n collateralTokenAddress,\n interestRate,\n loanDuration\n );\n }\n\n function _deleteCommitment(uint256 _commitmentId) public {\n commitmentForwarder.deleteCommitment(_commitmentId);\n }\n}\n\n//Move to a helper file !\ncontract LenderCommitmentForwarderTest_TellerV2Mock is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "contracts/tests/MarketForwarder_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport { Testable } from \"./Testable.sol\";\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\nimport { IMarketRegistry } from \"../interfaces/IMarketRegistry.sol\";\nimport { TellerV2MarketForwarder } from \"../TellerV2MarketForwarder.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\ncontract MarketForwarder_Test is Testable, TellerV2MarketForwarder {\n MarketForwarderTester private tellerV2Mock;\n\n MarketRegistryMock mockMarketRegistry;\n\n uint256 private marketId;\n MarketForwarderUser private marketOwner;\n MarketForwarderUser private user1;\n MarketForwarderUser private user2;\n\n constructor()\n TellerV2MarketForwarder(\n address(new MarketForwarderTester()),\n address(new MarketRegistryMock(address(0)))\n )\n {}\n\n function setup_beforeAll() public {\n mockMarketRegistry = MarketRegistryMock(address(getMarketRegistry()));\n tellerV2Mock = MarketForwarderTester(address(getTellerV2()));\n\n marketOwner = new MarketForwarderUser(address(tellerV2Mock));\n user1 = new MarketForwarderUser(address(tellerV2Mock));\n user2 = new MarketForwarderUser(address(tellerV2Mock));\n\n tellerV2Mock.__setMarketOwner(marketOwner);\n\n mockMarketRegistry.setMarketOwner(address(marketOwner));\n\n delete marketId;\n }\n\n function setTrustedMarketForwarder_before() public {\n marketOwner.setTrustedMarketForwarder(marketId, address(this));\n }\n\n function setTrustedMarketForwarder_test() public {\n Test.eq(\n tellerV2Mock.isTrustedMarketForwarder(marketId, address(this)),\n true,\n \"Trusted forwarder was not set\"\n );\n }\n\n function approveMarketForwarder_before() public {\n setTrustedMarketForwarder_before();\n\n user1.approveMarketForwarder(marketId, address(this));\n user2.approveMarketForwarder(marketId, address(this));\n }\n\n function approveMarketForwarder_test() public {\n Test.eq(\n tellerV2Mock.hasApprovedMarketForwarder(\n marketId,\n address(this),\n address(user1)\n ),\n true,\n \"Borrower did not set market forwarder approval\"\n );\n Test.eq(\n tellerV2Mock.hasApprovedMarketForwarder(\n marketId,\n address(this),\n address(user2)\n ),\n true,\n \"Lender did not set market forwarder approval\"\n );\n }\n\n function forwardUserCall_before() public {\n approveMarketForwarder_before();\n }\n\n function forwardUserCall_test() public {\n address expectedSender = address(user1);\n address sender = abi.decode(\n _forwardCall(\n abi.encodeWithSelector(\n MarketForwarderTester.getSenderForMarket.selector,\n marketId\n ),\n expectedSender\n ),\n (address)\n );\n Test.eq(\n sender,\n expectedSender,\n \"Sender address for market does not match expected\"\n );\n\n bytes memory expectedData = abi.encodeWithSelector(\n MarketForwarderTester.getDataForMarket.selector,\n marketId\n );\n bytes memory data = abi.decode(\n _forwardCall(expectedData, expectedSender),\n (bytes)\n );\n Test.eq0(\n data,\n expectedData,\n \"Function calldata for market does not match expected\"\n );\n }\n}\n\n//This should use the user helper !!\ncontract MarketForwarderUser is User {\n constructor(address _tellerV2) User(_tellerV2) {}\n}\n\n//Move to a helper\n//this is a tellerV2 mock\ncontract MarketForwarderTester is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "contracts/ProtocolFeeMock.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./ProtocolFee.sol\";\n\ncontract ProtocolFeeMock is ProtocolFee {\n bool public setProtocolFeeCalled;\n\n function initialize(uint16 _initFee) external initializer {\n __ProtocolFee_init(_initFee);\n }\n\n function setProtocolFee(uint16 newFee) public override onlyOwner {\n setProtocolFeeCalled = true;\n\n bool _isInitializing;\n assembly {\n _isInitializing := sload(1)\n }\n\n // Only call the actual function if we are not initializing\n if (!_isInitializing) {\n super.setProtocolFee(newFee);\n }\n }\n}\n" - }, - "contracts/tests/NextDueDate_test.sol": { - "content": "pragma solidity ^0.8.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract NextDueDate_Test is Testable, TellerV2 {\n Bid __bid;\n\n constructor() TellerV2(address(0)) {\n __bid.loanDetails.principal = 10000e6; // 10k USDC\n __bid.loanDetails.loanDuration = 365 days * 2; // 2 years\n __bid.terms.paymentCycle = 30 days; // 1 month\n __bid.terms.APR = 450; // 4.5%\n __bid.state = BidState.ACCEPTED;\n }\n\n function _01_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2020, 1, 31) // Leap year\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is Feb 29th\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2020, 2, 29));\n nextDueDate_runner(expectedDate);\n }\n\n function _02_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2020, 2, 29)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 29th\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2020, 3, 29));\n nextDueDate_runner(expectedDate);\n }\n\n function _03_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 2, 1)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 1st\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2023, 3, 1));\n nextDueDate_runner(expectedDate);\n }\n\n function _04_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 1, 31)\n );\n __bid.loanDetails.lastRepaidTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 2, 1)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 31st\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2023, 3, 31));\n nextDueDate_runner(expectedDate);\n }\n\n function nextDueDate_runner(uint256 _expected) private {\n uint256 nextDueDate = calculateNextDueDate(1);\n Test.eq(nextDueDate, _expected, \"Next due date incorrect\");\n }\n}\n" - }, - "contracts/tests/GetMetaDataURI_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract GetMetaDataURI_Test is Testable, TellerV2 {\n constructor() TellerV2(address(0)) {}\n\n function setup_beforeAll() public {\n // Old depreciated _metadataURI on bid struct\n bids[0]\n ._metadataURI = 0x0000000000000000000000000000000086004f3f419f88be1cab574b4bd01b6d;\n // New metadataURI from uris mapping\n uris[59] = \"ipfs://QmMyDataHash\";\n }\n\n function getMetaDataURI_test() public {\n string memory oldURI = getMetadataURI(0);\n Test.eq(\n oldURI,\n \"0x0000000000000000000000000000000086004f3f419f88be1cab574b4bd01b6d\",\n \"Expected URI does not match stored depreciated value in the Bid struct\"\n );\n string memory newURI = getMetadataURI(59);\n Test.eq(\n newURI,\n \"ipfs://QmMyDataHash\",\n \"Expected URI does not match new value in uri mapping\"\n );\n }\n}\n" - }, - "contracts/EAS/TellerASEIP712Verifier.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IEASEIP712Verifier.sol\";\n\n/**\n * @title EIP712 typed signatures verifier for EAS delegated attestations.\n */\ncontract TellerASEIP712Verifier is IEASEIP712Verifier {\n error InvalidSignature();\n\n string public constant VERSION = \"0.8\";\n\n // EIP712 domain separator, making signatures from different domains incompatible.\n bytes32 public immutable DOMAIN_SEPARATOR; // solhint-disable-line var-name-mixedcase\n\n // The hash of the data type used to relay calls to the attest function. It's the value of\n // keccak256(\"Attest(address recipient,bytes32 schema,uint256 expirationTime,bytes32 refUUID,bytes data,uint256 nonce)\").\n bytes32 public constant ATTEST_TYPEHASH =\n 0x39c0608dd995a3a25bfecb0fffe6801a81bae611d94438af988caa522d9d1476;\n\n // The hash of the data type used to relay calls to the revoke function. It's the value of\n // keccak256(\"Revoke(bytes32 uuid,uint256 nonce)\").\n bytes32 public constant REVOKE_TYPEHASH =\n 0xbae0931f3a99efd1b97c2f5b6b6e79d16418246b5055d64757e16de5ad11a8ab;\n\n // Replay protection nonces.\n mapping(address => uint256) private _nonces;\n\n /**\n * @dev Creates a new EIP712Verifier instance.\n */\n constructor() {\n uint256 chainId;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n chainId := chainid()\n }\n\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n ),\n keccak256(bytes(\"EAS\")),\n keccak256(bytes(VERSION)),\n chainId,\n address(this)\n )\n );\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function getNonce(address account)\n external\n view\n override\n returns (uint256)\n {\n return _nonces[account];\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(\n ATTEST_TYPEHASH,\n recipient,\n schema,\n expirationTime,\n refUUID,\n keccak256(data),\n _nonces[attester]++\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n if (recoveredAddress == address(0) || recoveredAddress != attester) {\n revert InvalidSignature();\n }\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function revoke(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(REVOKE_TYPEHASH, uuid, _nonces[attester]++)\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n if (recoveredAddress == address(0) || recoveredAddress != attester) {\n revert InvalidSignature();\n }\n }\n}\n" - }, - "contracts/EAS/TellerASRegistry.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../Types.sol\";\nimport \"../interfaces/IASRegistry.sol\";\nimport \"../interfaces/IASResolver.sol\";\n\n/**\n * @title The global AS registry.\n */\ncontract TellerASRegistry is IASRegistry {\n error AlreadyExists();\n\n string public constant VERSION = \"0.8\";\n\n // The global mapping between AS records and their IDs.\n mapping(bytes32 => ASRecord) private _registry;\n\n // The global counter for the total number of attestations.\n uint256 private _asCount;\n\n /**\n * @inheritdoc IASRegistry\n */\n function register(bytes calldata schema, IASResolver resolver)\n external\n override\n returns (bytes32)\n {\n uint256 index = ++_asCount;\n\n ASRecord memory asRecord = ASRecord({\n uuid: EMPTY_UUID,\n index: index,\n schema: schema,\n resolver: resolver\n });\n\n bytes32 uuid = _getUUID(asRecord);\n if (_registry[uuid].uuid != EMPTY_UUID) {\n revert AlreadyExists();\n }\n\n asRecord.uuid = uuid;\n _registry[uuid] = asRecord;\n\n emit Registered(uuid, index, schema, resolver, msg.sender);\n\n return uuid;\n }\n\n /**\n * @inheritdoc IASRegistry\n */\n function getAS(bytes32 uuid)\n external\n view\n override\n returns (ASRecord memory)\n {\n return _registry[uuid];\n }\n\n /**\n * @inheritdoc IASRegistry\n */\n function getASCount() external view override returns (uint256) {\n return _asCount;\n }\n\n /**\n * @dev Calculates a UUID for a given AS.\n *\n * @param asRecord The input AS.\n *\n * @return AS UUID.\n */\n function _getUUID(ASRecord memory asRecord) private pure returns (bytes32) {\n return keccak256(abi.encodePacked(asRecord.schema, asRecord.resolver));\n }\n}\n" - }, - "contracts/TellerV2Mock.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2.sol\";\n\ncontract TellerV2Mock is TellerV2 {\n constructor(address trustedForwarder) TellerV2(trustedForwarder) {}\n\n function mockBid(Bid calldata _bid) external {\n bids[bidId] = _bid;\n borrowerBids[_msgSender()].push(bidId);\n bidId++;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId, uint32 _timestamp) external {\n require(_timestamp > 0, \"Accepted timestamp 0\");\n bids[_bidId].loanDetails.acceptedTimestamp = _timestamp;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId) external {\n bids[_bidId].loanDetails.acceptedTimestamp = uint32(block.timestamp);\n }\n\n function mockLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp)\n external\n {\n require(_timestamp > 0, \"Repaid timestamp 0\");\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n\n function setVersion(uint256 _version) public {\n version = _version;\n }\n}\n" - }, - "contracts/TLR.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract TLR is ERC20Votes, Ownable {\n uint224 private immutable MAX_SUPPLY;\n\n /**\n * @dev Sets the value of the `cap`. This value is immutable, it can only be\n * set once during construction.\n */\n constructor(uint224 _supplyCap, address tokenOwner)\n ERC20(\"Teller\", \"TLR\")\n ERC20Permit(\"Teller\")\n {\n require(_supplyCap > 0, \"ERC20Capped: cap is 0\");\n MAX_SUPPLY = _supplyCap;\n _transferOwnership(tokenOwner);\n }\n\n /**\n * @dev Max supply has been overridden to cap the token supply upon initialization of the contract\n * @dev See OpenZeppelin's implementation of ERC20Votes _mint() function\n */\n function _maxSupply() internal view override returns (uint224) {\n return MAX_SUPPLY;\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function mint(address account, uint256 amount) external onlyOwner {\n _mint(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) external onlyOwner {\n _burn(account, amount);\n }\n}\n" - }, - "contracts/type-imports.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n//SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\n" - }, - "contracts/TellerV0Storage.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/*\n\n THIS IS ONLY USED FOR SUBGRAPH \n \n\n*/\n\ncontract TellerV0Storage {\n enum BidState {\n NONEXISTENT,\n PENDING,\n CANCELLED,\n ACCEPTED,\n PAID,\n LIQUIDATED\n }\n\n /**\n * @notice Represents a total amount for a payment.\n * @param principal Amount that counts towards the principal.\n * @param interest Amount that counts toward interest.\n */\n struct Payment {\n uint256 principal;\n uint256 interest;\n }\n\n /**\n * @notice Details about the loan.\n * @param lendingToken The token address for the loan.\n * @param principal The amount of tokens initially lent out.\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\n * @param loanDuration The duration of the loan.\n */\n struct LoanDetails {\n ERC20 lendingToken;\n uint256 principal;\n Payment totalRepaid;\n uint32 timestamp;\n uint32 acceptedTimestamp;\n uint32 lastRepaidTimestamp;\n uint32 loanDuration;\n }\n\n /**\n * @notice Details about a loan request.\n * @param borrower Account address who is requesting a loan.\n * @param receiver Account address who will receive the loan amount.\n * @param lender Account address who accepted and funded the loan request.\n * @param marketplaceId ID of the marketplace the bid was submitted to.\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\n * @param loanDetails Struct of the specific loan details.\n * @param terms Struct of the loan request terms.\n * @param state Represents the current state of the loan.\n */\n struct Bid0 {\n address borrower;\n address receiver;\n address _lender; // DEPRECATED\n uint256 marketplaceId;\n bytes32 _metadataURI; // DEPRECATED\n LoanDetails loanDetails;\n Terms terms;\n BidState state;\n }\n\n /**\n * @notice Information on the terms of a loan request\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\n */\n struct Terms {\n uint256 paymentCycleAmount;\n uint32 paymentCycle;\n uint16 APR;\n }\n\n // Mapping of bidId to bid information.\n mapping(uint256 => Bid0) public bids;\n}\n" - }, - "contracts/interfaces/IUniswapV2Router.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n @notice This interface defines the different functions available for a UniswapV2Router.\n @author develop@teller.finance\n */\ninterface IUniswapV2Router {\n function factory() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETH(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function quote(uint256 amountA, uint256 reserveA, uint256 reserveB)\n external\n pure\n returns (uint256 amountB);\n\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountOut);\n\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountIn);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n /**\n @notice It returns the address of the canonical WETH address;\n */\n function WETH() external pure returns (address);\n\n /**\n @notice Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountIn The amount of input tokens to send.\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the output tokens.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n */\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /**\n @notice Swaps an exact amount of tokens for as much ETH as possible, along the route determined by the path. The first element of path is the input token, the last must be WETH, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountIn The amount of input tokens to send.\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the ETH.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n @dev If the to address is a smart contract, it must have the ability to receive ETH.\n */\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /**\n @notice Swaps an exact amount of ETH for as many output tokens as possible, along the route determined by the path. The first element of path must be WETH, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the output tokens.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n */\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapTokensForExactETH(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapETHForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\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/packages/contracts/deployments/goerli/solcInputs/976bca259bf89d14d50591c72cf76420.json b/packages/contracts/deployments/goerli/solcInputs/976bca259bf89d14d50591c72cf76420.json deleted file mode 100644 index a6f831e79..000000000 --- a/packages/contracts/deployments/goerli/solcInputs/976bca259bf89d14d50591c72cf76420.json +++ /dev/null @@ -1,425 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/CollateralManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n// Interfaces\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\";\nimport \"./interfaces/ICollateralManager.sol\";\nimport { Collateral, CollateralType, ICollateralEscrowV1 } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\nimport \"./interfaces/ITellerV2.sol\";\n\ncontract CollateralManager is OwnableUpgradeable, ICollateralManager {\n /* Storage */\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n ITellerV2 public tellerV2;\n address private collateralEscrowBeacon; // The address of the escrow contract beacon\n mapping(uint256 => address) public _escrows; // bidIds -> collateralEscrow\n // bidIds -> validated collateral info\n mapping(uint256 => CollateralInfo) internal _bidCollaterals;\n struct CollateralInfo {\n EnumerableSetUpgradeable.AddressSet collateralAddresses;\n mapping(address => Collateral) collateralInfo;\n }\n\n /* Events */\n event CollateralEscrowDeployed(uint256 _bidId, address _collateralEscrow);\n event CollateralCommitted(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n );\n event CollateralClaimed(uint256 _bidId);\n event CollateralDeposited(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n );\n event CollateralWithdrawn(\n uint256 _bidId,\n CollateralType _type,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId,\n address _recipient\n );\n\n /* Modifiers */\n modifier onlyTellerV2() {\n require(_msgSender() == address(tellerV2), \"Sender not authorized\");\n _;\n }\n\n /* External Functions */\n\n /**\n * @notice Initializes the collateral manager.\n * @param _collateralEscrowBeacon The address of the escrow implementation.\n * @param _tellerV2 The address of the protocol.\n */\n function initialize(address _collateralEscrowBeacon, address _tellerV2)\n external\n initializer\n {\n collateralEscrowBeacon = _collateralEscrowBeacon;\n tellerV2 = ITellerV2(_tellerV2);\n __Ownable_init_unchained();\n }\n\n /**\n * @notice Sets the address of the Beacon contract used for the collateral escrow contracts.\n * @param _collateralEscrowBeacon The address of the Beacon contract.\n */\n function setCollateralEscrowBeacon(address _collateralEscrowBeacon)\n external\n reinitializer(2)\n {\n collateralEscrowBeacon = _collateralEscrowBeacon;\n }\n\n /**\n * @notice Checks to see if a bid is backed by collateral.\n * @param _bidId The id of the bid to check.\n */\n\n function isBidCollateralBacked(uint256 _bidId) public returns (bool) {\n return _bidCollaterals[_bidId].collateralAddresses.length() > 0;\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral assets.\n * @return validation_ Boolean indicating if the collateral balances were validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral[] calldata _collateralInfo\n ) public returns (bool validation_) {\n address borrower = tellerV2.getLoanBorrower(_bidId);\n (validation_, ) = checkBalances(borrower, _collateralInfo);\n if (validation_) {\n for (uint256 i; i < _collateralInfo.length; i++) {\n Collateral memory info = _collateralInfo[i];\n _commitCollateral(_bidId, info);\n }\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral calldata _collateralInfo\n ) public returns (bool validation_) {\n address borrower = tellerV2.getLoanBorrower(_bidId);\n validation_ = _checkBalance(borrower, _collateralInfo);\n if (validation_) {\n _commitCollateral(_bidId, _collateralInfo);\n }\n }\n\n /**\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\n * @param _bidId The id of the associated bid.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function revalidateCollateral(uint256 _bidId)\n external\n returns (bool validation_)\n {\n Collateral[] memory collateralInfos = getCollateralInfo(_bidId);\n address borrower = tellerV2.getLoanBorrower(_bidId);\n (validation_, ) = _checkBalances(borrower, collateralInfos, true);\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral assets.\n */\n function checkBalances(\n address _borrowerAddress,\n Collateral[] calldata _collateralInfo\n ) public returns (bool validated_, bool[] memory checks_) {\n return _checkBalances(_borrowerAddress, _collateralInfo, false);\n }\n\n /**\n * @notice Deploys a new collateral escrow and deposits collateral.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function deployAndDeposit(uint256 _bidId) external onlyTellerV2 {\n if (isBidCollateralBacked(_bidId)) {\n (address proxyAddress, ) = _deployEscrow(_bidId);\n _escrows[_bidId] = proxyAddress;\n\n for (\n uint256 i;\n i < _bidCollaterals[_bidId].collateralAddresses.length();\n i++\n ) {\n _deposit(\n _bidId,\n _bidCollaterals[_bidId].collateralInfo[\n _bidCollaterals[_bidId].collateralAddresses.at(i)\n ]\n );\n }\n\n emit CollateralEscrowDeployed(_bidId, proxyAddress);\n }\n }\n\n /**\n * @notice Gets the address of a deployed escrow.\n * @notice _bidId The bidId to return the escrow for.\n * @return The address of the escrow.\n */\n function getEscrow(uint256 _bidId) external view returns (address) {\n return _escrows[_bidId];\n }\n\n /**\n * @notice Gets the collateral info for a given bid id.\n * @param _bidId The bidId to return the collateral info for.\n * @return infos_ The stored collateral info.\n */\n function getCollateralInfo(uint256 _bidId)\n public\n view\n returns (Collateral[] memory infos_)\n {\n CollateralInfo storage collateral = _bidCollaterals[_bidId];\n address[] memory collateralAddresses = collateral\n .collateralAddresses\n .values();\n infos_ = new Collateral[](collateralAddresses.length);\n for (uint256 i; i < collateralAddresses.length; i++) {\n infos_[i] = collateral.collateralInfo[collateralAddresses[i]];\n }\n }\n\n /**\n * @notice Withdraws deposited collateral from the created escrow of a bid that has been successfully repaid.\n * @param _bidId The id of the bid to withdraw collateral for.\n */\n function withdraw(uint256 _bidId) external {\n BidState bidState = tellerV2.getBidState(_bidId);\n if (bidState == BidState.PAID) {\n _withdraw(_bidId, tellerV2.getLoanBorrower(_bidId));\n } else if (tellerV2.isLoanDefaulted(_bidId)) {\n _withdraw(_bidId, tellerV2.getLoanLender(_bidId));\n emit CollateralClaimed(_bidId);\n } else {\n revert(\"collateral cannot be withdrawn\");\n }\n }\n\n /**\n * @notice Sends the deposited collateral to a liquidator of a bid.\n * @notice Can only be called by the protocol.\n * @param _bidId The id of the liquidated bid.\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\n */\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\n external\n onlyTellerV2\n {\n if (isBidCollateralBacked(_bidId)) {\n BidState bidState = tellerV2.getBidState(_bidId);\n require(\n bidState == BidState.LIQUIDATED,\n \"Loan has not been liquidated\"\n );\n _withdraw(_bidId, _liquidatorAddress);\n }\n }\n\n /* Internal Functions */\n\n /**\n * @notice Deploys a new collateral escrow.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function _deployEscrow(uint256 _bidId)\n internal\n returns (address proxyAddress_, address borrower_)\n {\n proxyAddress_ = _escrows[_bidId];\n // Get bid info\n borrower_ = tellerV2.getLoanBorrower(_bidId);\n if (proxyAddress_ == address(0)) {\n require(borrower_ != address(0), \"Bid does not exist\");\n\n BeaconProxy proxy = new BeaconProxy(\n collateralEscrowBeacon,\n abi.encodeWithSelector(\n ICollateralEscrowV1.initialize.selector,\n _bidId\n )\n );\n proxyAddress_ = address(proxy);\n }\n }\n\n function _deposit(uint256 _bidId, Collateral memory collateralInfo)\n public\n payable\n {\n require(collateralInfo._amount > 0, \"Collateral not validated\");\n (address escrowAddress, address borrower) = _deployEscrow(_bidId);\n ICollateralEscrowV1 collateralEscrow = ICollateralEscrowV1(\n escrowAddress\n );\n // Pull collateral from borrower & deposit into escrow\n if (collateralInfo._collateralType == CollateralType.ERC20) {\n IERC20Upgradeable(collateralInfo._collateralAddress).transferFrom(\n borrower,\n address(this),\n collateralInfo._amount\n );\n IERC20Upgradeable(collateralInfo._collateralAddress).approve(\n escrowAddress,\n collateralInfo._amount\n );\n collateralEscrow.depositToken(\n collateralInfo._collateralAddress,\n collateralInfo._amount\n );\n } else if (collateralInfo._collateralType == CollateralType.ERC721) {\n IERC721Upgradeable(collateralInfo._collateralAddress).transferFrom(\n borrower,\n address(this),\n collateralInfo._tokenId\n );\n IERC721Upgradeable(collateralInfo._collateralAddress).approve(\n escrowAddress,\n collateralInfo._tokenId\n );\n collateralEscrow.depositAsset(\n CollateralType.ERC721,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n } else if (collateralInfo._collateralType == CollateralType.ERC1155) {\n bytes memory data;\n IERC1155Upgradeable(collateralInfo._collateralAddress)\n .safeTransferFrom(\n borrower,\n address(this),\n collateralInfo._tokenId,\n collateralInfo._amount,\n data\n );\n IERC1155Upgradeable(collateralInfo._collateralAddress)\n .setApprovalForAll(escrowAddress, true);\n collateralEscrow.depositAsset(\n CollateralType.ERC1155,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n }\n emit CollateralDeposited(\n _bidId,\n collateralInfo._collateralType,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId\n );\n }\n\n /**\n * @notice Withdraws collateral to a given receiver's address.\n * @param _bidId The id of the bid to withdraw collateral for.\n * @param _receiver The address to withdraw the collateral to.\n */\n function _withdraw(uint256 _bidId, address _receiver) internal {\n for (\n uint256 i;\n i < _bidCollaterals[_bidId].collateralAddresses.length();\n i++\n ) {\n // Get collateral info\n Collateral storage collateralInfo = _bidCollaterals[_bidId]\n .collateralInfo[\n _bidCollaterals[_bidId].collateralAddresses.at(i)\n ];\n // Withdraw collateral from escrow and send it to bid lender\n ICollateralEscrowV1(_escrows[_bidId]).withdraw(\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n _receiver\n );\n emit CollateralWithdrawn(\n _bidId,\n collateralInfo._collateralType,\n collateralInfo._collateralAddress,\n collateralInfo._amount,\n collateralInfo._tokenId,\n _receiver\n );\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function _commitCollateral(\n uint256 _bidId,\n Collateral memory _collateralInfo\n ) internal {\n CollateralInfo storage collateral = _bidCollaterals[_bidId];\n collateral.collateralAddresses.add(_collateralInfo._collateralAddress);\n collateral.collateralInfo[\n _collateralInfo._collateralAddress\n ] = _collateralInfo;\n emit CollateralCommitted(\n _bidId,\n _collateralInfo._collateralType,\n _collateralInfo._collateralAddress,\n _collateralInfo._amount,\n _collateralInfo._tokenId\n );\n }\n\n /**\n * @notice Checks the validity of a borrower's multiple collateral balances.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral assets.\n */\n function _checkBalances(\n address _borrowerAddress,\n Collateral[] memory _collateralInfo,\n bool _shortCircut\n ) internal returns (bool validated_, bool[] memory checks_) {\n checks_ = new bool[](_collateralInfo.length);\n validated_ = true;\n for (uint256 i; i < _collateralInfo.length; i++) {\n bool isValidated = _checkBalance(\n _borrowerAddress,\n _collateralInfo[i]\n );\n checks_[i] = isValidated;\n if (!isValidated) {\n validated_ = false;\n if (_shortCircut) {\n return (validated_, checks_);\n }\n }\n }\n }\n\n /**\n * @notice Checks the validity of a borrower's single collateral balance.\n * @param _borrowerAddress The address of the borrower holding the collateral.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balances were validated.\n */\n function _checkBalance(\n address _borrowerAddress,\n Collateral memory _collateralInfo\n ) internal returns (bool) {\n CollateralType collateralType = _collateralInfo._collateralType;\n if (collateralType == CollateralType.ERC20) {\n return\n _collateralInfo._amount <=\n IERC20Upgradeable(_collateralInfo._collateralAddress).balanceOf(\n _borrowerAddress\n );\n }\n if (collateralType == CollateralType.ERC721) {\n return\n _borrowerAddress ==\n IERC721Upgradeable(_collateralInfo._collateralAddress).ownerOf(\n _collateralInfo._tokenId\n );\n }\n if (collateralType == CollateralType.ERC1155) {\n return\n _collateralInfo._amount <=\n IERC1155Upgradeable(_collateralInfo._collateralAddress)\n .balanceOf(_borrowerAddress, _collateralInfo._tokenId);\n }\n return false;\n }\n\n // On NFT Received handlers\n\n function onERC721Received(address, address, uint256, bytes calldata)\n external\n pure\n returns (bytes4)\n {\n return\n bytes4(\n keccak256(\"onERC721Received(address,address,uint256,bytes)\")\n );\n }\n\n function onERC1155Received(\n address,\n address,\n uint256 id,\n uint256 value,\n bytes calldata\n ) external returns (bytes4) {\n return\n bytes4(\n keccak256(\n \"onERC1155Received(address,address,uint256,uint256,bytes)\"\n )\n );\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata _ids,\n uint256[] calldata _values,\n bytes calldata\n ) external returns (bytes4) {\n require(\n _ids.length == 1,\n \"Only allowed one asset batch transfer per transaction.\"\n );\n return\n bytes4(\n keccak256(\n \"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"\n )\n );\n }\n}\n" - }, - "contracts/interfaces/ICollateralManager.sol": { - "content": "// SPDX-Licence-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nimport { Collateral } from \"./escrow/ICollateralEscrowV1.sol\";\n\ninterface ICollateralManager {\n /**\n * @notice Checks the validity of a borrower's collateral balance.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validation_);\n\n /**\n * @notice Checks the validity of a borrower's collateral balance and commits it to a bid.\n * @param _bidId The id of the associated bid.\n * @param _collateralInfo Additional information about the collateral asset.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function commitCollateral(\n uint256 _bidId,\n Collateral calldata _collateralInfo\n ) external returns (bool validation_);\n\n function checkBalances(\n address _borrowerAddress,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validated_, bool[] memory checks_);\n\n /**\n * @notice Deploys a new collateral escrow.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function deployAndDeposit(uint256 _bidId) external;\n\n /**\n * @notice Gets the address of a deployed escrow.\n * @notice _bidId The bidId to return the escrow for.\n * @return The address of the escrow.\n */\n function getEscrow(uint256 _bidId) external view returns (address);\n\n /**\n * @notice Gets the collateral info for a given bid id.\n * @param _bidId The bidId to return the collateral info for.\n * @return The stored collateral info.\n */\n function getCollateralInfo(uint256 _bidId)\n external\n view\n returns (Collateral[] memory);\n\n /**\n * @notice Withdraws deposited collateral from the created escrow of a bid.\n * @param _bidId The id of the bid to withdraw collateral for.\n */\n function withdraw(uint256 _bidId) external;\n\n /**\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\n * @param _bidId The id of the associated bid.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function revalidateCollateral(uint256 _bidId) external returns (bool);\n\n /**\n * @notice Sends the deposited collateral to a liquidator of a bid.\n * @notice Can only be called by the protocol.\n * @param _bidId The id of the liquidated bid.\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\n */\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\n external;\n}\n" - }, - "contracts/interfaces/escrow/ICollateralEscrowV1.sol": { - "content": "// SPDX-Licence-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nenum CollateralType {\n ERC20,\n ERC721,\n ERC1155\n}\n\nstruct Collateral {\n CollateralType _collateralType;\n uint256 _amount;\n uint256 _tokenId;\n address _collateralAddress;\n}\n\ninterface ICollateralEscrowV1 {\n /**\n * @notice Deposits a collateral ERC20 token into the escrow.\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositToken(address _collateralAddress, uint256 _amount) external;\n\n /**\n * @notice Deposits a collateral asset into the escrow.\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositAsset(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) external payable;\n\n /**\n * @notice Withdraws a collateral asset from the escrow.\n * @param _collateralAddress The address of the collateral contract.\n * @param _amount The amount to withdraw.\n * @param _recipient The address to send the assets to.\n */\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) external;\n\n function getBid() external view returns (uint256);\n\n function initialize(uint256 _bidId) external;\n}\n" - }, - "contracts/interfaces/ITellerV2.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Payment, BidState } from \"../TellerV2Storage.sol\";\nimport { Collateral } from \"./escrow/ICollateralEscrowV1.sol\";\n\ninterface ITellerV2 {\n /**\n * @notice Function for a borrower to create a bid for a loan.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) external returns (uint256 bidId_);\n\n /**\n * @notice Function for a borrower to create a bid for a loan with Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) external returns (uint256 bidId_);\n\n /**\n * @notice Function for a lender to accept a proposed loan bid.\n * @param _bidId The id of the loan bid to accept.\n */\n function lenderAcceptBid(uint256 _bidId)\n external\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n );\n\n function calculateAmountDue(uint256 _bidId)\n external\n view\n returns (Payment memory due);\n\n /**\n * @notice Function for users to make the minimum amount due for an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanMinimum(uint256 _bidId) external;\n\n /**\n * @notice Function for users to repay an active loan in full.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanFull(uint256 _bidId) external;\n\n /**\n * @notice Function for users to make a payment towards an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _amount The amount of the payment.\n */\n function repayLoan(uint256 _bidId, uint256 _amount) external;\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanDefaulted(uint256 _bidId) external view returns (bool);\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isPaymentLate(uint256 _bidId) external view returns (bool);\n\n function getBidState(uint256 _bidId) external view returns (BidState);\n\n function getBorrowerActiveLoanIds(address _borrower)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @notice Returns the borrower address for a given bid.\n * @param _bidId The id of the bid/loan to get the borrower for.\n * @return borrower_ The address of the borrower associated with the bid.\n */\n function getLoanBorrower(uint256 _bidId)\n external\n view\n returns (address borrower_);\n\n /**\n * @notice Returns the lender address for a given bid.\n * @param _bidId The id of the bid/loan to get the lender for.\n * @return lender_ The address of the lender associated with the bid.\n */\n function getLoanLender(uint256 _bidId)\n external\n view\n returns (address lender_);\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_);\n\n function getLoanMarketId(uint256 _bidId) external view returns (uint256);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^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 *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSetUpgradeable {\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 // 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) {\n // 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 if (lastIndex != toDeleteIndex) {\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] = valueIndex; // Replace lastValue's index to valueIndex\n }\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 return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 in 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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n" - }, - "contracts/TellerV2Storage.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport { IMarketRegistry } from \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/IReputationManager.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./interfaces/ICollateralManager.sol\";\nimport { PaymentType, PaymentCycleType } from \"./libraries/V2Calculations.sol\";\nimport \"./interfaces/ILenderManager.sol\";\n\nenum BidState {\n NONEXISTENT,\n PENDING,\n CANCELLED,\n ACCEPTED,\n PAID,\n LIQUIDATED\n}\n\n/**\n * @notice Represents a total amount for a payment.\n * @param principal Amount that counts towards the principal.\n * @param interest Amount that counts toward interest.\n */\nstruct Payment {\n uint256 principal;\n uint256 interest;\n}\n\n/**\n * @notice Details about a loan request.\n * @param borrower Account address who is requesting a loan.\n * @param receiver Account address who will receive the loan amount.\n * @param lender Account address who accepted and funded the loan request.\n * @param marketplaceId ID of the marketplace the bid was submitted to.\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\n * @param loanDetails Struct of the specific loan details.\n * @param terms Struct of the loan request terms.\n * @param state Represents the current state of the loan.\n */\nstruct Bid {\n address borrower;\n address receiver;\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\n uint256 marketplaceId;\n bytes32 _metadataURI; // DEPRECATED\n LoanDetails loanDetails;\n Terms terms;\n BidState state;\n PaymentType paymentType;\n}\n\n/**\n * @notice Details about the loan.\n * @param lendingToken The token address for the loan.\n * @param principal The amount of tokens initially lent out.\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\n * @param loanDuration The duration of the loan.\n */\nstruct LoanDetails {\n ERC20 lendingToken;\n uint256 principal;\n Payment totalRepaid;\n uint32 timestamp;\n uint32 acceptedTimestamp;\n uint32 lastRepaidTimestamp;\n uint32 loanDuration;\n}\n\n/**\n * @notice Information on the terms of a loan request\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\n */\nstruct Terms {\n uint256 paymentCycleAmount;\n uint32 paymentCycle;\n uint16 APR;\n}\n\nabstract contract TellerV2Storage_G0 {\n /** Storage Variables */\n\n // Current number of bids.\n uint256 public bidId = 0;\n\n // Mapping of bidId to bid information.\n mapping(uint256 => Bid) public bids;\n\n // Mapping of borrowers to borrower requests.\n mapping(address => uint256[]) public borrowerBids;\n\n // Mapping of volume filled by lenders.\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\n\n // Volume filled by all lenders.\n uint256 public __totalVolumeFilled; // DEPRECIATED\n\n // List of allowed lending tokens\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\n\n IMarketRegistry public marketRegistry;\n IReputationManager public reputationManager;\n\n // Mapping of borrowers to borrower requests.\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\n\n mapping(uint256 => uint32) public bidDefaultDuration;\n mapping(uint256 => uint32) public bidExpirationTime;\n\n // Mapping of volume filled by lenders.\n // Asset address => Lender address => Volume amount\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\n\n // Volume filled by all lenders.\n // Asset address => Volume amount\n mapping(address => uint256) public totalVolumeFilled;\n\n uint256 public version;\n\n // Mapping of metadataURIs by bidIds.\n // Bid Id => metadataURI string\n mapping(uint256 => string) public uris;\n}\n\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\n // market ID => trusted forwarder\n mapping(uint256 => address) internal _trustedMarketForwarders;\n // trusted forwarder => set of pre-approved senders\n mapping(address => EnumerableSet.AddressSet)\n internal _approvedForwarderSenders;\n}\n\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\n address public lenderCommitmentForwarder;\n}\n\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\n ICollateralManager public collateralManager;\n}\n\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\n // Address of the lender manager contract\n ILenderManager public lenderManager;\n // BidId to payment cycle type (custom or monthly)\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\n}\n\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\n" - }, - "contracts/interfaces/IMarketRegistry.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../EAS/TellerAS.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ninterface IMarketRegistry {\n function initialize(TellerAS tellerAs) external;\n\n function isVerifiedLender(uint256 _marketId, address _lender)\n external\n view\n returns (bool, bytes32);\n\n function isMarketClosed(uint256 _marketId) external view returns (bool);\n\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\n external\n view\n returns (bool, bytes32);\n\n function getMarketOwner(uint256 _marketId) external view returns (address);\n\n function getMarketFeeRecipient(uint256 _marketId)\n external\n view\n returns (address);\n\n function getMarketURI(uint256 _marketId)\n external\n view\n returns (string memory);\n\n function getPaymentCycle(uint256 _marketId)\n external\n view\n returns (uint32, PaymentCycleType);\n\n function getPaymentDefaultDuration(uint256 _marketId)\n external\n view\n returns (uint32);\n\n function getBidExpirationTime(uint256 _marketId)\n external\n view\n returns (uint32);\n\n function getMarketplaceFee(uint256 _marketId)\n external\n view\n returns (uint16);\n\n function getPaymentType(uint256 _marketId)\n external\n view\n returns (PaymentType);\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) external returns (uint256 marketId_);\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) external returns (uint256 marketId_);\n}\n" - }, - "contracts/interfaces/IReputationManager.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nenum RepMark {\n Good,\n Delinquent,\n Default\n}\n\ninterface IReputationManager {\n function initialize(address protocolAddress) external;\n\n function getDelinquentLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getDefaultedLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getCurrentDelinquentLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function getCurrentDefaultLoanIds(address _account)\n external\n returns (uint256[] memory);\n\n function updateAccountReputation(address _account) external;\n\n function updateAccountReputation(address _account, uint256 _bidId)\n external\n returns (RepMark);\n}\n" - }, - "contracts/libraries/V2Calculations.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n// Libraries\nimport \"./NumbersLib.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport { Bid } from \"../TellerV2Storage.sol\";\n\nenum PaymentType {\n EMI,\n Bullet\n}\n\nenum PaymentCycleType {\n Seconds,\n Monthly\n}\n\nlibrary V2Calculations {\n using NumbersLib for uint256;\n\n /**\n * @notice Returns the timestamp of the last payment made for a loan.\n * @param _bid The loan bid struct to get the timestamp for.\n */\n function lastRepaidTimestamp(Bid storage _bid)\n internal\n view\n returns (uint32)\n {\n return\n _bid.loanDetails.lastRepaidTimestamp == 0\n ? _bid.loanDetails.acceptedTimestamp\n : _bid.loanDetails.lastRepaidTimestamp;\n }\n\n /**\n * @notice Calculates the amount owed for a loan.\n * @param _bid The loan bid struct to get the owed amount for.\n * @param _timestamp The timestamp at which to get the owed amount at.\n * @param _paymentCycleType The payment cycle type of the loan (Seconds or Monthly).\n */\n function calculateAmountOwed(\n Bid storage _bid,\n uint256 _timestamp,\n PaymentCycleType _paymentCycleType\n )\n internal\n view\n returns (\n uint256 owedPrincipal_,\n uint256 duePrincipal_,\n uint256 interest_\n )\n {\n // Total principal left to pay\n return\n calculateAmountOwed(\n _bid,\n lastRepaidTimestamp(_bid),\n _timestamp,\n _paymentCycleType\n );\n }\n\n function calculateAmountOwed(\n Bid storage _bid,\n uint256 _lastRepaidTimestamp,\n uint256 _timestamp,\n PaymentCycleType _paymentCycleType\n )\n internal\n view\n returns (\n uint256 owedPrincipal_,\n uint256 duePrincipal_,\n uint256 interest_\n )\n {\n owedPrincipal_ =\n _bid.loanDetails.principal -\n _bid.loanDetails.totalRepaid.principal;\n\n uint256 daysInYear = _paymentCycleType == PaymentCycleType.Monthly\n ? 360 days\n : 365 days;\n\n uint256 interestOwedInAYear = owedPrincipal_.percent(_bid.terms.APR);\n uint256 owedTime = _timestamp - uint256(_lastRepaidTimestamp);\n interest_ = (interestOwedInAYear * owedTime) / daysInYear;\n\n // Cast to int265 to avoid underflow errors (negative means loan duration has passed)\n int256 durationLeftOnLoan = int256(\n uint256(_bid.loanDetails.loanDuration)\n ) -\n (int256(_timestamp) -\n int256(uint256(_bid.loanDetails.acceptedTimestamp)));\n bool isLastPaymentCycle = durationLeftOnLoan <\n int256(uint256(_bid.terms.paymentCycle)) || // Check if current payment cycle is within or beyond the last one\n owedPrincipal_ + interest_ <= _bid.terms.paymentCycleAmount; // Check if what is left to pay is less than the payment cycle amount\n\n if (_bid.paymentType == PaymentType.Bullet) {\n if (isLastPaymentCycle) {\n duePrincipal_ = owedPrincipal_;\n }\n } else {\n // Default to PaymentType.EMI\n // Max payable amount in a cycle\n // NOTE: the last cycle could have less than the calculated payment amount\n uint256 maxCycleOwed = isLastPaymentCycle\n ? owedPrincipal_ + interest_\n : _bid.terms.paymentCycleAmount;\n\n // Calculate accrued amount due since last repayment\n uint256 owedAmount = (maxCycleOwed * owedTime) /\n _bid.terms.paymentCycle;\n duePrincipal_ = Math.min(owedAmount - interest_, owedPrincipal_);\n }\n }\n\n /**\n * @notice Calculates the amount owed for a loan for the next payment cycle.\n * @param _type The payment type of the loan.\n * @param _cycleType The cycle type set for the loan. (Seconds or Monthly)\n * @param _principal The starting amount that is owed on the loan.\n * @param _duration The length of the loan.\n * @param _paymentCycle The length of the loan's payment cycle.\n * @param _apr The annual percentage rate of the loan.\n */\n function calculatePaymentCycleAmount(\n PaymentType _type,\n PaymentCycleType _cycleType,\n uint256 _principal,\n uint32 _duration,\n uint32 _paymentCycle,\n uint16 _apr\n ) internal returns (uint256) {\n uint256 daysInYear = _cycleType == PaymentCycleType.Monthly\n ? 360 days\n : 365 days;\n if (_type == PaymentType.Bullet) {\n return\n _principal.percent(_apr).percent(\n uint256(_paymentCycle).ratioOf(daysInYear, 10),\n 10\n );\n }\n // Default to PaymentType.EMI\n return\n NumbersLib.pmt(\n _principal,\n _duration,\n _paymentCycle,\n _apr,\n daysInYear\n );\n }\n}\n" - }, - "contracts/interfaces/ILenderManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\n\nabstract contract ILenderManager is IERC721Upgradeable {\n /**\n * @notice Registers a new active lender for a loan, minting the nft.\n * @param _bidId The id for the loan to set.\n * @param _newLender The address of the new active lender.\n */\n function registerLoan(uint256 _bidId, address _newLender) external virtual;\n}\n" - }, - "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^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 *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\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 // 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) {\n // 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 if (lastIndex != toDeleteIndex) {\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] = valueIndex; // Replace lastValue's index to valueIndex\n }\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 return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 in 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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/ERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * 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, IERC20Metadata {\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\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override 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 override 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 this function is\n * overridden;\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 override returns (uint8) {\n return 18;\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 * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, 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 * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\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 address owner = _msgSender();\n _approve(owner, 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 * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\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 address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + 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 address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This 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 * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, 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 * - `account` 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 += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(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 uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(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(\n address owner,\n address spender,\n uint256 amount\n ) 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 Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\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 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after 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 * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" - }, - "contracts/EAS/TellerAS.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../Types.sol\";\nimport \"../interfaces/IEAS.sol\";\nimport \"../interfaces/IASRegistry.sol\";\n\n/**\n * @title TellerAS - Teller Attestation Service - based on EAS - Ethereum Attestation Service\n */\ncontract TellerAS is IEAS {\n error AccessDenied();\n error AlreadyRevoked();\n error InvalidAttestation();\n error InvalidExpirationTime();\n error InvalidOffset();\n error InvalidRegistry();\n error InvalidSchema();\n error InvalidVerifier();\n error NotFound();\n error NotPayable();\n\n string public constant VERSION = \"0.8\";\n\n // A terminator used when concatenating and hashing multiple fields.\n string private constant HASH_TERMINATOR = \"@\";\n\n // The AS global registry.\n IASRegistry private immutable _asRegistry;\n\n // The EIP712 verifier used to verify signed attestations.\n IEASEIP712Verifier private immutable _eip712Verifier;\n\n // A mapping between attestations and their related attestations.\n mapping(bytes32 => bytes32[]) private _relatedAttestations;\n\n // A mapping between an account and its received attestations.\n mapping(address => mapping(bytes32 => bytes32[]))\n private _receivedAttestations;\n\n // A mapping between an account and its sent attestations.\n mapping(address => mapping(bytes32 => bytes32[])) private _sentAttestations;\n\n // A mapping between a schema and its attestations.\n mapping(bytes32 => bytes32[]) private _schemaAttestations;\n\n // The global mapping between attestations and their UUIDs.\n mapping(bytes32 => Attestation) private _db;\n\n // The global counter for the total number of attestations.\n uint256 private _attestationsCount;\n\n bytes32 private _lastUUID;\n\n /**\n * @dev Creates a new EAS instance.\n *\n * @param registry The address of the global AS registry.\n * @param verifier The address of the EIP712 verifier.\n */\n constructor(IASRegistry registry, IEASEIP712Verifier verifier) {\n if (address(registry) == address(0x0)) {\n revert InvalidRegistry();\n }\n\n if (address(verifier) == address(0x0)) {\n revert InvalidVerifier();\n }\n\n _asRegistry = registry;\n _eip712Verifier = verifier;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getASRegistry() external view override returns (IASRegistry) {\n return _asRegistry;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getEIP712Verifier()\n external\n view\n override\n returns (IEASEIP712Verifier)\n {\n return _eip712Verifier;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getAttestationsCount() external view override returns (uint256) {\n return _attestationsCount;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data\n ) public payable virtual override returns (bytes32) {\n return\n _attest(\n recipient,\n schema,\n expirationTime,\n refUUID,\n data,\n msg.sender\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function attestByDelegation(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public payable virtual override returns (bytes32) {\n _eip712Verifier.attest(\n recipient,\n schema,\n expirationTime,\n refUUID,\n data,\n attester,\n v,\n r,\n s\n );\n\n return\n _attest(recipient, schema, expirationTime, refUUID, data, attester);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function revoke(bytes32 uuid) public virtual override {\n return _revoke(uuid, msg.sender);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function revokeByDelegation(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n _eip712Verifier.revoke(uuid, attester, v, r, s);\n\n _revoke(uuid, attester);\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getAttestation(bytes32 uuid)\n external\n view\n override\n returns (Attestation memory)\n {\n return _db[uuid];\n }\n\n /**\n * @inheritdoc IEAS\n */\n function isAttestationValid(bytes32 uuid)\n public\n view\n override\n returns (bool)\n {\n return _db[uuid].uuid != 0;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function isAttestationActive(bytes32 uuid)\n public\n view\n override\n returns (bool)\n {\n return\n isAttestationValid(uuid) &&\n _db[uuid].expirationTime >= block.timestamp &&\n _db[uuid].revocationTime == 0;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getReceivedAttestationUUIDs(\n address recipient,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _receivedAttestations[recipient][schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _receivedAttestations[recipient][schema].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSentAttestationUUIDs(\n address attester,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _sentAttestations[attester][schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _sentAttestations[recipient][schema].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getRelatedAttestationUUIDs(\n bytes32 uuid,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _relatedAttestations[uuid],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\n external\n view\n override\n returns (uint256)\n {\n return _relatedAttestations[uuid].length;\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSchemaAttestationUUIDs(\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view override returns (bytes32[] memory) {\n return\n _sliceUUIDs(\n _schemaAttestations[schema],\n start,\n length,\n reverseOrder\n );\n }\n\n /**\n * @inheritdoc IEAS\n */\n function getSchemaAttestationUUIDsCount(bytes32 schema)\n external\n view\n override\n returns (uint256)\n {\n return _schemaAttestations[schema].length;\n }\n\n /**\n * @dev Attests to a specific AS.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n *\n * @return The UUID of the new attestation.\n */\n function _attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester\n ) private returns (bytes32) {\n if (expirationTime <= block.timestamp) {\n revert InvalidExpirationTime();\n }\n\n IASRegistry.ASRecord memory asRecord = _asRegistry.getAS(schema);\n if (asRecord.uuid == EMPTY_UUID) {\n revert InvalidSchema();\n }\n\n IASResolver resolver = asRecord.resolver;\n if (address(resolver) != address(0x0)) {\n if (msg.value != 0 && !resolver.isPayable()) {\n revert NotPayable();\n }\n\n if (\n !resolver.resolve{ value: msg.value }(\n recipient,\n asRecord.schema,\n data,\n expirationTime,\n attester\n )\n ) {\n revert InvalidAttestation();\n }\n }\n\n Attestation memory attestation = Attestation({\n uuid: EMPTY_UUID,\n schema: schema,\n recipient: recipient,\n attester: attester,\n time: block.timestamp,\n expirationTime: expirationTime,\n revocationTime: 0,\n refUUID: refUUID,\n data: data\n });\n\n _lastUUID = _getUUID(attestation);\n attestation.uuid = _lastUUID;\n\n _receivedAttestations[recipient][schema].push(_lastUUID);\n _sentAttestations[attester][schema].push(_lastUUID);\n _schemaAttestations[schema].push(_lastUUID);\n\n _db[_lastUUID] = attestation;\n _attestationsCount++;\n\n if (refUUID != 0) {\n if (!isAttestationValid(refUUID)) {\n revert NotFound();\n }\n\n _relatedAttestations[refUUID].push(_lastUUID);\n }\n\n emit Attested(recipient, attester, _lastUUID, schema);\n\n return _lastUUID;\n }\n\n function getLastUUID() external view returns (bytes32) {\n return _lastUUID;\n }\n\n /**\n * @dev Revokes an existing attestation to a specific AS.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n */\n function _revoke(bytes32 uuid, address attester) private {\n Attestation storage attestation = _db[uuid];\n if (attestation.uuid == EMPTY_UUID) {\n revert NotFound();\n }\n\n if (attestation.attester != attester) {\n revert AccessDenied();\n }\n\n if (attestation.revocationTime != 0) {\n revert AlreadyRevoked();\n }\n\n attestation.revocationTime = block.timestamp;\n\n emit Revoked(attestation.recipient, attester, uuid, attestation.schema);\n }\n\n /**\n * @dev Calculates a UUID for a given attestation.\n *\n * @param attestation The input attestation.\n *\n * @return Attestation UUID.\n */\n function _getUUID(Attestation memory attestation)\n private\n view\n returns (bytes32)\n {\n return\n keccak256(\n abi.encodePacked(\n attestation.schema,\n attestation.recipient,\n attestation.attester,\n attestation.time,\n attestation.expirationTime,\n attestation.data,\n HASH_TERMINATOR,\n _attestationsCount\n )\n );\n }\n\n /**\n * @dev Returns a slice in an array of attestation UUIDs.\n *\n * @param uuids The array of attestation UUIDs.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function _sliceUUIDs(\n bytes32[] memory uuids,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) private pure returns (bytes32[] memory) {\n uint256 attestationsLength = uuids.length;\n if (attestationsLength == 0) {\n return new bytes32[](0);\n }\n\n if (start >= attestationsLength) {\n revert InvalidOffset();\n }\n\n uint256 len = length;\n if (attestationsLength < start + length) {\n len = attestationsLength - start;\n }\n\n bytes32[] memory res = new bytes32[](len);\n\n for (uint256 i = 0; i < len; ++i) {\n res[i] = uuids[\n reverseOrder ? attestationsLength - (start + i + 1) : start + i\n ];\n }\n\n return res;\n }\n}\n" - }, - "contracts/Types.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// A representation of an empty/uninitialized UUID.\nbytes32 constant EMPTY_UUID = 0;\n" - }, - "contracts/interfaces/IEAS.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./IASRegistry.sol\";\nimport \"./IEASEIP712Verifier.sol\";\n\n/**\n * @title EAS - Ethereum Attestation Service interface\n */\ninterface IEAS {\n /**\n * @dev A struct representing a single attestation.\n */\n struct Attestation {\n // A unique identifier of the attestation.\n bytes32 uuid;\n // A unique identifier of the AS.\n bytes32 schema;\n // The recipient of the attestation.\n address recipient;\n // The attester/sender of the attestation.\n address attester;\n // The time when the attestation was created (Unix timestamp).\n uint256 time;\n // The time when the attestation expires (Unix timestamp).\n uint256 expirationTime;\n // The time when the attestation was revoked (Unix timestamp).\n uint256 revocationTime;\n // The UUID of the related attestation.\n bytes32 refUUID;\n // Custom attestation data.\n bytes data;\n }\n\n /**\n * @dev Triggered when an attestation has been made.\n *\n * @param recipient The recipient of the attestation.\n * @param attester The attesting account.\n * @param uuid The UUID the revoked attestation.\n * @param schema The UUID of the AS.\n */\n event Attested(\n address indexed recipient,\n address indexed attester,\n bytes32 uuid,\n bytes32 indexed schema\n );\n\n /**\n * @dev Triggered when an attestation has been revoked.\n *\n * @param recipient The recipient of the attestation.\n * @param attester The attesting account.\n * @param schema The UUID of the AS.\n * @param uuid The UUID the revoked attestation.\n */\n event Revoked(\n address indexed recipient,\n address indexed attester,\n bytes32 uuid,\n bytes32 indexed schema\n );\n\n /**\n * @dev Returns the address of the AS global registry.\n *\n * @return The address of the AS global registry.\n */\n function getASRegistry() external view returns (IASRegistry);\n\n /**\n * @dev Returns the address of the EIP712 verifier used to verify signed attestations.\n *\n * @return The address of the EIP712 verifier used to verify signed attestations.\n */\n function getEIP712Verifier() external view returns (IEASEIP712Verifier);\n\n /**\n * @dev Returns the global counter for the total number of attestations.\n *\n * @return The global counter for the total number of attestations.\n */\n function getAttestationsCount() external view returns (uint256);\n\n /**\n * @dev Attests to a specific AS.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n *\n * @return The UUID of the new attestation.\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data\n ) external payable returns (bytes32);\n\n /**\n * @dev Attests to a specific AS using a provided EIP712 signature.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n *\n * @return The UUID of the new attestation.\n */\n function attestByDelegation(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external payable returns (bytes32);\n\n /**\n * @dev Revokes an existing attestation to a specific AS.\n *\n * @param uuid The UUID of the attestation to revoke.\n */\n function revoke(bytes32 uuid) external;\n\n /**\n * @dev Attests to a specific AS using a provided EIP712 signature.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function revokeByDelegation(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns an existing attestation by UUID.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return The attestation data members.\n */\n function getAttestation(bytes32 uuid)\n external\n view\n returns (Attestation memory);\n\n /**\n * @dev Checks whether an attestation exists.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return Whether an attestation exists.\n */\n function isAttestationValid(bytes32 uuid) external view returns (bool);\n\n /**\n * @dev Checks whether an attestation is active.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return Whether an attestation is active.\n */\n function isAttestationActive(bytes32 uuid) external view returns (bool);\n\n /**\n * @dev Returns all received attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getReceivedAttestationUUIDs(\n address recipient,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of received attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getReceivedAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all sent attestation UUIDs.\n *\n * @param attester The attesting account.\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getSentAttestationUUIDs(\n address attester,\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of sent attestation UUIDs.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getSentAttestationUUIDsCount(address recipient, bytes32 schema)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all attestations related to a specific attestation.\n *\n * @param uuid The UUID of the attestation to retrieve.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getRelatedAttestationUUIDs(\n bytes32 uuid,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of related attestation UUIDs.\n *\n * @param uuid The UUID of the attestation to retrieve.\n *\n * @return The number of related attestations.\n */\n function getRelatedAttestationUUIDsCount(bytes32 uuid)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns all per-schema attestation UUIDs.\n *\n * @param schema The UUID of the AS.\n * @param start The offset to start from.\n * @param length The number of total members to retrieve.\n * @param reverseOrder Whether the offset starts from the end and the data is returned in reverse.\n *\n * @return An array of attestation UUIDs.\n */\n function getSchemaAttestationUUIDs(\n bytes32 schema,\n uint256 start,\n uint256 length,\n bool reverseOrder\n ) external view returns (bytes32[] memory);\n\n /**\n * @dev Returns the number of per-schema attestation UUIDs.\n *\n * @param schema The UUID of the AS.\n *\n * @return The number of attestations.\n */\n function getSchemaAttestationUUIDsCount(bytes32 schema)\n external\n view\n returns (uint256);\n}\n" - }, - "contracts/interfaces/IASRegistry.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./IASResolver.sol\";\n\n/**\n * @title The global AS registry interface.\n */\ninterface IASRegistry {\n /**\n * @title A struct representing a record for a submitted AS (Attestation Schema).\n */\n struct ASRecord {\n // A unique identifier of the AS.\n bytes32 uuid;\n // Optional schema resolver.\n IASResolver resolver;\n // Auto-incrementing index for reference, assigned by the registry itself.\n uint256 index;\n // Custom specification of the AS (e.g., an ABI).\n bytes schema;\n }\n\n /**\n * @dev Triggered when a new AS has been registered\n *\n * @param uuid The AS UUID.\n * @param index The AS index.\n * @param schema The AS schema.\n * @param resolver An optional AS schema resolver.\n * @param attester The address of the account used to register the AS.\n */\n event Registered(\n bytes32 indexed uuid,\n uint256 indexed index,\n bytes schema,\n IASResolver resolver,\n address attester\n );\n\n /**\n * @dev Submits and reserve a new AS\n *\n * @param schema The AS data schema.\n * @param resolver An optional AS schema resolver.\n *\n * @return The UUID of the new AS.\n */\n function register(bytes calldata schema, IASResolver resolver)\n external\n returns (bytes32);\n\n /**\n * @dev Returns an existing AS by UUID\n *\n * @param uuid The UUID of the AS to retrieve.\n *\n * @return The AS data members.\n */\n function getAS(bytes32 uuid) external view returns (ASRecord memory);\n\n /**\n * @dev Returns the global counter for the total number of attestations\n *\n * @return The global counter for the total number of attestations.\n */\n function getASCount() external view returns (uint256);\n}\n" - }, - "contracts/interfaces/IEASEIP712Verifier.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n/**\n * @title EIP712 typed signatures verifier for EAS delegated attestations interface.\n */\ninterface IEASEIP712Verifier {\n /**\n * @dev Returns the current nonce per-account.\n *\n * @param account The requested accunt.\n *\n * @return The current nonce.\n */\n function getNonce(address account) external view returns (uint256);\n\n /**\n * @dev Verifies signed attestation.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The UUID of the AS.\n * @param expirationTime The expiration time of the attestation.\n * @param refUUID An optional related attestation's UUID.\n * @param data Additional custom data.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Verifies signed revocations.\n *\n * @param uuid The UUID of the attestation to revoke.\n * @param attester The attesting account.\n * @param v The recovery ID.\n * @param r The x-coordinate of the nonce R.\n * @param s The signature data.\n */\n function revoke(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" - }, - "contracts/interfaces/IASResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\n/**\n * @title The interface of an optional AS resolver.\n */\ninterface IASResolver {\n /**\n * @dev Returns whether the resolver supports ETH transfers\n */\n function isPayable() external pure returns (bool);\n\n /**\n * @dev Resolves an attestation and verifier whether its data conforms to the spec.\n *\n * @param recipient The recipient of the attestation.\n * @param schema The AS data schema.\n * @param data The actual attestation data.\n * @param expirationTime The expiration time of the attestation.\n * @param msgSender The sender of the original attestation message.\n *\n * @return Whether the data is valid according to the scheme.\n */\n function resolve(\n address recipient,\n bytes calldata schema,\n bytes calldata data,\n uint256 expirationTime,\n address msgSender\n ) external payable returns (bool);\n}\n" - }, - "contracts/libraries/NumbersLib.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// Libraries\nimport { SafeCast } from \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport { Math } from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"./WadRayMath.sol\";\n\n/**\n * @dev Utility library for uint256 numbers\n *\n * @author develop@teller.finance\n */\nlibrary NumbersLib {\n using WadRayMath for uint256;\n\n /**\n * @dev It represents 100% with 2 decimal places.\n */\n uint16 internal constant PCT_100 = 10000;\n\n function percentFactor(uint256 decimals) internal pure returns (uint256) {\n return 100 * (10**decimals);\n }\n\n /**\n * @notice Returns a percentage value of a number.\n * @param self The number to get a percentage of.\n * @param percentage The percentage value to calculate with 2 decimal places (10000 = 100%).\n */\n function percent(uint256 self, uint16 percentage)\n internal\n pure\n returns (uint256)\n {\n return percent(self, percentage, 2);\n }\n\n /**\n * @notice Returns a percentage value of a number.\n * @param self The number to get a percentage of.\n * @param percentage The percentage value to calculate with.\n * @param decimals The number of decimals the percentage value is in.\n */\n function percent(uint256 self, uint256 percentage, uint256 decimals)\n internal\n pure\n returns (uint256)\n {\n return (self * percentage) / percentFactor(decimals);\n }\n\n /**\n * @notice it returns the absolute number of a specified parameter\n * @param self the number to be returned in it's absolute\n * @return the absolute number\n */\n function abs(int256 self) internal pure returns (uint256) {\n return self >= 0 ? uint256(self) : uint256(-1 * self);\n }\n\n /**\n * @notice Returns a ratio percentage of {num1} to {num2}.\n * @dev Returned value is type uint16.\n * @param num1 The number used to get the ratio for.\n * @param num2 The number used to get the ratio from.\n * @return Ratio percentage with 2 decimal places (10000 = 100%).\n */\n function ratioOf(uint256 num1, uint256 num2)\n internal\n pure\n returns (uint16)\n {\n return SafeCast.toUint16(ratioOf(num1, num2, 2));\n }\n\n /**\n * @notice Returns a ratio percentage of {num1} to {num2}.\n * @param num1 The number used to get the ratio for.\n * @param num2 The number used to get the ratio from.\n * @param decimals The number of decimals the percentage value is returned in.\n * @return Ratio percentage value.\n */\n function ratioOf(uint256 num1, uint256 num2, uint256 decimals)\n internal\n pure\n returns (uint256)\n {\n if (num2 == 0) return 0;\n return (num1 * percentFactor(decimals)) / num2;\n }\n\n /**\n * @notice Calculates the payment amount for a cycle duration.\n * The formula is calculated based on the standard Estimated Monthly Installment (https://en.wikipedia.org/wiki/Equated_monthly_installment)\n * EMI = [P x R x (1+R)^N]/[(1+R)^N-1]\n * @param principal The starting amount that is owed on the loan.\n * @param loanDuration The length of the loan.\n * @param cycleDuration The length of the loan's payment cycle.\n * @param apr The annual percentage rate of the loan.\n */\n function pmt(\n uint256 principal,\n uint32 loanDuration,\n uint32 cycleDuration,\n uint16 apr,\n uint256 daysInYear\n ) internal pure returns (uint256) {\n require(\n loanDuration >= cycleDuration,\n \"PMT: cycle duration < loan duration\"\n );\n if (apr == 0)\n return\n Math.mulDiv(\n principal,\n cycleDuration,\n loanDuration,\n Math.Rounding.Up\n );\n\n // Number of payment cycles for the duration of the loan\n uint256 n = Math.ceilDiv(loanDuration, cycleDuration);\n\n uint256 one = WadRayMath.wad();\n uint256 r = WadRayMath.pctToWad(apr).wadMul(cycleDuration).wadDiv(\n daysInYear\n );\n uint256 exp = (one + r).wadPow(n);\n uint256 numerator = principal.wadMul(r).wadMul(exp);\n uint256 denominator = exp - one;\n\n return numerator.wadDiv(denominator);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/Math.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" - }, - "contracts/libraries/WadRayMath.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\n/**\n * @title WadRayMath library\n * @author Multiplier Finance\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\n */\nlibrary WadRayMath {\n using SafeMath for uint256;\n\n uint256 internal constant WAD = 1e18;\n uint256 internal constant halfWAD = WAD / 2;\n\n uint256 internal constant RAY = 1e27;\n uint256 internal constant halfRAY = RAY / 2;\n\n uint256 internal constant WAD_RAY_RATIO = 1e9;\n uint256 internal constant PCT_WAD_RATIO = 1e14;\n uint256 internal constant PCT_RAY_RATIO = 1e23;\n\n function ray() internal pure returns (uint256) {\n return RAY;\n }\n\n function wad() internal pure returns (uint256) {\n return WAD;\n }\n\n function halfRay() internal pure returns (uint256) {\n return halfRAY;\n }\n\n function halfWad() internal pure returns (uint256) {\n return halfWAD;\n }\n\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\n return halfWAD.add(a.mul(b)).div(WAD);\n }\n\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 halfB = b / 2;\n\n return halfB.add(a.mul(WAD)).div(b);\n }\n\n function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {\n return halfRAY.add(a.mul(b)).div(RAY);\n }\n\n function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 halfB = b / 2;\n\n return halfB.add(a.mul(RAY)).div(b);\n }\n\n function rayToWad(uint256 a) internal pure returns (uint256) {\n uint256 halfRatio = WAD_RAY_RATIO / 2;\n\n return halfRatio.add(a).div(WAD_RAY_RATIO);\n }\n\n function rayToPct(uint256 a) internal pure returns (uint16) {\n uint256 halfRatio = PCT_RAY_RATIO / 2;\n\n uint256 val = halfRatio.add(a).div(PCT_RAY_RATIO);\n return SafeCast.toUint16(val);\n }\n\n function wadToPct(uint256 a) internal pure returns (uint16) {\n uint256 halfRatio = PCT_WAD_RATIO / 2;\n\n uint256 val = halfRatio.add(a).div(PCT_WAD_RATIO);\n return SafeCast.toUint16(val);\n }\n\n function wadToRay(uint256 a) internal pure returns (uint256) {\n return a.mul(WAD_RAY_RATIO);\n }\n\n function pctToRay(uint16 a) internal pure returns (uint256) {\n return uint256(a).mul(RAY).div(1e4);\n }\n\n function pctToWad(uint16 a) internal pure returns (uint256) {\n return uint256(a).mul(WAD).div(1e4);\n }\n\n /**\n * @dev calculates base^duration. The code uses the ModExp precompile\n * @return z base^duration, in ray\n */\n function rayPow(uint256 x, uint256 n) internal pure returns (uint256) {\n return _pow(x, n, RAY, rayMul);\n }\n\n function wadPow(uint256 x, uint256 n) internal pure returns (uint256) {\n return _pow(x, n, WAD, wadMul);\n }\n\n function _pow(\n uint256 x,\n uint256 n,\n uint256 p,\n function(uint256, uint256) internal pure returns (uint256) mul\n ) internal pure returns (uint256 z) {\n z = n % 2 != 0 ? x : p;\n\n for (n /= 2; n != 0; n /= 2) {\n x = mul(x, x);\n\n if (n % 2 != 0) {\n z = mul(z, x);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeCast.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\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 unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction 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 unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\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 unchecked {\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 /**\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 unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\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 unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\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 return a + b;\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 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 return a * b;\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.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\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 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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\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 * 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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a / b;\n }\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(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/Proxy.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" - }, - "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" - }, - "contracts/tests/TellerV2_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../escrow/CollateralEscrowV1.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\";\nimport \"../LenderCommitmentForwarder.sol\";\nimport \"./resolvers/TestERC20Token.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"../CollateralManager.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\nimport { BidState, Payment } from \"../TellerV2Storage.sol\";\nimport \"../MetaForwarder.sol\";\nimport { LenderManager } from \"../LenderManager.sol\";\n\ncontract TellerV2_Test is Testable {\n TellerV2User private marketOwner;\n TellerV2User private borrower;\n TellerV2User private lender;\n\n TellerV2 tellerV2;\n\n WethMock wethMock;\n TestERC20Token daiMock;\n CollateralManager collateralManager;\n\n uint256 marketId1;\n uint256 collateralAmount = 10;\n\n function setup_beforeAll() public {\n // Deploy test tokens\n wethMock = new WethMock();\n daiMock = new TestERC20Token(\"Dai\", \"DAI\", 10000000, 18);\n\n // Deploy Escrow beacon\n CollateralEscrowV1 escrowImplementation = new CollateralEscrowV1();\n UpgradeableBeacon escrowBeacon = new UpgradeableBeacon(\n address(escrowImplementation)\n );\n\n // Deploy protocol\n tellerV2 = new TellerV2(address(0));\n\n // Deploy MarketRegistry & ReputationManager\n IMarketRegistry marketRegistry = IMarketRegistry(new MarketRegistry());\n IReputationManager reputationManager = IReputationManager(\n new ReputationManager()\n );\n reputationManager.initialize(address(tellerV2));\n\n // Deploy Collateral manager\n collateralManager = new CollateralManager();\n collateralManager.initialize(address(escrowBeacon), address(tellerV2));\n\n // Deploy Lender manager\n MetaForwarder metaforwarder = new MetaForwarder();\n metaforwarder.initialize();\n LenderManager lenderManager = new LenderManager((marketRegistry));\n lenderManager.initialize();\n lenderManager.transferOwnership(address(tellerV2));\n\n // Deploy LenderCommitmentForwarder\n LenderCommitmentForwarder lenderCommitmentForwarder = new LenderCommitmentForwarder(\n address(tellerV2),\n address(marketRegistry)\n );\n\n // Initialize protocol\n tellerV2.initialize(\n 50,\n address(marketRegistry),\n address(reputationManager),\n address(lenderCommitmentForwarder),\n address(collateralManager),\n address(lenderManager)\n );\n\n // Instantiate users & balances\n marketOwner = new TellerV2User(address(tellerV2), wethMock);\n borrower = new TellerV2User(address(tellerV2), wethMock);\n lender = new TellerV2User(address(tellerV2), wethMock);\n\n uint256 balance = 50000;\n payable(address(borrower)).transfer(balance);\n payable(address(lender)).transfer(balance * 10);\n borrower.depositToWeth(balance);\n lender.depositToWeth(balance * 10);\n\n daiMock.transfer(address(lender), balance * 10);\n daiMock.transfer(address(borrower), balance);\n // Approve Teller V2 for the lender's dai\n lender.addAllowance(address(daiMock), address(tellerV2), balance * 10);\n\n // Create a market\n marketId1 = marketOwner.createMarket(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n \"uri://\"\n );\n }\n\n function submitCollateralBid() public returns (uint256 bidId_) {\n Collateral memory info;\n info._amount = collateralAmount;\n info._tokenId = 0;\n info._collateralType = CollateralType.ERC20;\n info._collateralAddress = address(wethMock);\n\n Collateral[] memory collateralInfo = new Collateral[](1);\n collateralInfo[0] = info;\n\n uint256 bal = wethMock.balanceOf(address(borrower));\n\n // Increase allowance\n // Approve the collateral manager for the borrower's weth\n borrower.addAllowance(\n address(wethMock),\n address(collateralManager),\n info._amount\n );\n\n bidId_ = borrower.submitCollateralBid(\n address(daiMock),\n marketId1,\n 100,\n 10000,\n 500,\n \"metadataUri://\",\n address(borrower),\n collateralInfo\n );\n }\n\n function acceptBid(uint256 _bidId) public {\n // Accept bid\n lender.acceptBid(_bidId);\n }\n\n function collateralEscrow_test() public {\n // Submit bid as borrower\n uint256 bidId = submitCollateralBid();\n // Accept bid as lender\n acceptBid(bidId);\n\n // Get newly created escrow\n address escrowAddress = collateralManager._escrows(bidId);\n CollateralEscrowV1 escrow = CollateralEscrowV1(escrowAddress);\n\n uint256 storedBidId = escrow.getBid();\n\n // Test that the created escrow has the same bidId and collateral stored\n Test.eq(bidId, storedBidId, \"Collateral escrow was not created\");\n\n uint256 escrowBalance = wethMock.balanceOf(escrowAddress);\n\n Test.eq(collateralAmount, escrowBalance, \"Collateral was not stored\");\n\n // Repay loan\n uint256 borrowerBalanceBefore = wethMock.balanceOf(address(borrower));\n Payment memory amountOwed = tellerV2.calculateAmountOwed(bidId);\n borrower.addAllowance(\n address(daiMock),\n address(tellerV2),\n amountOwed.principal + amountOwed.interest\n );\n borrower.repayLoanFull(bidId);\n\n // Check escrow balance\n uint256 escrowBalanceAfter = wethMock.balanceOf(escrowAddress);\n Test.eq(\n 0,\n escrowBalanceAfter,\n \"Collateral was not withdrawn from escrow on repayment\"\n );\n\n // Check borrower balance for collateral\n uint256 borrowerBalanceAfter = wethMock.balanceOf(address(borrower));\n Test.eq(\n collateralAmount,\n borrowerBalanceAfter - borrowerBalanceBefore,\n \"Collateral was not sent to borrower after repayment\"\n );\n }\n}\n\ncontract TellerV2User is User {\n WethMock public immutable wethMock;\n\n constructor(address _tellerV2, WethMock _wethMock) User(_tellerV2) {\n wethMock = _wethMock;\n }\n\n function depositToWeth(uint256 amount) public {\n wethMock.deposit{ value: amount }();\n }\n}\n" - }, - "contracts/tests/Testable.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n\nabstract contract Testable {\n receive() external payable {}\n}\n" - }, - "contracts/TellerV2.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./ProtocolFee.sol\";\nimport \"./TellerV2Storage.sol\";\nimport \"./TellerV2Context.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/IReputationManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport { Collateral } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\nimport { BokkyPooBahsDateTimeLibrary as BPBDTL } from \"./libraries/DateTimeLib.sol\";\nimport { V2Calculations, PaymentCycleType } from \"./libraries/V2Calculations.sol\";\n\n/* Errors */\n/**\n * @notice This error is reverted when the action isn't allowed\n * @param bidId The id of the bid.\n * @param action The action string (i.e: 'repayLoan', 'cancelBid', 'etc)\n * @param message The message string to return to the user explaining why the tx was reverted\n */\nerror ActionNotAllowed(uint256 bidId, string action, string message);\n\n/**\n * @notice This error is reverted when repayment amount is less than the required minimum\n * @param bidId The id of the bid the borrower is attempting to repay.\n * @param payment The payment made by the borrower\n * @param minimumOwed The minimum owed value\n */\nerror PaymentNotMinimum(uint256 bidId, uint256 payment, uint256 minimumOwed);\n\ncontract TellerV2 is\n ITellerV2,\n OwnableUpgradeable,\n ProtocolFee,\n PausableUpgradeable,\n TellerV2Storage,\n TellerV2Context\n{\n using Address for address;\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /** Events */\n\n /**\n * @notice This event is emitted when a new bid is submitted.\n * @param bidId The id of the bid submitted.\n * @param borrower The address of the bid borrower.\n * @param metadataURI URI for additional bid information as part of loan bid.\n */\n event SubmittedBid(\n uint256 indexed bidId,\n address indexed borrower,\n address receiver,\n bytes32 indexed metadataURI\n );\n\n /**\n * @notice This event is emitted when a bid has been accepted by a lender.\n * @param bidId The id of the bid accepted.\n * @param lender The address of the accepted bid lender.\n */\n event AcceptedBid(uint256 indexed bidId, address indexed lender);\n\n /**\n * @notice This event is emitted when a previously submitted bid has been cancelled.\n * @param bidId The id of the cancelled bid.\n */\n event CancelledBid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when market owner has cancelled a pending bid in their market.\n * @param bidId The id of the bid funded.\n *\n * Note: The `CancelledBid` event will also be emitted.\n */\n event MarketOwnerCancelledBid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a payment is made towards an active loan.\n * @param bidId The id of the bid/loan to which the payment was made.\n */\n event LoanRepayment(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a loan has been fully repaid.\n * @param bidId The id of the bid/loan which was repaid.\n */\n event LoanRepaid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a loan has been fully repaid.\n * @param bidId The id of the bid/loan which was repaid.\n */\n event LoanLiquidated(uint256 indexed bidId, address indexed liquidator);\n\n /**\n * @notice This event is emitted when a fee has been paid related to a bid.\n * @param bidId The id of the bid.\n * @param feeType The name of the fee being paid.\n * @param amount The amount of the fee being paid.\n */\n event FeePaid(\n uint256 indexed bidId,\n string indexed feeType,\n uint256 indexed amount\n );\n\n /** Modifiers */\n\n /**\n * @notice This modifier is used to check if the state of a bid is pending, before running an action.\n * @param _bidId The id of the bid to check the state for.\n * @param _action The desired action to run on the bid.\n */\n modifier pendingBid(uint256 _bidId, string memory _action) {\n if (bids[_bidId].state != BidState.PENDING) {\n revert ActionNotAllowed(_bidId, _action, \"Bid must be pending\");\n }\n\n _;\n }\n\n /**\n * @notice This modifier is used to check if the state of a loan has been accepted, before running an action.\n * @param _bidId The id of the bid to check the state for.\n * @param _action The desired action to run on the bid.\n */\n modifier acceptedLoan(uint256 _bidId, string memory _action) {\n if (bids[_bidId].state != BidState.ACCEPTED) {\n revert ActionNotAllowed(_bidId, _action, \"Loan must be accepted\");\n }\n\n _;\n }\n\n /** Constant Variables **/\n\n uint8 public constant CURRENT_CODE_VERSION = 9;\n\n /** Constructor **/\n\n constructor(address trustedForwarder) TellerV2Context(trustedForwarder) {}\n\n /** External Functions **/\n\n /**\n * @notice Initializes the proxy.\n * @param _protocolFee The fee collected by the protocol for loan processing.\n * @param _marketRegistry The address of the market registry contract for the protocol.\n * @param _reputationManager The address of the reputation manager contract.\n * @param _lenderCommitmentForwarder The address of the lender commitment forwarder contract.\n * @param _collateralManager The address of the collateral manager contracts.\n * @param _lenderManager The address of the lender manager contract for loans on the protocol.\n */\n function initialize(\n uint16 _protocolFee,\n address _marketRegistry,\n address _reputationManager,\n address _lenderCommitmentForwarder,\n address _collateralManager,\n address _lenderManager\n ) external initializer {\n __ProtocolFee_init(_protocolFee);\n\n __Pausable_init();\n\n require(\n _lenderCommitmentForwarder.isContract(),\n \"LenderCommitmentForwarder must be a contract\"\n );\n lenderCommitmentForwarder = _lenderCommitmentForwarder;\n\n require(\n _marketRegistry.isContract(),\n \"MarketRegistry must be a contract\"\n );\n marketRegistry = IMarketRegistry(_marketRegistry);\n\n require(\n _reputationManager.isContract(),\n \"ReputationManager must be a contract\"\n );\n reputationManager = IReputationManager(_reputationManager);\n\n require(\n _collateralManager.isContract(),\n \"CollateralManager must be a contract\"\n );\n collateralManager = ICollateralManager(_collateralManager);\n\n _setLenderManager(_lenderManager);\n }\n\n function setLenderManager(address _lenderManager)\n external\n reinitializer(8)\n onlyOwner\n {\n _setLenderManager(_lenderManager);\n }\n\n function _setLenderManager(address _lenderManager)\n internal\n onlyInitializing\n {\n require(\n _lenderManager.isContract(),\n \"LenderManager must be a contract\"\n );\n lenderManager = ILenderManager(_lenderManager);\n }\n\n /**\n * @notice Gets the metadataURI for a bidId.\n * @param _bidId The id of the bid to return the metadataURI for\n * @return metadataURI_ The metadataURI for the bid, as a string.\n */\n function getMetadataURI(uint256 _bidId)\n public\n view\n returns (string memory metadataURI_)\n {\n // Check uri mapping first\n metadataURI_ = uris[_bidId];\n // If the URI is not present in the mapping\n if (\n keccak256(abi.encodePacked(metadataURI_)) ==\n 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 // hardcoded constant of keccak256('')\n ) {\n // Return depreciated bytes32 uri as a string\n uint256 convertedURI = uint256(bids[_bidId]._metadataURI);\n metadataURI_ = StringsUpgradeable.toHexString(convertedURI, 32);\n }\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol to set a new reputation manager contract.\n * @param _reputationManager The new contract address.\n */\n function setReputationManager(address _reputationManager) public onlyOwner {\n reputationManager = IReputationManager(_reputationManager);\n }\n\n /**\n * @notice Function for a borrower to create a bid for a loan without Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public override whenNotPaused returns (uint256 bidId_) {\n bidId_ = _submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n /**\n * @notice Function for a borrower to create a bid for a loan with Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public override whenNotPaused returns (uint256 bidId_) {\n bidId_ = _submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n\n bool validation = collateralManager.commitCollateral(\n bidId_,\n _collateralInfo\n );\n\n require(\n validation == true,\n \"Collateral balance could not be validated\"\n );\n }\n\n function _submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) internal returns (uint256 bidId_) {\n address sender = _msgSenderForMarket(_marketplaceId);\n (bool isVerified, ) = marketRegistry.isVerifiedBorrower(\n _marketplaceId,\n sender\n );\n require(isVerified, \"Not verified borrower\");\n require(\n !marketRegistry.isMarketClosed(_marketplaceId),\n \"Market is closed\"\n );\n\n // Set response bid ID.\n bidId_ = bidId;\n\n // Create and store our bid into the mapping\n Bid storage bid = bids[bidId];\n bid.borrower = sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketplaceId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n // Set payment cycle type based on market setting (custom or monthly)\n (bid.terms.paymentCycle, bidPaymentCycleType[bidId]) = marketRegistry\n .getPaymentCycle(_marketplaceId);\n\n bid.terms.APR = _APR;\n\n bidDefaultDuration[bidId] = marketRegistry.getPaymentDefaultDuration(\n _marketplaceId\n );\n\n bidExpirationTime[bidId] = marketRegistry.getBidExpirationTime(\n _marketplaceId\n );\n\n bid.paymentType = marketRegistry.getPaymentType(_marketplaceId);\n\n bid.terms.paymentCycleAmount = V2Calculations\n .calculatePaymentCycleAmount(\n bid.paymentType,\n bidPaymentCycleType[bidId],\n _principal,\n _duration,\n bid.terms.paymentCycle,\n _APR\n );\n\n uris[bidId] = _metadataURI;\n bid.state = BidState.PENDING;\n\n emit SubmittedBid(\n bidId,\n bid.borrower,\n bid.receiver,\n keccak256(abi.encodePacked(_metadataURI))\n );\n\n // Store bid inside borrower bids mapping\n borrowerBids[bid.borrower].push(bidId);\n\n // Increment bid id counter\n bidId++;\n }\n\n /**\n * @notice Function for a borrower to cancel their pending bid.\n * @param _bidId The id of the bid to cancel.\n */\n function cancelBid(uint256 _bidId) external {\n if (\n _msgSenderForMarket(bids[_bidId].marketplaceId) !=\n bids[_bidId].borrower\n ) {\n revert ActionNotAllowed({\n bidId: _bidId,\n action: \"cancelBid\",\n message: \"Only the bid owner can cancel!\"\n });\n }\n _cancelBid(_bidId);\n }\n\n /**\n * @notice Function for a market owner to cancel a bid in the market.\n * @param _bidId The id of the bid to cancel.\n */\n function marketOwnerCancelBid(uint256 _bidId) external {\n if (\n _msgSender() !=\n marketRegistry.getMarketOwner(bids[_bidId].marketplaceId)\n ) {\n revert ActionNotAllowed({\n bidId: _bidId,\n action: \"marketOwnerCancelBid\",\n message: \"Only the market owner can cancel!\"\n });\n }\n _cancelBid(_bidId);\n emit MarketOwnerCancelledBid(_bidId);\n }\n\n /**\n * @notice Function for users to cancel a bid.\n * @param _bidId The id of the bid to be cancelled.\n */\n function _cancelBid(uint256 _bidId)\n internal\n pendingBid(_bidId, \"cancelBid\")\n {\n // Set the bid state to CANCELLED\n bids[_bidId].state = BidState.CANCELLED;\n\n // Emit CancelledBid event\n emit CancelledBid(_bidId);\n }\n\n /**\n * @notice Function for a lender to accept a proposed loan bid.\n * @param _bidId The id of the loan bid to accept.\n */\n function lenderAcceptBid(uint256 _bidId)\n external\n override\n pendingBid(_bidId, \"lenderAcceptBid\")\n whenNotPaused\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n // Retrieve bid\n Bid storage bid = bids[_bidId];\n\n address sender = _msgSenderForMarket(bid.marketplaceId);\n\n (bool isVerified, ) = marketRegistry.isVerifiedLender(\n bid.marketplaceId,\n sender\n );\n require(isVerified, \"Not verified lender\");\n\n require(\n !marketRegistry.isMarketClosed(bid.marketplaceId),\n \"Market is closed\"\n );\n\n require(!isLoanExpired(_bidId), \"Bid has expired\");\n\n // Set timestamp\n bid.loanDetails.acceptedTimestamp = uint32(block.timestamp);\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\n\n // Mark borrower's request as accepted\n bid.state = BidState.ACCEPTED;\n\n // Declare the bid acceptor as the lender of the bid\n bid.lender = sender;\n\n // Tell the collateral manager to deploy the escrow and pull funds from the borrower if applicable\n collateralManager.deployAndDeposit(_bidId);\n\n // Transfer funds to borrower from the lender\n amountToProtocol = bid.loanDetails.principal.percent(protocolFee());\n amountToMarketplace = bid.loanDetails.principal.percent(\n marketRegistry.getMarketplaceFee(bid.marketplaceId)\n );\n amountToBorrower =\n bid.loanDetails.principal -\n amountToProtocol -\n amountToMarketplace;\n //transfer fee to protocol\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n owner(),\n amountToProtocol\n );\n\n //transfer fee to marketplace\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n marketRegistry.getMarketFeeRecipient(bid.marketplaceId),\n amountToMarketplace\n );\n\n //transfer funds to borrower\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n bid.receiver,\n amountToBorrower\n );\n\n // Record volume filled by lenders\n lenderVolumeFilled[address(bid.loanDetails.lendingToken)][sender] += bid\n .loanDetails\n .principal;\n totalVolumeFilled[address(bid.loanDetails.lendingToken)] += bid\n .loanDetails\n .principal;\n\n // Add borrower's active bid\n _borrowerBidsActive[bid.borrower].add(_bidId);\n\n // Emit AcceptedBid\n emit AcceptedBid(_bidId, sender);\n\n emit FeePaid(_bidId, \"protocol\", amountToProtocol);\n emit FeePaid(_bidId, \"marketplace\", amountToMarketplace);\n }\n\n function claimLoanNFT(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"claimLoanNFT\")\n whenNotPaused\n {\n // Retrieve bid\n Bid storage bid = bids[_bidId];\n\n address sender = _msgSenderForMarket(bid.marketplaceId);\n require(sender == bid.lender, \"only lender can claim NFT\");\n // mint an NFT with the lender manager\n lenderManager.registerLoan(_bidId, sender);\n // set lender address to the lender manager so we know to check the owner of the NFT for the true lender\n bid.lender = address(lenderManager);\n }\n\n /**\n * @notice Function for users to make the minimum amount due for an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanMinimum(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (\n uint256 owedPrincipal,\n uint256 duePrincipal,\n uint256 interest\n ) = V2Calculations.calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: duePrincipal, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n /**\n * @notice Function for users to repay an active loan in full.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanFull(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: owedPrincipal, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n // function that the borrower (ideally) sends to repay the loan\n /**\n * @notice Function for users to make a payment towards an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _amount The amount of the payment.\n */\n function repayLoan(uint256 _bidId, uint256 _amount)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (\n uint256 owedPrincipal,\n uint256 duePrincipal,\n uint256 interest\n ) = V2Calculations.calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n uint256 minimumOwed = duePrincipal + interest;\n\n // If amount is less than minimumOwed, we revert\n if (_amount < minimumOwed) {\n revert PaymentNotMinimum(_bidId, _amount, minimumOwed);\n }\n\n _repayLoan(\n _bidId,\n Payment({ principal: _amount - interest, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol implement an emergency stop mechanism.\n */\n function pauseProtocol() public virtual onlyOwner whenNotPaused {\n _pause();\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol undo a previously implemented emergency stop.\n */\n function unpauseProtocol() public virtual onlyOwner whenPaused {\n _unpause();\n }\n\n //TODO: add an incentive for liquidator\n /**\n * @notice Function for users to liquidate a defaulted loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function liquidateLoanFull(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"liquidateLoan\")\n {\n require(isLoanDefaulted(_bidId), \"Loan must be defaulted.\");\n\n Bid storage bid = bids[_bidId];\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bid,\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: owedPrincipal, interest: interest }),\n owedPrincipal + interest,\n false\n );\n\n bid.state = BidState.LIQUIDATED;\n\n // If loan is backed by collateral, withdraw and send to the liquidator\n address liquidator = _msgSenderForMarket(bid.marketplaceId);\n collateralManager.liquidateCollateral(_bidId, liquidator);\n\n emit LoanLiquidated(_bidId, liquidator);\n }\n\n /**\n * @notice Internal function to make a loan payment.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _payment The Payment struct with payments amounts towards principal and interest respectively.\n * @param _owedAmount The total amount owed on the loan.\n */\n function _repayLoan(\n uint256 _bidId,\n Payment memory _payment,\n uint256 _owedAmount,\n bool _shouldWithdrawCollateral\n ) internal {\n Bid storage bid = bids[_bidId];\n uint256 paymentAmount = _payment.principal + _payment.interest;\n\n RepMark mark = reputationManager.updateAccountReputation(\n bid.borrower,\n _bidId\n );\n\n // Check if we are sending a payment or amount remaining\n if (paymentAmount >= _owedAmount) {\n paymentAmount = _owedAmount;\n bid.state = BidState.PAID;\n\n // Remove borrower's active bid\n _borrowerBidsActive[bid.borrower].remove(_bidId);\n\n // If loan is is being liquidated and backed by collateral, withdraw and send to borrower\n if (_shouldWithdrawCollateral) {\n collateralManager.withdraw(_bidId);\n }\n\n emit LoanRepaid(_bidId);\n } else {\n emit LoanRepayment(_bidId);\n }\n\n address lender = getLoanLender(_bidId);\n\n // Send payment to the lender\n bid.loanDetails.lendingToken.safeTransferFrom(\n _msgSenderForMarket(bid.marketplaceId),\n lender,\n paymentAmount\n );\n\n // update our mappings\n bid.loanDetails.totalRepaid.principal += _payment.principal;\n bid.loanDetails.totalRepaid.interest += _payment.interest;\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\n\n // If the loan is paid in full and has a mark, we should update the current reputation\n if (mark != RepMark.Good) {\n reputationManager.updateAccountReputation(bid.borrower, _bidId);\n }\n }\n\n /**\n * @notice Calculates the total amount owed for a bid.\n * @param _bidId The id of the loan bid to calculate the owed amount for.\n */\n function calculateAmountOwed(uint256 _bidId)\n public\n view\n returns (Payment memory owed)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return owed;\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n owed.principal = owedPrincipal;\n owed.interest = interest;\n }\n\n /**\n * @notice Calculates the total amount owed for a loan bid at a specific timestamp.\n * @param _bidId The id of the loan bid to calculate the owed amount for.\n * @param _timestamp The timestamp at which to calculate the loan owed amount at.\n */\n function calculateAmountOwed(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory owed)\n {\n Bid storage bid = bids[_bidId];\n if (\n bid.state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return owed;\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n owed.principal = owedPrincipal;\n owed.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Returns the next due date for a loan payment.\n * @param _bidId The id of the loan bid.\n */\n function calculateNextDueDate(uint256 _bidId)\n public\n view\n returns (uint32 dueDate_)\n {\n Bid storage bid = bids[_bidId];\n if (bids[_bidId].state != BidState.ACCEPTED) return dueDate_;\n\n uint32 lastRepaidTimestamp = lastRepaidTimestamp(_bidId);\n\n // Calculate due date if payment cycle is set to monthly\n if (bidPaymentCycleType[_bidId] == PaymentCycleType.Monthly) {\n // Calculate the cycle number the last repayment was made\n uint256 lastPaymentCycle = BPBDTL.diffMonths(\n bid.loanDetails.acceptedTimestamp,\n lastRepaidTimestamp\n );\n if (\n BPBDTL.getDay(lastRepaidTimestamp) >\n BPBDTL.getDay(bid.loanDetails.acceptedTimestamp)\n ) {\n lastPaymentCycle += 2;\n } else {\n lastPaymentCycle += 1;\n }\n\n dueDate_ = uint32(\n BPBDTL.addMonths(\n bid.loanDetails.acceptedTimestamp,\n lastPaymentCycle\n )\n );\n } else if (bidPaymentCycleType[_bidId] == PaymentCycleType.Seconds) {\n // Start with the original due date being 1 payment cycle since bid was accepted\n dueDate_ =\n bid.loanDetails.acceptedTimestamp +\n bid.terms.paymentCycle;\n // Calculate the cycle number the last repayment was made\n uint32 delta = lastRepaidTimestamp -\n bid.loanDetails.acceptedTimestamp;\n if (delta > 0) {\n uint32 repaymentCycle = uint32(\n Math.ceilDiv(delta, bid.terms.paymentCycle)\n );\n dueDate_ += (repaymentCycle * bid.terms.paymentCycle);\n }\n }\n\n uint32 endOfLoan = bid.loanDetails.acceptedTimestamp +\n bid.loanDetails.loanDuration;\n //if we are in the last payment cycle, the next due date is the end of loan duration\n if (dueDate_ > endOfLoan) {\n dueDate_ = endOfLoan;\n }\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isPaymentLate(uint256 _bidId) public view override returns (bool) {\n if (bids[_bidId].state != BidState.ACCEPTED) return false;\n return uint32(block.timestamp) > calculateNextDueDate(_bidId);\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanDefaulted(uint256 _bidId)\n public\n view\n override\n returns (bool)\n {\n Bid storage bid = bids[_bidId];\n\n // Make sure loan cannot be liquidated if it is not active\n if (bid.state != BidState.ACCEPTED) return false;\n\n if (bidDefaultDuration[_bidId] == 0) return false;\n\n return (uint32(block.timestamp) - lastRepaidTimestamp(_bidId) >\n bidDefaultDuration[_bidId]);\n }\n\n function getBidState(uint256 _bidId)\n external\n view\n override\n returns (BidState)\n {\n return bids[_bidId].state;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n external\n view\n override\n returns (uint256[] memory)\n {\n return _borrowerBidsActive[_borrower].values();\n }\n\n function getBorrowerLoanIds(address _borrower)\n external\n view\n returns (uint256[] memory)\n {\n return borrowerBids[_borrower];\n }\n\n /**\n * @notice Checks to see if a pending loan has expired so it is no longer able to be accepted.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanExpired(uint256 _bidId) public view returns (bool) {\n Bid storage bid = bids[_bidId];\n\n if (bid.state != BidState.PENDING) return false;\n if (bidExpirationTime[_bidId] == 0) return false;\n\n return (uint32(block.timestamp) >\n bid.loanDetails.timestamp + bidExpirationTime[_bidId]);\n }\n\n /**\n * @notice Returns the last repaid timestamp for a loan.\n * @param _bidId The id of the loan bid to get the timestamp for.\n */\n function lastRepaidTimestamp(uint256 _bidId) public view returns (uint32) {\n return V2Calculations.lastRepaidTimestamp(bids[_bidId]);\n }\n\n /**\n * @notice Returns the borrower address for a given bid.\n * @param _bidId The id of the bid/loan to get the borrower for.\n * @return borrower_ The address of the borrower associated with the bid.\n */\n function getLoanBorrower(uint256 _bidId)\n public\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n /**\n * @notice Returns the lender address for a given bid. If the stored lender address is the `LenderManager` NFT address, return the `ownerOf` for the bid ID.\n * @param _bidId The id of the bid/loan to get the lender for.\n * @return lender_ The address of the lender associated with the bid.\n */\n function getLoanLender(uint256 _bidId)\n public\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n\n if (lender_ == address(lenderManager)) {\n return lenderManager.ownerOf(_bidId);\n }\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n /** OpenZeppelin Override Functions **/\n\n function _msgSender()\n internal\n view\n virtual\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\n returns (address sender)\n {\n sender = ERC2771ContextUpgradeable._msgSender();\n }\n\n function _msgData()\n internal\n view\n virtual\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\n returns (bytes calldata)\n {\n return ERC2771ContextUpgradeable._msgData();\n }\n}\n" - }, - "contracts/MarketRegistry.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// Contracts\nimport \"./EAS/TellerAS.sol\";\nimport \"./EAS/TellerASResolver.sol\";\n\n//must continue to use this so storage slots are not broken\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n// Interfaces\nimport \"./interfaces/IMarketRegistry.sol\";\n\n// Libraries\nimport { EnumerableSet } from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport { PaymentType } from \"./libraries/V2Calculations.sol\";\n\ncontract MarketRegistry is\n IMarketRegistry,\n Initializable,\n Context,\n TellerASResolver\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n /** Constant Variables **/\n\n uint256 public constant CURRENT_CODE_VERSION = 8;\n\n /* Storage Variables */\n\n struct Marketplace {\n address owner;\n string metadataURI;\n uint16 marketplaceFeePercent; // 10000 is 100%\n bool lenderAttestationRequired;\n EnumerableSet.AddressSet verifiedLendersForMarket;\n mapping(address => bytes32) lenderAttestationIds;\n uint32 paymentCycleDuration; // unix time (seconds)\n uint32 paymentDefaultDuration; //unix time\n uint32 bidExpirationTime; //unix time\n bool borrowerAttestationRequired;\n EnumerableSet.AddressSet verifiedBorrowersForMarket;\n mapping(address => bytes32) borrowerAttestationIds;\n address feeRecipient;\n PaymentType paymentType;\n PaymentCycleType paymentCycleType;\n }\n\n bytes32 public lenderAttestationSchemaId;\n\n mapping(uint256 => Marketplace) internal markets;\n mapping(bytes32 => uint256) internal __uriToId; //DEPRECATED\n uint256 public marketCount;\n bytes32 private _attestingSchemaId;\n bytes32 public borrowerAttestationSchemaId;\n\n uint256 public version;\n\n mapping(uint256 => bool) private marketIsClosed;\n\n TellerAS public tellerAS;\n\n /* Modifiers */\n\n modifier ownsMarket(uint256 _marketId) {\n require(markets[_marketId].owner == _msgSender(), \"Not the owner\");\n _;\n }\n\n modifier withAttestingSchema(bytes32 schemaId) {\n _attestingSchemaId = schemaId;\n _;\n _attestingSchemaId = bytes32(0);\n }\n\n /* Events */\n\n event MarketCreated(address indexed owner, uint256 marketId);\n event SetMarketURI(uint256 marketId, string uri);\n event SetPaymentCycleDuration(uint256 marketId, uint32 duration); // DEPRECATED - used for subgraph reference\n event SetPaymentCycle(\n uint256 marketId,\n PaymentCycleType paymentCycleType,\n uint32 value\n );\n event SetPaymentDefaultDuration(uint256 marketId, uint32 duration);\n event SetBidExpirationTime(uint256 marketId, uint32 duration);\n event SetMarketFee(uint256 marketId, uint16 feePct);\n event LenderAttestation(uint256 marketId, address lender);\n event BorrowerAttestation(uint256 marketId, address borrower);\n event LenderRevocation(uint256 marketId, address lender);\n event BorrowerRevocation(uint256 marketId, address borrower);\n event MarketClosed(uint256 marketId);\n event LenderExitMarket(uint256 marketId, address lender);\n event BorrowerExitMarket(uint256 marketId, address borrower);\n event SetMarketOwner(uint256 marketId, address newOwner);\n event SetMarketFeeRecipient(uint256 marketId, address newRecipient);\n event SetMarketLenderAttestation(uint256 marketId, bool required);\n event SetMarketBorrowerAttestation(uint256 marketId, bool required);\n event SetMarketPaymentType(uint256 marketId, PaymentType paymentType);\n\n /* External Functions */\n\n function initialize(TellerAS _tellerAS) external initializer {\n tellerAS = _tellerAS;\n\n lenderAttestationSchemaId = tellerAS.getASRegistry().register(\n \"(uint256 marketId, address lenderAddress)\",\n this\n );\n borrowerAttestationSchemaId = tellerAS.getASRegistry().register(\n \"(uint256 marketId, address borrowerAddress)\",\n this\n );\n }\n\n /**\n * @notice Creates a new market.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _paymentType The payment type for loans in the market.\n * @param _uri URI string to get metadata details about the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @return marketId_ The market ID of the newly created market.\n */\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) external returns (uint256 marketId_) {\n marketId_ = _createMarket(\n _initialOwner,\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n _paymentCycleType,\n _uri\n );\n }\n\n /**\n * @notice Creates a new market.\n * @dev Uses the default EMI payment type.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _uri URI string to get metadata details about the market.\n * @return marketId_ The market ID of the newly created market.\n */\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) external returns (uint256 marketId_) {\n marketId_ = _createMarket(\n _initialOwner,\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n _uri\n );\n }\n\n /**\n * @notice Creates a new market.\n * @param _initialOwner Address who will initially own the market.\n * @param _paymentCycleDuration Length of time in seconds before a bid's next payment is required to be made.\n * @param _paymentDefaultDuration Length of time in seconds before a loan is considered in default for non-payment.\n * @param _bidExpirationTime Length of time in seconds before pending bids expire.\n * @param _requireLenderAttestation Boolean that indicates if lenders require attestation to join market.\n * @param _requireBorrowerAttestation Boolean that indicates if borrowers require attestation to join market.\n * @param _paymentType The payment type for loans in the market.\n * @param _uri URI string to get metadata details about the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @return marketId_ The market ID of the newly created market.\n */\n function _createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) internal returns (uint256 marketId_) {\n require(_initialOwner != address(0), \"Invalid owner address\");\n // Increment market ID counter\n marketId_ = ++marketCount;\n\n // Set the market owner\n markets[marketId_].owner = _initialOwner;\n\n // Initialize market settings\n _setMarketSettings(\n marketId_,\n _paymentCycleDuration,\n _paymentType,\n _paymentCycleType,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireBorrowerAttestation,\n _requireLenderAttestation,\n _uri\n );\n\n emit MarketCreated(_initialOwner, marketId_);\n }\n\n /**\n * @notice Closes a market so new bids cannot be added.\n * @param _marketId The market ID for the market to close.\n */\n\n function closeMarket(uint256 _marketId) public ownsMarket(_marketId) {\n if (!marketIsClosed[_marketId]) {\n marketIsClosed[_marketId] = true;\n\n emit MarketClosed(_marketId);\n }\n }\n\n /**\n * @notice Returns the status of a market being open or closed for new bids.\n * @param _marketId The market ID for the market to check.\n */\n function isMarketClosed(uint256 _marketId)\n public\n view\n override\n returns (bool)\n {\n return marketIsClosed[_marketId];\n }\n\n /**\n * @notice Adds a lender to a market.\n * @dev See {_attestStakeholder}.\n */\n function attestLender(\n uint256 _marketId,\n address _lenderAddress,\n uint256 _expirationTime\n ) external {\n _attestStakeholder(_marketId, _lenderAddress, _expirationTime, true);\n }\n\n /**\n * @notice Adds a lender to a market via delegated attestation.\n * @dev See {_attestStakeholderViaDelegation}.\n */\n function attestLender(\n uint256 _marketId,\n address _lenderAddress,\n uint256 _expirationTime,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _attestStakeholderViaDelegation(\n _marketId,\n _lenderAddress,\n _expirationTime,\n true,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Removes a lender from an market.\n * @dev See {_revokeStakeholder}.\n */\n function revokeLender(uint256 _marketId, address _lenderAddress) external {\n _revokeStakeholder(_marketId, _lenderAddress, true);\n }\n\n /**\n * @notice Removes a borrower from a market via delegated revocation.\n * @dev See {_revokeStakeholderViaDelegation}.\n */\n function revokeLender(\n uint256 _marketId,\n address _lenderAddress,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _revokeStakeholderViaDelegation(\n _marketId,\n _lenderAddress,\n true,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Allows a lender to voluntarily leave a market.\n * @param _marketId The market ID to leave.\n */\n function lenderExitMarket(uint256 _marketId) external {\n // Remove lender address from market set\n bool response = markets[_marketId].verifiedLendersForMarket.remove(\n _msgSender()\n );\n if (response) {\n emit LenderExitMarket(_marketId, _msgSender());\n }\n }\n\n /**\n * @notice Adds a borrower to a market.\n * @dev See {_attestStakeholder}.\n */\n function attestBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint256 _expirationTime\n ) external {\n _attestStakeholder(_marketId, _borrowerAddress, _expirationTime, false);\n }\n\n /**\n * @notice Adds a borrower to a market via delegated attestation.\n * @dev See {_attestStakeholderViaDelegation}.\n */\n function attestBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint256 _expirationTime,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _attestStakeholderViaDelegation(\n _marketId,\n _borrowerAddress,\n _expirationTime,\n false,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Removes a borrower from an market.\n * @dev See {_revokeStakeholder}.\n */\n function revokeBorrower(uint256 _marketId, address _borrowerAddress)\n external\n {\n _revokeStakeholder(_marketId, _borrowerAddress, false);\n }\n\n /**\n * @notice Removes a borrower from a market via delegated revocation.\n * @dev See {_revokeStakeholderViaDelegation}.\n */\n function revokeBorrower(\n uint256 _marketId,\n address _borrowerAddress,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n _revokeStakeholderViaDelegation(\n _marketId,\n _borrowerAddress,\n false,\n _v,\n _r,\n _s\n );\n }\n\n /**\n * @notice Allows a borrower to voluntarily leave a market.\n * @param _marketId The market ID to leave.\n */\n function borrowerExitMarket(uint256 _marketId) external {\n // Remove borrower address from market set\n bool response = markets[_marketId].verifiedBorrowersForMarket.remove(\n _msgSender()\n );\n if (response) {\n emit BorrowerExitMarket(_marketId, _msgSender());\n }\n }\n\n /**\n * @notice Verifies an attestation is valid.\n * @dev This function must only be called by the `attestLender` function above.\n * @param recipient Lender's address who is being attested.\n * @param schema The schema used for the attestation.\n * @param data Data the must include the market ID and lender's address\n * @param\n * @param attestor Market owner's address who signed the attestation.\n * @return Boolean indicating the attestation was successful.\n */\n function resolve(\n address recipient,\n bytes calldata schema,\n bytes calldata data,\n uint256 /* expirationTime */,\n address attestor\n ) external payable override returns (bool) {\n bytes32 attestationSchemaId = keccak256(\n abi.encodePacked(schema, address(this))\n );\n (uint256 marketId, address lenderAddress) = abi.decode(\n data,\n (uint256, address)\n );\n return\n (_attestingSchemaId == attestationSchemaId &&\n recipient == lenderAddress &&\n attestor == markets[marketId].owner) ||\n attestor == address(this);\n }\n\n /**\n * @notice Transfers ownership of a marketplace.\n * @param _marketId The ID of a market.\n * @param _newOwner Address of the new market owner.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function transferMarketOwnership(uint256 _marketId, address _newOwner)\n public\n ownsMarket(_marketId)\n {\n markets[_marketId].owner = _newOwner;\n emit SetMarketOwner(_marketId, _newOwner);\n }\n\n /**\n * @notice Updates multiple market settings for a given market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleDuration Delinquency duration for new loans\n * @param _newPaymentType The payment type for the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @param _paymentDefaultDuration Default duration for new loans\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\n * @param _metadataURI A URI that points to a market's metadata.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function updateMarketSettings(\n uint256 _marketId,\n uint32 _paymentCycleDuration,\n PaymentType _newPaymentType,\n PaymentCycleType _paymentCycleType,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _borrowerAttestationRequired,\n bool _lenderAttestationRequired,\n string calldata _metadataURI\n ) public ownsMarket(_marketId) {\n _setMarketSettings(\n _marketId,\n _paymentCycleDuration,\n _newPaymentType,\n _paymentCycleType,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _borrowerAttestationRequired,\n _lenderAttestationRequired,\n _metadataURI\n );\n }\n\n /**\n * @notice Sets the fee recipient address for a market.\n * @param _marketId The ID of a market.\n * @param _recipient Address of the new fee recipient.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketFeeRecipient(uint256 _marketId, address _recipient)\n public\n ownsMarket(_marketId)\n {\n markets[_marketId].feeRecipient = _recipient;\n emit SetMarketFeeRecipient(_marketId, _recipient);\n }\n\n /**\n * @notice Sets the metadata URI for a market.\n * @param _marketId The ID of a market.\n * @param _uri A URI that points to a market's metadata.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketURI(uint256 _marketId, string calldata _uri)\n public\n ownsMarket(_marketId)\n {\n //We do string comparison by checking the hashes of the strings against one another\n if (\n keccak256(abi.encodePacked(_uri)) !=\n keccak256(abi.encodePacked(markets[_marketId].metadataURI))\n ) {\n markets[_marketId].metadataURI = _uri;\n\n emit SetMarketURI(_marketId, _uri);\n }\n }\n\n /**\n * @notice Sets the duration of new loans for this market before they turn delinquent.\n * @notice Changing this value does not change the terms of existing loans for this market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleType Cycle type (seconds or monthly)\n * @param _duration Delinquency duration for new loans\n */\n function setPaymentCycle(\n uint256 _marketId,\n PaymentCycleType _paymentCycleType,\n uint32 _duration\n ) public ownsMarket(_marketId) {\n require(\n (_paymentCycleType == PaymentCycleType.Seconds) ||\n (_paymentCycleType == PaymentCycleType.Monthly &&\n _duration == 0),\n \"monthly payment cycle duration cannot be set\"\n );\n Marketplace storage market = markets[_marketId];\n uint32 duration = _paymentCycleType == PaymentCycleType.Seconds\n ? _duration\n : 30 days;\n if (\n _paymentCycleType != market.paymentCycleType ||\n duration != market.paymentCycleDuration\n ) {\n markets[_marketId].paymentCycleType = _paymentCycleType;\n markets[_marketId].paymentCycleDuration = duration;\n\n emit SetPaymentCycle(_marketId, _paymentCycleType, duration);\n }\n }\n\n /**\n * @notice Sets the duration of new loans for this market before they turn defaulted.\n * @notice Changing this value does not change the terms of existing loans for this market.\n * @param _marketId The ID of a market.\n * @param _duration Default duration for new loans\n */\n function setPaymentDefaultDuration(uint256 _marketId, uint32 _duration)\n public\n ownsMarket(_marketId)\n {\n if (_duration != markets[_marketId].paymentDefaultDuration) {\n markets[_marketId].paymentDefaultDuration = _duration;\n\n emit SetPaymentDefaultDuration(_marketId, _duration);\n }\n }\n\n function setBidExpirationTime(uint256 _marketId, uint32 _duration)\n public\n ownsMarket(_marketId)\n {\n if (_duration != markets[_marketId].bidExpirationTime) {\n markets[_marketId].bidExpirationTime = _duration;\n\n emit SetBidExpirationTime(_marketId, _duration);\n }\n }\n\n /**\n * @notice Sets the fee for the market.\n * @param _marketId The ID of a market.\n * @param _newPercent The percentage fee in basis points.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setMarketFeePercent(uint256 _marketId, uint16 _newPercent)\n public\n ownsMarket(_marketId)\n {\n require(_newPercent >= 0 && _newPercent <= 10000, \"invalid percent\");\n if (_newPercent != markets[_marketId].marketplaceFeePercent) {\n markets[_marketId].marketplaceFeePercent = _newPercent;\n emit SetMarketFee(_marketId, _newPercent);\n }\n }\n\n /**\n * @notice Set the payment type for the market.\n * @param _marketId The ID of the market.\n * @param _newPaymentType The payment type for the market.\n */\n function setMarketPaymentType(\n uint256 _marketId,\n PaymentType _newPaymentType\n ) public ownsMarket(_marketId) {\n if (_newPaymentType != markets[_marketId].paymentType) {\n markets[_marketId].paymentType = _newPaymentType;\n emit SetMarketPaymentType(_marketId, _newPaymentType);\n }\n }\n\n /**\n * @notice Enable/disables market whitelist for lenders.\n * @param _marketId The ID of a market.\n * @param _required Boolean indicating if the market requires whitelist.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setLenderAttestationRequired(uint256 _marketId, bool _required)\n public\n ownsMarket(_marketId)\n {\n if (_required != markets[_marketId].lenderAttestationRequired) {\n markets[_marketId].lenderAttestationRequired = _required;\n emit SetMarketLenderAttestation(_marketId, _required);\n }\n }\n\n /**\n * @notice Enable/disables market whitelist for borrowers.\n * @param _marketId The ID of a market.\n * @param _required Boolean indicating if the market requires whitelist.\n *\n * Requirements:\n * - The caller must be the current owner.\n */\n function setBorrowerAttestationRequired(uint256 _marketId, bool _required)\n public\n ownsMarket(_marketId)\n {\n if (_required != markets[_marketId].borrowerAttestationRequired) {\n markets[_marketId].borrowerAttestationRequired = _required;\n emit SetMarketBorrowerAttestation(_marketId, _required);\n }\n }\n\n /**\n * @notice Gets the data associated with a market.\n * @param _marketId The ID of a market.\n */\n function getMarketData(uint256 _marketId)\n public\n view\n returns (\n address owner,\n uint32 paymentCycleDuration,\n uint32 paymentDefaultDuration,\n uint32 loanExpirationTime,\n string memory metadataURI,\n uint16 marketplaceFeePercent,\n bool lenderAttestationRequired\n )\n {\n return (\n markets[_marketId].owner,\n markets[_marketId].paymentCycleDuration,\n markets[_marketId].paymentDefaultDuration,\n markets[_marketId].bidExpirationTime,\n markets[_marketId].metadataURI,\n markets[_marketId].marketplaceFeePercent,\n markets[_marketId].lenderAttestationRequired\n );\n }\n\n /**\n * @notice Gets the attestation requirements for a given market.\n * @param _marketId The ID of the market.\n */\n function getMarketAttestationRequirements(uint256 _marketId)\n public\n view\n returns (\n bool lenderAttestationRequired,\n bool borrowerAttestationRequired\n )\n {\n return (\n markets[_marketId].lenderAttestationRequired,\n markets[_marketId].borrowerAttestationRequired\n );\n }\n\n /**\n * @notice Gets the address of a market's owner.\n * @param _marketId The ID of a market.\n * @return The address of a market's owner.\n */\n function getMarketOwner(uint256 _marketId)\n public\n view\n override\n returns (address)\n {\n return markets[_marketId].owner;\n }\n\n /**\n * @notice Gets the fee recipient of a market.\n * @param _marketId The ID of a market.\n * @return The address of a market's fee recipient.\n */\n function getMarketFeeRecipient(uint256 _marketId)\n public\n view\n override\n returns (address)\n {\n address recipient = markets[_marketId].feeRecipient;\n\n if (recipient == address(0)) {\n return markets[_marketId].owner;\n }\n\n return recipient;\n }\n\n /**\n * @notice Gets the metadata URI of a market.\n * @param _marketId The ID of a market.\n * @return URI of a market's metadata.\n */\n function getMarketURI(uint256 _marketId)\n public\n view\n override\n returns (string memory)\n {\n return markets[_marketId].metadataURI;\n }\n\n /**\n * @notice Gets the loan delinquent duration of a market.\n * @param _marketId The ID of a market.\n * @return Duration of a loan until it is delinquent.\n * @return The type of payment cycle for loans in the market.\n */\n function getPaymentCycle(uint256 _marketId)\n public\n view\n override\n returns (uint32, PaymentCycleType)\n {\n return (\n markets[_marketId].paymentCycleDuration,\n markets[_marketId].paymentCycleType\n );\n }\n\n /**\n * @notice Gets the loan default duration of a market.\n * @param _marketId The ID of a market.\n * @return Duration of a loan repayment interval until it is default.\n */\n function getPaymentDefaultDuration(uint256 _marketId)\n public\n view\n override\n returns (uint32)\n {\n return markets[_marketId].paymentDefaultDuration;\n }\n\n /**\n * @notice Get the payment type of a market.\n * @param _marketId the ID of the market.\n * @return The type of payment for loans in the market.\n */\n function getPaymentType(uint256 _marketId)\n public\n view\n override\n returns (PaymentType)\n {\n return markets[_marketId].paymentType;\n }\n\n function getBidExpirationTime(uint256 marketId)\n public\n view\n override\n returns (uint32)\n {\n return markets[marketId].bidExpirationTime;\n }\n\n /**\n * @notice Gets the marketplace fee in basis points\n * @param _marketId The ID of a market.\n * @return fee in basis points\n */\n function getMarketplaceFee(uint256 _marketId)\n public\n view\n override\n returns (uint16 fee)\n {\n return markets[_marketId].marketplaceFeePercent;\n }\n\n /**\n * @notice Checks if a lender has been attested and added to a market.\n * @param _marketId The ID of a market.\n * @param _lenderAddress Address to check.\n * @return isVerified_ Boolean indicating if a lender has been added to a market.\n * @return uuid_ Bytes32 representing the UUID of the lender.\n */\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\n public\n view\n override\n returns (bool isVerified_, bytes32 uuid_)\n {\n return\n _isVerified(\n _lenderAddress,\n markets[_marketId].lenderAttestationRequired,\n markets[_marketId].lenderAttestationIds,\n markets[_marketId].verifiedLendersForMarket\n );\n }\n\n /**\n * @notice Checks if a borrower has been attested and added to a market.\n * @param _marketId The ID of a market.\n * @param _borrowerAddress Address of the borrower to check.\n * @return isVerified_ Boolean indicating if a borrower has been added to a market.\n * @return uuid_ Bytes32 representing the UUID of the borrower.\n */\n function isVerifiedBorrower(uint256 _marketId, address _borrowerAddress)\n public\n view\n override\n returns (bool isVerified_, bytes32 uuid_)\n {\n return\n _isVerified(\n _borrowerAddress,\n markets[_marketId].borrowerAttestationRequired,\n markets[_marketId].borrowerAttestationIds,\n markets[_marketId].verifiedBorrowersForMarket\n );\n }\n\n /**\n * @notice Gets addresses of all attested lenders.\n * @param _marketId The ID of a market.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return Array of addresses that have been added to a market.\n */\n function getAllVerifiedLendersForMarket(\n uint256 _marketId,\n uint256 _page,\n uint256 _perPage\n ) public view returns (address[] memory) {\n EnumerableSet.AddressSet storage set = markets[_marketId]\n .verifiedLendersForMarket;\n\n return _getStakeholdersForMarket(set, _page, _perPage);\n }\n\n /**\n * @notice Gets addresses of all attested borrowers.\n * @param _marketId The ID of the market.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return Array of addresses that have been added to a market.\n */\n function getAllVerifiedBorrowersForMarket(\n uint256 _marketId,\n uint256 _page,\n uint256 _perPage\n ) public view returns (address[] memory) {\n EnumerableSet.AddressSet storage set = markets[_marketId]\n .verifiedBorrowersForMarket;\n return _getStakeholdersForMarket(set, _page, _perPage);\n }\n\n /**\n * @notice Sets multiple market settings for a given market.\n * @param _marketId The ID of a market.\n * @param _paymentCycleDuration Delinquency duration for new loans\n * @param _newPaymentType The payment type for the market.\n * @param _paymentCycleType The payment cycle type for loans in the market - Seconds or Monthly\n * @param _paymentDefaultDuration Default duration for new loans\n * @param _bidExpirationTime Duration of time before a bid is considered out of date\n * @param _metadataURI A URI that points to a market's metadata.\n */\n function _setMarketSettings(\n uint256 _marketId,\n uint32 _paymentCycleDuration,\n PaymentType _newPaymentType,\n PaymentCycleType _paymentCycleType,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _borrowerAttestationRequired,\n bool _lenderAttestationRequired,\n string calldata _metadataURI\n ) internal {\n setMarketURI(_marketId, _metadataURI);\n setPaymentDefaultDuration(_marketId, _paymentDefaultDuration);\n setBidExpirationTime(_marketId, _bidExpirationTime);\n setMarketFeePercent(_marketId, _feePercent);\n setLenderAttestationRequired(_marketId, _lenderAttestationRequired);\n setBorrowerAttestationRequired(_marketId, _borrowerAttestationRequired);\n setMarketPaymentType(_marketId, _newPaymentType);\n setPaymentCycle(_marketId, _paymentCycleType, _paymentCycleDuration);\n }\n\n /**\n * @notice Gets addresses of all attested relevant stakeholders.\n * @param _set The stored set of stakeholders to index from.\n * @param _page Page index to start from.\n * @param _perPage Number of items in a page to return.\n * @return stakeholders_ Array of addresses that have been added to a market.\n */\n function _getStakeholdersForMarket(\n EnumerableSet.AddressSet storage _set,\n uint256 _page,\n uint256 _perPage\n ) internal view returns (address[] memory stakeholders_) {\n uint256 len = _set.length();\n\n uint256 start = _page * _perPage;\n if (start <= len) {\n uint256 end = start + _perPage;\n // Ensure we do not go out of bounds\n if (end > len) {\n end = len;\n }\n\n stakeholders_ = new address[](end - start);\n for (uint256 i = start; i < end; i++) {\n stakeholders_[i] = _set.at(i);\n }\n }\n }\n\n /* Internal Functions */\n\n /**\n * @notice Adds a stakeholder (lender or borrower) to a market.\n * @param _marketId The market ID to add a borrower to.\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\n * @param _expirationTime The expiration time of the attestation.\n * @param _expirationTime The expiration time of the attestation.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _attestStakeholder(\n uint256 _marketId,\n address _stakeholderAddress,\n uint256 _expirationTime,\n bool _isLender\n )\n internal\n withAttestingSchema(\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\n )\n {\n require(\n _msgSender() == markets[_marketId].owner,\n \"Not the market owner\"\n );\n\n // Submit attestation for borrower to join a market\n bytes32 uuid = tellerAS.attest(\n _stakeholderAddress,\n _attestingSchemaId, // set by the modifier\n _expirationTime,\n 0,\n abi.encode(_marketId, _stakeholderAddress)\n );\n _attestStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n uuid,\n _isLender\n );\n }\n\n /**\n * @notice Adds a stakeholder (lender or borrower) to a market via delegated attestation.\n * @dev The signature must match that of the market owner.\n * @param _marketId The market ID to add a lender to.\n * @param _stakeholderAddress The address of the lender to add to the market.\n * @param _expirationTime The expiration time of the attestation.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @param _v Signature value\n * @param _r Signature value\n * @param _s Signature value\n */\n function _attestStakeholderViaDelegation(\n uint256 _marketId,\n address _stakeholderAddress,\n uint256 _expirationTime,\n bool _isLender,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n )\n internal\n withAttestingSchema(\n _isLender ? lenderAttestationSchemaId : borrowerAttestationSchemaId\n )\n {\n // NOTE: block scope to prevent stack too deep!\n bytes32 uuid;\n {\n bytes memory data = abi.encode(_marketId, _stakeholderAddress);\n address attestor = markets[_marketId].owner;\n // Submit attestation for stakeholder to join a market (attestation must be signed by market owner)\n uuid = tellerAS.attestByDelegation(\n _stakeholderAddress,\n _attestingSchemaId, // set by the modifier\n _expirationTime,\n 0,\n data,\n attestor,\n _v,\n _r,\n _s\n );\n }\n _attestStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n uuid,\n _isLender\n );\n }\n\n /**\n * @notice Adds a stakeholder (borrower/lender) to a market.\n * @param _marketId The market ID to add a stakeholder to.\n * @param _stakeholderAddress The address of the stakeholder to add to the market.\n * @param _uuid The UUID of the attestation created.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _attestStakeholderVerification(\n uint256 _marketId,\n address _stakeholderAddress,\n bytes32 _uuid,\n bool _isLender\n ) internal {\n if (_isLender) {\n // Store the lender attestation ID for the market ID\n markets[_marketId].lenderAttestationIds[\n _stakeholderAddress\n ] = _uuid;\n // Add lender address to market set\n markets[_marketId].verifiedLendersForMarket.add(\n _stakeholderAddress\n );\n\n emit LenderAttestation(_marketId, _stakeholderAddress);\n } else {\n // Store the lender attestation ID for the market ID\n markets[_marketId].borrowerAttestationIds[\n _stakeholderAddress\n ] = _uuid;\n // Add lender address to market set\n markets[_marketId].verifiedBorrowersForMarket.add(\n _stakeholderAddress\n );\n\n emit BorrowerAttestation(_marketId, _stakeholderAddress);\n }\n }\n\n /**\n * @notice Removes a stakeholder from an market.\n * @dev The caller must be the market owner.\n * @param _marketId The market ID to remove the borrower from.\n * @param _stakeholderAddress The address of the borrower to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n */\n function _revokeStakeholder(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender\n ) internal {\n require(\n _msgSender() == markets[_marketId].owner,\n \"Not the market owner\"\n );\n\n bytes32 uuid = _revokeStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n _isLender\n );\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\n // tellerAS.revoke(uuid);\n }\n\n /**\n * @notice Removes a stakeholder from an market via delegated revocation.\n * @param _marketId The market ID to remove the borrower from.\n * @param _stakeholderAddress The address of the borrower to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @param _v Signature value\n * @param _r Signature value\n * @param _s Signature value\n */\n function _revokeStakeholderViaDelegation(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) internal {\n bytes32 uuid = _revokeStakeholderVerification(\n _marketId,\n _stakeholderAddress,\n _isLender\n );\n // NOTE: Disabling the call to revoke the attestation on EAS contracts\n // address attestor = markets[_marketId].owner;\n // tellerAS.revokeByDelegation(uuid, attestor, _v, _r, _s);\n }\n\n /**\n * @notice Removes a stakeholder (borrower/lender) from a market.\n * @param _marketId The market ID to remove the lender from.\n * @param _stakeholderAddress The address of the stakeholder to remove from the market.\n * @param _isLender Boolean indicating if the stakeholder is a lender. Otherwise it is a borrower.\n * @return uuid_ The ID of the previously verified attestation.\n */\n function _revokeStakeholderVerification(\n uint256 _marketId,\n address _stakeholderAddress,\n bool _isLender\n ) internal returns (bytes32 uuid_) {\n if (_isLender) {\n uuid_ = markets[_marketId].lenderAttestationIds[\n _stakeholderAddress\n ];\n // Remove lender address from market set\n markets[_marketId].verifiedLendersForMarket.remove(\n _stakeholderAddress\n );\n\n emit LenderRevocation(_marketId, _stakeholderAddress);\n } else {\n uuid_ = markets[_marketId].borrowerAttestationIds[\n _stakeholderAddress\n ];\n // Remove borrower address from market set\n markets[_marketId].verifiedBorrowersForMarket.remove(\n _stakeholderAddress\n );\n\n emit BorrowerRevocation(_marketId, _stakeholderAddress);\n }\n }\n\n /**\n * @notice Checks if a stakeholder has been attested and added to a market.\n * @param _stakeholderAddress Address of the stakeholder to check.\n * @param _attestationRequired Stored boolean indicating if attestation is required for the stakeholder class.\n * @param _stakeholderAttestationIds Mapping of attested Ids for the stakeholder class.\n */\n function _isVerified(\n address _stakeholderAddress,\n bool _attestationRequired,\n mapping(address => bytes32) storage _stakeholderAttestationIds,\n EnumerableSet.AddressSet storage _verifiedStakeholderForMarket\n ) internal view returns (bool isVerified_, bytes32 uuid_) {\n if (_attestationRequired) {\n isVerified_ =\n _verifiedStakeholderForMarket.contains(_stakeholderAddress) &&\n tellerAS.isAttestationActive(\n _stakeholderAttestationIds[_stakeholderAddress]\n );\n uuid_ = _stakeholderAttestationIds[_stakeholderAddress];\n } else {\n isVerified_ = true;\n }\n }\n}\n" - }, - "contracts/ReputationManager.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n// Interfaces\nimport \"./interfaces/IReputationManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract ReputationManager is IReputationManager, Initializable {\n using EnumerableSet for EnumerableSet.UintSet;\n\n bytes32 public constant CONTROLLER = keccak256(\"CONTROLLER\");\n\n ITellerV2 public tellerV2;\n mapping(address => EnumerableSet.UintSet) private _delinquencies;\n mapping(address => EnumerableSet.UintSet) private _defaults;\n mapping(address => EnumerableSet.UintSet) private _currentDelinquencies;\n mapping(address => EnumerableSet.UintSet) private _currentDefaults;\n\n event MarkAdded(\n address indexed account,\n RepMark indexed repMark,\n uint256 bidId\n );\n event MarkRemoved(\n address indexed account,\n RepMark indexed repMark,\n uint256 bidId\n );\n\n /**\n * @notice Initializes the proxy.\n */\n function initialize(address _tellerV2) external initializer {\n tellerV2 = ITellerV2(_tellerV2);\n }\n\n function getDelinquentLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _delinquencies[_account].values();\n }\n\n function getDefaultedLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _defaults[_account].values();\n }\n\n function getCurrentDelinquentLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _currentDelinquencies[_account].values();\n }\n\n function getCurrentDefaultLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _currentDefaults[_account].values();\n }\n\n function updateAccountReputation(address _account) public override {\n uint256[] memory activeBidIds = tellerV2.getBorrowerActiveLoanIds(\n _account\n );\n for (uint256 i; i < activeBidIds.length; i++) {\n _applyReputation(_account, activeBidIds[i]);\n }\n }\n\n function updateAccountReputation(address _account, uint256 _bidId)\n public\n override\n returns (RepMark)\n {\n return _applyReputation(_account, _bidId);\n }\n\n function _applyReputation(address _account, uint256 _bidId)\n internal\n returns (RepMark mark_)\n {\n mark_ = RepMark.Good;\n\n if (tellerV2.isLoanDefaulted(_bidId)) {\n mark_ = RepMark.Default;\n\n // Remove delinquent status\n _removeMark(_account, _bidId, RepMark.Delinquent);\n } else if (tellerV2.isPaymentLate(_bidId)) {\n mark_ = RepMark.Delinquent;\n }\n\n // Mark status if not \"Good\"\n if (mark_ != RepMark.Good) {\n _addMark(_account, _bidId, mark_);\n }\n }\n\n function _addMark(address _account, uint256 _bidId, RepMark _mark)\n internal\n {\n if (_mark == RepMark.Delinquent) {\n _delinquencies[_account].add(_bidId);\n _currentDelinquencies[_account].add(_bidId);\n } else if (_mark == RepMark.Default) {\n _defaults[_account].add(_bidId);\n _currentDefaults[_account].add(_bidId);\n }\n\n emit MarkAdded(_account, _mark, _bidId);\n }\n\n function _removeMark(address _account, uint256 _bidId, RepMark _mark)\n internal\n {\n if (_mark == RepMark.Delinquent) {\n _currentDelinquencies[_account].remove(_bidId);\n } else if (_mark == RepMark.Default) {\n _currentDefaults[_account].remove(_bidId);\n }\n\n emit MarkRemoved(_account, _mark, _bidId);\n }\n}\n" - }, - "contracts/mock/WethMock.sol": { - "content": "/**\n *Submitted for verification at Etherscan.io on 2017-12-12\n */\n\n// Copyright (C) 2015, 2016, 2017 Dapphub\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\ncontract WethMock {\n string public name = \"Wrapped Ether\";\n string public symbol = \"WETH\";\n uint8 public decimals = 18;\n\n event Approval(address indexed src, address indexed guy, uint256 wad);\n event Transfer(address indexed src, address indexed dst, uint256 wad);\n event Deposit(address indexed dst, uint256 wad);\n event Withdrawal(address indexed src, uint256 wad);\n\n mapping(address => uint256) public balanceOf;\n mapping(address => mapping(address => uint256)) public allowance;\n\n function deposit() public payable {\n balanceOf[msg.sender] += msg.value;\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 wad) public {\n require(balanceOf[msg.sender] >= wad);\n balanceOf[msg.sender] -= wad;\n payable(msg.sender).transfer(wad);\n emit Withdrawal(msg.sender, wad);\n }\n\n function totalSupply() public view returns (uint256) {\n return address(this).balance;\n }\n\n function approve(address guy, uint256 wad) public returns (bool) {\n allowance[msg.sender][guy] = wad;\n emit Approval(msg.sender, guy, wad);\n return true;\n }\n\n function transfer(address dst, uint256 wad) public returns (bool) {\n return transferFrom(msg.sender, dst, wad);\n }\n\n function transferFrom(address src, address dst, uint256 wad)\n public\n returns (bool)\n {\n require(balanceOf[src] >= wad, \"insufficient balance\");\n\n if (src != msg.sender) {\n require(\n allowance[src][msg.sender] >= wad,\n \"insufficient allowance\"\n );\n allowance[src][msg.sender] -= wad;\n }\n\n balanceOf[src] -= wad;\n balanceOf[dst] += wad;\n\n emit Transfer(src, dst, wad);\n\n return true;\n }\n}\n" - }, - "contracts/interfaces/IWETH.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @notice It is the interface of functions that we use for the canonical WETH contract.\n *\n * @author develop@teller.finance\n */\ninterface IWETH {\n /**\n * @notice It withdraws ETH from the contract by sending it to the caller and reducing the caller's internal balance of WETH.\n * @param amount The amount of ETH to withdraw.\n */\n function withdraw(uint256 amount) external;\n\n /**\n * @notice It deposits ETH into the contract and increases the caller's internal balance of WETH.\n */\n function deposit() external payable;\n\n /**\n * @notice It gets the ETH deposit balance of an {account}.\n * @param account Address to get balance of.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @notice It transfers the WETH amount specified to the given {account}.\n * @param to Address to transfer to\n * @param value Amount of WETH to transfer\n */\n function transfer(address to, uint256 value) external returns (bool);\n}\n" - }, - "contracts/tests/Test_Helpers.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/ITellerV2.sol\";\nimport \"../interfaces/ITellerV2Context.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ncontract User {\n address public immutable tellerV2;\n\n constructor(address _tellerV2 /*, WethMock _wethMock*/) {\n tellerV2 = _tellerV2;\n }\n\n function addAllowance(\n address _assetContractAddress,\n address _spender,\n uint256 _amount\n ) public {\n IERC20(_assetContractAddress).approve(_spender, _amount);\n }\n\n function createMarket(\n address marketRegistry,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) public returns (uint256) {\n return\n IMarketRegistry(marketRegistry).createMarket(\n address(this),\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n _paymentCycleType,\n _uri\n );\n }\n\n function acceptBid(uint256 _bidId) public {\n ITellerV2(tellerV2).lenderAcceptBid(_bidId);\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n function submitCollateralBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver,\n _collateralInfo\n );\n }\n\n function repayLoanFull(uint256 _bidId) public {\n return ITellerV2(tellerV2).repayLoanFull(_bidId);\n }\n\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n ITellerV2Context(tellerV2).setTrustedMarketForwarder(\n _marketId,\n _forwarder\n );\n }\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n ITellerV2Context(tellerV2).approveMarketForwarder(\n _marketId,\n _forwarder\n );\n }\n\n receive() external payable {}\n}\n" - }, - "contracts/escrow/CollateralEscrowV1.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\n// Interfaces\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\";\nimport \"../interfaces/escrow/ICollateralEscrowV1.sol\";\n\ncontract CollateralEscrowV1 is OwnableUpgradeable, ICollateralEscrowV1 {\n uint256 public bidId;\n /* Mappings */\n mapping(address => Collateral) public collateralBalances; // collateral address -> collateral\n\n /* Events */\n event CollateralDeposited(address _collateralAddress, uint256 _amount);\n event CollateralWithdrawn(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n );\n\n /**\n * @notice Initializes an escrow.\n * @notice The id of the associated bid.\n */\n function initialize(uint256 _bidId) public initializer {\n __Ownable_init();\n bidId = _bidId;\n }\n\n function getBid() external view returns (uint256) {\n return bidId;\n }\n\n /**\n * @notice Deposits a collateral ERC20 token into the escrow.\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositToken(address _collateralAddress, uint256 _amount)\n external\n onlyOwner\n {\n require(_amount > 0, \"Deposit amount cannot be zero\");\n _depositCollateral(\n CollateralType.ERC20,\n _collateralAddress,\n _amount,\n 0\n );\n Collateral storage collateral = collateralBalances[_collateralAddress];\n collateral._collateralType = CollateralType.ERC20;\n collateral._amount = _amount;\n emit CollateralDeposited(_collateralAddress, _amount);\n }\n\n /**\n * @notice Deposits a collateral asset into the escrow.\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositAsset(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) external payable onlyOwner {\n require(_amount > 0, \"Deposit amount cannot be zero\");\n _depositCollateral(\n _collateralType,\n _collateralAddress,\n _amount,\n _tokenId\n );\n Collateral storage collateral = collateralBalances[_collateralAddress];\n collateral._collateralType = _collateralType;\n collateral._amount = _amount;\n collateral._tokenId = _tokenId;\n emit CollateralDeposited(_collateralAddress, _amount);\n }\n\n /**\n * @notice Withdraws a collateral asset from the escrow.\n * @param _collateralAddress The address of the collateral contract.\n * @param _amount The amount to withdraw.\n * @param _recipient The address to send the assets to.\n */\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) external onlyOwner {\n require(_amount > 0, \"Withdraw amount cannot be zero\");\n Collateral storage collateral = collateralBalances[_collateralAddress];\n require(\n collateral._amount >= _amount,\n \"No collateral balance for asset\"\n );\n _withdrawCollateral(\n collateral,\n _collateralAddress,\n _amount,\n _recipient\n );\n collateral._amount -= _amount;\n emit CollateralWithdrawn(_collateralAddress, _amount, _recipient);\n }\n\n function _depositCollateral(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) internal {\n // Deposit ERC20\n if (_collateralType == CollateralType.ERC20) {\n SafeERC20Upgradeable.safeTransferFrom(\n IERC20Upgradeable(_collateralAddress),\n _msgSender(),\n address(this),\n _amount\n );\n }\n // Deposit ERC721\n else if (_collateralType == CollateralType.ERC721) {\n require(_amount == 1, \"Incorrect deposit amount\");\n IERC721Upgradeable(_collateralAddress).transferFrom(\n _msgSender(),\n address(this),\n _tokenId\n );\n }\n // Deposit ERC1155\n else if (_collateralType == CollateralType.ERC1155) {\n bytes memory data;\n\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\n _msgSender(),\n address(this),\n _tokenId,\n _amount,\n data\n );\n }\n }\n\n function _withdrawCollateral(\n Collateral memory _collateral,\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) internal {\n // Withdraw ERC20\n if (_collateral._collateralType == CollateralType.ERC20) {\n IERC20Upgradeable(_collateralAddress).transfer(\n _recipient,\n _collateral._amount\n );\n }\n // Withdraw ERC721\n else if (_collateral._collateralType == CollateralType.ERC721) {\n require(_amount == 1, \"Incorrect withdrawal amount\");\n IERC721Upgradeable(_collateralAddress).transferFrom(\n address(this),\n _recipient,\n _collateral._tokenId\n );\n }\n // Withdraw ERC1155\n else if (_collateral._collateralType == CollateralType.ERC1155) {\n bytes memory data;\n\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\n address(this),\n _recipient,\n _collateral._tokenId,\n _amount,\n data\n );\n }\n }\n\n // On NFT Received handlers\n\n function onERC721Received(address, address, uint256, bytes calldata)\n external\n pure\n returns (bytes4)\n {\n return\n bytes4(\n keccak256(\"onERC721Received(address,address,uint256,bytes)\")\n );\n }\n\n function onERC1155Received(\n address,\n address,\n uint256 id,\n uint256 value,\n bytes calldata\n ) external returns (bytes4) {\n return\n bytes4(\n keccak256(\n \"onERC1155Received(address,address,uint256,uint256,bytes)\"\n )\n );\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata _ids,\n uint256[] calldata _values,\n bytes calldata\n ) external returns (bytes4) {\n require(\n _ids.length == 1,\n \"Only allowed one asset batch transfer per transaction.\"\n );\n return\n bytes4(\n keccak256(\n \"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"\n )\n );\n }\n}\n" - }, - "contracts/LenderCommitmentForwarder.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./TellerV2MarketForwarder.sol\";\n\n// Interfaces\nimport \"./interfaces/ICollateralManager.sol\";\nimport { Collateral, CollateralType } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n// Libraries\nimport { MathUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\ncontract LenderCommitmentForwarder is TellerV2MarketForwarder {\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n\n enum CommitmentCollateralType {\n NONE, // no collateral required\n ERC20,\n ERC721,\n ERC1155,\n ERC721_ANY_ID,\n ERC1155_ANY_ID\n }\n\n /**\n * @notice Details about a lender's capital commitment.\n * @param maxPrincipal Amount of tokens being committed by the lender. Max amount that can be loaned.\n * @param expiration Expiration time in seconds, when the commitment expires.\n * @param maxDuration Length of time, in seconds that the lender's capital can be lent out for.\n * @param minInterestRate Minimum Annual percentage to be applied for loans using the lender's capital.\n * @param collateralTokenAddress The address for the token contract that must be used to provide collateral for loans for this commitment.\n * @param maxPrincipalPerCollateralAmount The amount of principal that can be used for a loan per each unit of collateral, expanded additionally by principal decimals.\n * @param collateralTokenType The type of asset of the collateralTokenAddress (ERC20, ERC721, or ERC1155).\n * @param lender The address of the lender for this commitment.\n * @param marketId The market id for this commitment.\n * @param principalTokenAddress The address for the token contract that will be used to provide principal for loans of this commitment.\n */\n struct Commitment {\n uint256 maxPrincipal;\n uint32 expiration;\n uint32 maxDuration;\n uint16 minInterestRate;\n address collateralTokenAddress;\n uint256 collateralTokenId;\n uint256 maxPrincipalPerCollateralAmount;\n CommitmentCollateralType collateralTokenType;\n address lender;\n uint256 marketId;\n address principalTokenAddress;\n }\n\n // CommitmentId => commitment\n mapping(uint256 => Commitment) public commitments;\n\n uint256 commitmentCount;\n\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet)\n internal commitmentBorrowersList;\n\n /**\n * @notice This event is emitted when a lender's commitment is created.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event CreatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when a lender's commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event UpdatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when the allowed borrowers for a commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n */\n event UpdatedCommitmentBorrowers(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment has been deleted.\n * @param commitmentId The id of the commitment that was deleted.\n */\n event DeletedCommitment(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment is exercised for a loan.\n * @param commitmentId The id of the commitment that was exercised.\n * @param borrower The address of the borrower.\n * @param tokenAmount The amount of the asset being committed.\n * @param bidId The bid id for the loan from TellerV2.\n */\n event ExercisedCommitment(\n uint256 indexed commitmentId,\n address borrower,\n uint256 tokenAmount,\n uint256 bidId\n );\n\n error InsufficientCommitmentAllocation(\n uint256 allocated,\n uint256 requested\n );\n error InsufficientBorrowerCollateral(uint256 required, uint256 actual);\n\n /** Modifiers **/\n\n modifier commitmentLender(uint256 _commitmentId) {\n require(\n commitments[_commitmentId].lender == _msgSender(),\n \"unauthorized commitment lender\"\n );\n _;\n }\n\n function validateCommitment(Commitment storage _commitment) internal {\n require(\n _commitment.expiration > uint32(block.timestamp),\n \"expired commitment\"\n );\n require(\n _commitment.maxPrincipal > 0,\n \"commitment principal allocation 0\"\n );\n\n if (_commitment.collateralTokenType != CommitmentCollateralType.NONE) {\n require(\n _commitment.maxPrincipalPerCollateralAmount > 0,\n \"commitment collateral ratio 0\"\n );\n\n if (\n _commitment.collateralTokenType ==\n CommitmentCollateralType.ERC20\n ) {\n require(\n _commitment.collateralTokenId == 0,\n \"commitment collateral token id must be 0 for ERC20\"\n );\n }\n }\n }\n\n /** External Functions **/\n\n constructor(address _protocolAddress, address _marketRegistry)\n TellerV2MarketForwarder(_protocolAddress, _marketRegistry)\n {}\n\n /**\n * @notice Creates a loan commitment from a lender for a market.\n * @param _commitment The new commitment data expressed as a struct\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\n * @return commitmentId_ returns the commitmentId for the created commitment\n */\n function createCommitment(\n Commitment calldata _commitment,\n address[] calldata _borrowerAddressList\n ) public returns (uint256 commitmentId_) {\n commitmentId_ = commitmentCount++;\n\n require(\n _commitment.lender == _msgSender(),\n \"unauthorized commitment creator\"\n );\n\n commitments[commitmentId_] = _commitment;\n\n validateCommitment(commitments[commitmentId_]);\n\n _addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList);\n\n emit CreatedCommitment(\n commitmentId_,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n /**\n * @notice Updates the commitment of a lender to a market.\n * @param _commitmentId The Id of the commitment to update.\n * @param _commitment The new commitment data expressed as a struct\n */\n function updateCommitment(\n uint256 _commitmentId,\n Commitment calldata _commitment\n ) public commitmentLender(_commitmentId) {\n require(\n _commitment.principalTokenAddress ==\n commitments[_commitmentId].principalTokenAddress,\n \"Principal token address cannot be updated.\"\n );\n require(\n _commitment.marketId == commitments[_commitmentId].marketId,\n \"Market Id cannot be updated.\"\n );\n\n commitments[_commitmentId] = _commitment;\n\n validateCommitment(commitments[_commitmentId]);\n\n emit UpdatedCommitment(\n _commitmentId,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n /**\n * @notice Updates the borrowers allowed to accept a commitment\n * @param _commitmentId The Id of the commitment to update.\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\n */\n function updateCommitmentBorrowers(\n uint256 _commitmentId,\n address[] calldata _borrowerAddressList\n ) public commitmentLender(_commitmentId) {\n delete commitmentBorrowersList[_commitmentId];\n _addBorrowersToCommitmentAllowlist(_commitmentId, _borrowerAddressList);\n }\n\n /**\n * @notice Adds a borrower to the allowlist for a commmitment.\n * @param _commitmentId The id of the commitment that will allow the new borrower\n * @param _borrowerArray the address array of the borrowers that will be allowed to accept loans using the commitment\n */\n function _addBorrowersToCommitmentAllowlist(\n uint256 _commitmentId,\n address[] calldata _borrowerArray\n ) internal {\n for (uint256 i = 0; i < _borrowerArray.length; i++) {\n commitmentBorrowersList[_commitmentId].add(_borrowerArray[i]);\n }\n emit UpdatedCommitmentBorrowers(_commitmentId);\n }\n\n /**\n * @notice Removes the commitment of a lender to a market.\n * @param _commitmentId The id of the commitment to delete.\n */\n function deleteCommitment(uint256 _commitmentId)\n public\n commitmentLender(_commitmentId)\n {\n delete commitments[_commitmentId];\n delete commitmentBorrowersList[_commitmentId];\n emit DeletedCommitment(_commitmentId);\n }\n\n /**\n * @notice Reduces the commitment amount for a lender to a market.\n * @param _commitmentId The id of the commitment to modify.\n * @param _tokenAmountDelta The amount of change in the maxPrincipal.\n */\n function _decrementCommitment(\n uint256 _commitmentId,\n uint256 _tokenAmountDelta\n ) internal {\n commitments[_commitmentId].maxPrincipal -= _tokenAmountDelta;\n }\n\n /**\n * @notice Accept the commitment to submitBid and acceptBid using the funds\n * @dev LoanDuration must be longer than the market payment cycle\n * @param _commitmentId The id of the commitment being accepted.\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId of collateral to use for the loan if ERC721 or ERC1155.\n * @param _collateralTokenAddress The contract address to use for the loan collateral token.s\n * @param _interestRate The interest rate APY to use for the loan in basis points.\n * @param _loanDuration The overall duratiion for the loan. Must be longer than market payment cycle duration.\n * @return bidId The ID of the loan that was created on TellerV2\n */\n function acceptCommitment(\n uint256 _commitmentId,\n uint256 _principalAmount,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n address _collateralTokenAddress,\n uint16 _interestRate,\n uint32 _loanDuration\n ) external returns (uint256 bidId) {\n address borrower = _msgSender();\n\n Commitment storage commitment = commitments[_commitmentId];\n\n validateCommitment(commitment);\n\n require(\n _collateralTokenAddress == commitment.collateralTokenAddress,\n \"Mismatching collateral token\"\n );\n require(\n _interestRate >= commitment.minInterestRate,\n \"Invalid interest rate\"\n );\n require(\n _loanDuration <= commitment.maxDuration,\n \"Invalid loan max duration\"\n );\n\n require(\n commitmentBorrowersList[_commitmentId].length() == 0 ||\n commitmentBorrowersList[_commitmentId].contains(borrower),\n \"unauthorized commitment borrower\"\n );\n\n if (_principalAmount > commitment.maxPrincipal) {\n revert InsufficientCommitmentAllocation({\n allocated: commitment.maxPrincipal,\n requested: _principalAmount\n });\n }\n\n uint256 requiredCollateral = getRequiredCollateral(\n _principalAmount,\n commitment.maxPrincipalPerCollateralAmount,\n commitment.collateralTokenType,\n commitment.collateralTokenAddress,\n commitment.principalTokenAddress\n );\n if (_collateralAmount < requiredCollateral) {\n revert InsufficientBorrowerCollateral({\n required: requiredCollateral,\n actual: _collateralAmount\n });\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType ==\n CommitmentCollateralType.ERC721_ANY_ID\n ) {\n require(\n _collateralAmount == 1,\n \"invalid commitment collateral amount for ERC721\"\n );\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType == CommitmentCollateralType.ERC1155\n ) {\n require(\n commitment.collateralTokenId == _collateralTokenId,\n \"invalid commitment collateral tokenId\"\n );\n }\n\n bidId = _submitBidFromCommitment(\n borrower,\n commitment.marketId,\n commitment.principalTokenAddress,\n _principalAmount,\n commitment.collateralTokenAddress,\n _collateralAmount,\n _collateralTokenId,\n commitment.collateralTokenType,\n _loanDuration,\n _interestRate\n );\n\n _acceptBid(bidId, commitment.lender);\n\n _decrementCommitment(_commitmentId, _principalAmount);\n\n emit ExercisedCommitment(\n _commitmentId,\n borrower,\n _principalAmount,\n bidId\n );\n }\n\n /**\n * @notice Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _maxPrincipalPerCollateralAmount The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\n * @param _collateralTokenType The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\n * @param _collateralTokenAddress The contract address for the collateral for the loan.\n * @param _principalTokenAddress The contract address for the principal for the loan.\n */\n function getRequiredCollateral(\n uint256 _principalAmount,\n uint256 _maxPrincipalPerCollateralAmount,\n CommitmentCollateralType _collateralTokenType,\n address _collateralTokenAddress,\n address _principalTokenAddress\n ) public view virtual returns (uint256) {\n if (_collateralTokenType == CommitmentCollateralType.NONE) {\n return 0;\n }\n\n uint8 collateralDecimals;\n uint8 principalDecimals = IERC20MetadataUpgradeable(\n _principalTokenAddress\n ).decimals();\n\n if (_collateralTokenType == CommitmentCollateralType.ERC20) {\n collateralDecimals = IERC20MetadataUpgradeable(\n _collateralTokenAddress\n ).decimals();\n }\n\n /*\n * The principalAmount is expanded by (collateralDecimals+principalDecimals) to increase precision\n * and then it is divided by _maxPrincipalPerCollateralAmount which should already been expanded by principalDecimals\n */\n return\n MathUpgradeable.mulDiv(\n _principalAmount,\n (10**(collateralDecimals + principalDecimals)),\n _maxPrincipalPerCollateralAmount,\n MathUpgradeable.Rounding.Up\n );\n }\n\n /**\n * @notice Return the array of borrowers that are allowlisted for a commitment\n * @param _commitmentId The commitment id for the commitment to query.\n * @return borrowers_ An array of addresses restricted to accept the commitment. Empty array means unrestricted.\n */\n function getCommitmentBorrowers(uint256 _commitmentId)\n external\n view\n returns (address[] memory borrowers_)\n {\n borrowers_ = commitmentBorrowersList[_commitmentId].values();\n }\n\n /**\n * @notice Internal function to submit a bid to the lending protocol using a commitment\n * @param _borrower The address of the borrower for the loan.\n * @param _marketId The id for the market of the loan in the lending protocol.\n * @param _principalTokenAddress The contract address for the principal token.\n * @param _principalAmount The amount of principal to borrow for the loan.\n * @param _collateralTokenAddress The contract address for the collateral token.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId for the collateral (if it is ERC721 or ERC1155).\n * @param _collateralTokenType The type of collateral token (ERC20,ERC721,ERC1177,None).\n * @param _loanDuration The duration of the loan in seconds delta. Must be longer than loan payment cycle for the market.\n * @param _interestRate The amount of interest APY for the loan expressed in basis points.\n */\n function _submitBidFromCommitment(\n address _borrower,\n uint256 _marketId,\n address _principalTokenAddress,\n uint256 _principalAmount,\n address _collateralTokenAddress,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n CommitmentCollateralType _collateralTokenType,\n uint32 _loanDuration,\n uint16 _interestRate\n ) internal returns (uint256 bidId) {\n CreateLoanArgs memory createLoanArgs;\n createLoanArgs.marketId = _marketId;\n createLoanArgs.lendingToken = _principalTokenAddress;\n createLoanArgs.principal = _principalAmount;\n createLoanArgs.duration = _loanDuration;\n createLoanArgs.interestRate = _interestRate;\n\n Collateral[] memory collateralInfo;\n if (_collateralTokenType != CommitmentCollateralType.NONE) {\n collateralInfo = new Collateral[](1);\n collateralInfo[0] = Collateral({\n _collateralType: _getEscrowCollateralType(_collateralTokenType),\n _tokenId: _collateralTokenId,\n _amount: _collateralAmount,\n _collateralAddress: _collateralTokenAddress\n });\n }\n\n bidId = _submitBidWithCollateral(\n createLoanArgs,\n collateralInfo,\n _borrower\n );\n }\n\n /**\n * @notice Return the collateral type based on the commitmentcollateral type. Collateral type is used in the base lending protocol.\n * @param _type The type of collateral to be used for the loan.\n */\n function _getEscrowCollateralType(CommitmentCollateralType _type)\n internal\n pure\n returns (CollateralType)\n {\n if (_type == CommitmentCollateralType.ERC20) {\n return CollateralType.ERC20;\n }\n if (\n _type == CommitmentCollateralType.ERC721 ||\n _type == CommitmentCollateralType.ERC721_ANY_ID\n ) {\n return CollateralType.ERC721;\n }\n if (\n _type == CommitmentCollateralType.ERC1155 ||\n _type == CommitmentCollateralType.ERC1155_ANY_ID\n ) {\n return CollateralType.ERC1155;\n }\n\n revert(\"Unknown Collateral Type\");\n }\n}\n" - }, - "contracts/tests/resolvers/TestERC20Token.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract TestERC20Token is ERC20 {\n uint8 private immutable DECIMALS;\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint256 _totalSupply,\n uint8 _decimals\n ) ERC20(_name, _symbol) {\n DECIMALS = _decimals;\n _mint(msg.sender, _totalSupply);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return DECIMALS;\n }\n}\n" - }, - "contracts/MetaForwarder.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol\";\n\ncontract MetaForwarder is MinimalForwarderUpgradeable {\n function initialize() external initializer {\n __EIP712_init_unchained(\"TellerMetaForwarder\", \"0.0.1\");\n }\n}\n" - }, - "contracts/LenderManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/ILenderManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/IMarketRegistry.sol\";\n\ncontract LenderManager is\n Initializable,\n OwnableUpgradeable,\n ERC721Upgradeable,\n ILenderManager\n{\n IMarketRegistry public immutable marketRegistry;\n\n constructor(IMarketRegistry _marketRegistry) {\n marketRegistry = _marketRegistry;\n }\n\n function initialize() external initializer {\n __LenderManager_init();\n }\n\n function __LenderManager_init() internal onlyInitializing {\n __Ownable_init();\n __ERC721_init(\"TellerLoan\", \"TLN\");\n }\n\n /**\n * @notice Registers a new active lender for a loan, minting the nft\n * @param _bidId The id for the loan to set.\n * @param _newLender The address of the new active lender.\n */\n function registerLoan(uint256 _bidId, address _newLender)\n public\n override\n onlyOwner\n {\n _mint(_newLender, _bidId);\n }\n\n /**\n * @notice Returns the address of the lender that owns a given loan/bid.\n * @param _bidId The id of the bid of which to return the market id\n */\n function _getLoanMarketId(uint256 _bidId) internal view returns (uint256) {\n return ITellerV2(owner()).getLoanMarketId(_bidId);\n }\n\n /**\n * @notice Returns the verification status of a lender for a market.\n * @param _lender The address of the lender which should be verified by the market\n * @param _bidId The id of the bid of which to return the market id\n */\n function _hasMarketVerification(address _lender, uint256 _bidId)\n internal\n view\n virtual\n returns (bool isVerified_)\n {\n uint256 _marketId = _getLoanMarketId(_bidId);\n\n (isVerified_, ) = marketRegistry.isVerifiedLender(_marketId, _lender);\n }\n\n /** ERC721 Functions **/\n\n function _beforeTokenTransfer(address, address to, uint256 tokenId, uint256)\n internal\n override\n {\n require(_hasMarketVerification(to, tokenId), \"Not approved by market\");\n }\n\n function _baseURI() internal view override returns (string memory) {\n return \"\";\n }\n}\n" - }, - "@mangrovedao/hardhat-test-solidity/test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0;\n\n// Should be kept in sync with ./lib.js\n\nlibrary Test {\n /* \n * Expect events from contracts\n */\n event ExpectFrom(address from);\n event StopExpecting();\n\n // Usage: from a test contract `t`, call `expectFrom(a)`. \n // Any subsequent non-special event emitted by `t` will mean \n // \"I expect `a` to emit the exact same event\". \n // The order of expectations must be respected.\n function expectFrom(address from) internal {\n emit ExpectFrom(from);\n }\n\n // After using `expectFrom` and emitting some events you expect\n // to see emitted elsewhere, you can use `stopExpecting` to emit \n // further, normal events from your test.\n function stopExpecting() internal {\n emit StopExpecting();\n }\n\n\n /* \n * Boolean test\n */\n event TestTrue(bool success, string message);\n\n // Succeed iff success is true\n function check(bool success, string memory message) internal {\n emit TestTrue(success, message);\n }\n\n\n /* \n * Always fail, always succeed\n */\n function fail(string memory message) internal {\n emit TestTrue(false, message);\n }\n\n function succeed() internal {\n emit TestTrue(true, \"Success\");\n }\n\n /* \n * Equality testing\n * ! overloaded as `eq` for everything except for bytes use `eq0`.\n */\n\n // Bytes\n event TestEqBytes(bool success, bytes actual, bytes expected, string message);\n\n function eq0(\n bytes memory actual,\n bytes memory expected,\n string memory message\n ) internal returns (bool) {\n bool success = keccak256((actual)) == keccak256((expected));\n emit TestEqBytes(success, actual, expected, message);\n return success;\n }\n\n // Byte32\n event TestEqBytes32(\n bool success,\n bytes32 actual,\n bytes32 expected,\n string message\n );\n\n function eq(\n bytes32 actual,\n bytes32 expected,\n string memory message\n ) internal returns (bool) {\n bool success = (actual == expected);\n emit TestEqBytes32(success, actual, expected, message);\n return success;\n }\n\n // Bool\n event TestEqBool(bool success, bool actual, bool expected, string message);\n function eq(\n bool actual,\n bool expected,\n string memory message\n ) internal returns (bool) {\n bool success = (actual == expected);\n emit TestEqBool(success, actual, expected, message);\n return success;\n }\n\n // uints\n event TestEqUint(bool success, uint actual, uint expected, string message);\n\n function eq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual == expected;\n emit TestEqUint(success, actual, expected, message);\n return success;\n }\n\n // strings\n event TestEqString(\n bool success,\n string actual,\n string expected,\n string message\n );\n\n function eq(\n string memory actual,\n string memory expected,\n string memory message\n ) internal returns (bool) {\n bool success = keccak256(bytes((actual))) == keccak256(bytes((expected)));\n emit TestEqString(success, actual, expected, message);\n return success;\n }\n\n // addresses\n event TestEqAddress(\n bool success,\n address actual,\n address expected,\n string message\n );\n\n\n function eq(\n address actual,\n address expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual == expected;\n emit TestEqAddress(success, actual, expected, message);\n return success;\n }\n\n /* \n * Inequality testing\n */\n event TestLess(bool success, uint actual, uint expected, string message);\n function less(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual < expected;\n emit TestLess(success, actual, expected, message);\n return success;\n }\n\n event TestLessEq(bool success, uint actual, uint expected, string message);\n function lessEq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual <= expected;\n emit TestLessEq(success, actual, expected, message);\n return success;\n }\n\n event TestMore(bool success, uint actual, uint expected, string message);\n function more(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual > expected;\n emit TestMore(success, actual, expected, message);\n return success;\n }\n\n event TestMoreEq(bool success, uint actual, uint expected, string message);\n function moreEq(\n uint actual,\n uint expected,\n string memory message\n ) internal returns (bool) {\n bool success = actual >= expected;\n emit TestMoreEq(success, actual, expected, message);\n return success;\n }\n}\n\n// /* Either cast your arguments to address when you call balanceOf logging functions\n// or add `is address` to your ERC20s\n// or use the overloads with `address` types */\ninterface ERC20BalanceOf {\n function balanceOf(address account) view external returns (uint);\n}\n\n\nlibrary Display {\n /* ****************************************************************\n * Register/read address->name mappings to make logs easier to read.\n *****************************************************************/\n /* \n * Names are stored in the contract using the library.\n */\n\n // Disgusting hack so a library can manipulate storage refs.\n bytes32 constant NAMES_POS = keccak256(\"Display.NAMES_POS\");\n // Store mapping in library caller's storage.\n // That's quite fragile.\n struct Registers {\n mapping(address => string) map;\n }\n\n // Also send mapping to javascript test interpreter. The interpreter COULD\n // just make an EVM call to map every name but that would probably be very\n // slow. So we cache locally.\n event Register(address addr, string name);\n\n function registers() internal view returns (Registers storage) {\n this; // silence warning about pure mutability\n Registers storage regs;\n bytes32 _slot = NAMES_POS;\n assembly {\n regs.slot := _slot\n }\n return regs;\n }\n\n /*\n * Give a name to an address for logging purposes\n * @example\n * ```solidity\n * address addr = address(new Contract());\n * register(addr,\"My Contract instance\");\n * ```\n */\n\n function register(address addr, string memory name) internal {\n registers().map[addr] = name;\n emit Register(addr, name);\n }\n\n /*\n * Read the name of a registered address. Default: \"\". \n */\n function nameOf(address addr) internal view returns (string memory) {\n string memory s = registers().map[addr];\n if (keccak256(bytes(s)) != keccak256(bytes(\"\"))) {\n return s;\n } else {\n return \"\";\n }\n }\n\n /* 1 arg logging (string/uint) */\n\n event LogString(string a);\n\n function log(string memory a) internal {\n emit LogString(a);\n }\n\n event LogUint(uint a);\n\n function log(uint a) internal {\n emit LogUint(a);\n }\n\n /* 2 arg logging (string/uint) */\n\n event LogStringString(string a, string b);\n\n function log(string memory a, string memory b) internal {\n emit LogStringString(a, b);\n }\n\n event LogStringUint(string a, uint b);\n\n function log(string memory a, uint b) internal {\n emit LogStringUint(a, b);\n }\n\n event LogUintUint(uint a, uint b);\n\n function log(uint a, uint b) internal {\n emit LogUintUint(a, b);\n }\n\n event LogUintString(uint a, string b);\n\n function log(uint a, string memory b) internal {\n emit LogUintString(a, b);\n }\n\n /* 3 arg logging (string/uint) */\n\n event LogStringStringString(string a, string b, string c);\n\n function log(\n string memory a,\n string memory b,\n string memory c\n ) internal {\n emit LogStringStringString(a, b, c);\n }\n\n event LogStringStringUint(string a, string b, uint c);\n\n function log(\n string memory a,\n string memory b,\n uint c\n ) internal {\n emit LogStringStringUint(a, b, c);\n }\n\n event LogStringUintUint(string a, uint b, uint c);\n\n function log(\n string memory a,\n uint b,\n uint c\n ) internal {\n emit LogStringUintUint(a, b, c);\n }\n\n event LogStringUintString(string a, uint b, string c);\n\n function log(\n string memory a,\n uint b,\n string memory c\n ) internal {\n emit LogStringUintString(a, b, c);\n }\n\n event LogUintUintUint(uint a, uint b, uint c);\n\n function log(\n uint a,\n uint b,\n uint c\n ) internal {\n emit LogUintUintUint(a, b, c);\n }\n\n event LogUintStringUint(uint a, string b, uint c);\n\n function log(\n uint a,\n string memory b,\n uint c\n ) internal {\n emit LogUintStringUint(a, b, c);\n }\n\n event LogUintStringString(uint a, string b, string c);\n\n function log(\n uint a,\n string memory b,\n string memory c\n ) internal {\n emit LogUintStringString(a, b, c);\n }\n\n /* End of register/read section */\n event ERC20Balances(address[] tokens, address[] accounts, uint[] balances);\n\n function logBalances(\n address[1] memory _tokens, \n address _a0\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](1);\n accounts[0] = _a0;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[1] memory _tokens,\n address _a0,\n address _a1\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](2);\n accounts[0] = _a0;\n accounts[1] = _a1;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[1] memory _tokens,\n address _a0,\n address _a1,\n address _a2\n ) internal {\n address[] memory tokens = new address[](1);\n tokens[0] = _tokens[0];\n address[] memory accounts = new address[](3);\n accounts[0] = _a0;\n accounts[1] = _a1;\n accounts[2] = _a2;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](1);\n accounts[0] = _a0;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0,\n address _a1\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](2);\n accounts[0] = _a0;\n accounts[1] = _a1;\n logBalances(tokens, accounts);\n }\n\n function logBalances(\n address[2] memory _tokens,\n address _a0,\n address _a1,\n address _a2\n ) internal {\n address[] memory tokens = new address[](2);\n tokens[0] = _tokens[0];\n tokens[1] = _tokens[1];\n address[] memory accounts = new address[](3);\n accounts[0] = _a0;\n accounts[1] = _a1;\n accounts[2] = _a2;\n logBalances(tokens, accounts);\n }\n\n /* takes [t1,...,tM], [a1,...,aN]\n logs also [...b(t1,aj) ... b(tM,aj) ...] */\n\n function logBalances(address[] memory tokens, address[] memory accounts)\n internal\n {\n uint[] memory balances = new uint[](tokens.length * accounts.length);\n for (uint i = 0; i < tokens.length; i++) {\n for (uint j = 0; j < accounts.length; j++) {\n uint bal = ERC20BalanceOf(tokens[i]).balanceOf(accounts[j]);\n balances[i * accounts.length + j] = bal;\n //console.log(tokens[i].symbol(),nameOf(accounts[j]),bal);\n }\n }\n emit ERC20Balances(tokens, accounts, balances);\n }\n\n}" - }, - "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n address private _implementation;\n\n /**\n * @dev Emitted when the implementation returned by the beacon is changed.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n * beacon.\n */\n constructor(address implementation_) {\n _setImplementation(implementation_);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view virtual override returns (address) {\n return _implementation;\n }\n\n /**\n * @dev Upgrades the beacon to a new implementation.\n *\n * Emits an {Upgraded} event.\n *\n * Requirements:\n *\n * - msg.sender must be the owner of the contract.\n * - `newImplementation` must be a contract.\n */\n function upgradeTo(address newImplementation) public virtual onlyOwner {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Sets the implementation contract address for this beacon\n *\n * Requirements:\n *\n * - `newImplementation` must be a contract.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n _implementation = newImplementation;\n }\n}\n" - }, - "contracts/ProtocolFee.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract ProtocolFee is OwnableUpgradeable {\n // Protocol fee set for loan processing.\n uint16 private _protocolFee;\n\n /**\n * @notice This event is emitted when the protocol fee has been updated.\n * @param newFee The new protocol fee set.\n * @param oldFee The previously set protocol fee.\n */\n event ProtocolFeeSet(uint16 newFee, uint16 oldFee);\n\n /**\n * @notice Initialized the protocol fee.\n * @param initFee The initial protocol fee to be set on the protocol.\n */\n function __ProtocolFee_init(uint16 initFee) internal onlyInitializing {\n __Ownable_init();\n __ProtocolFee_init_unchained(initFee);\n }\n\n function __ProtocolFee_init_unchained(uint16 initFee)\n internal\n onlyInitializing\n {\n setProtocolFee(initFee);\n }\n\n /**\n * @notice Returns the current protocol fee.\n */\n function protocolFee() public view virtual returns (uint16) {\n return _protocolFee;\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol to set a new protocol fee.\n * @param newFee The new protocol fee to be set.\n */\n function setProtocolFee(uint16 newFee) public virtual onlyOwner {\n // Skip if the fee is the same\n if (newFee == _protocolFee) return;\n\n uint16 oldFee = _protocolFee;\n _protocolFee = newFee;\n emit ProtocolFeeSet(newFee, oldFee);\n }\n}\n" - }, - "contracts/TellerV2Context.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2Storage.sol\";\nimport \"./ERC2771ContextUpgradeable.sol\";\n\n/**\n * @dev This contract should not use any storage\n */\n\nabstract contract TellerV2Context is\n ERC2771ContextUpgradeable,\n TellerV2Storage\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n event TrustedMarketForwarderSet(\n uint256 indexed marketId,\n address forwarder,\n address sender\n );\n event MarketForwarderApproved(\n uint256 indexed marketId,\n address indexed forwarder,\n address sender\n );\n\n constructor(address trustedForwarder)\n ERC2771ContextUpgradeable(trustedForwarder)\n {}\n\n /**\n * @notice Checks if an address is a trusted forwarder contract for a given market.\n * @param _marketId An ID for a lending market.\n * @param _trustedMarketForwarder An address to check if is a trusted forwarder in the given market.\n * @return A boolean indicating the forwarder address is trusted in a market.\n */\n function isTrustedMarketForwarder(\n uint256 _marketId,\n address _trustedMarketForwarder\n ) public view returns (bool) {\n return\n _trustedMarketForwarders[_marketId] == _trustedMarketForwarder ||\n lenderCommitmentForwarder == _trustedMarketForwarder;\n }\n\n /**\n * @notice Checks if an account has approved a forwarder for a market.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n * @param _account The address to verify set an approval.\n * @return A boolean indicating if an approval was set.\n */\n function hasApprovedMarketForwarder(\n uint256 _marketId,\n address _forwarder,\n address _account\n ) public view returns (bool) {\n return\n isTrustedMarketForwarder(_marketId, _forwarder) &&\n _approvedForwarderSenders[_forwarder].contains(_account);\n }\n\n /**\n * @notice Sets a trusted forwarder for a lending market.\n * @notice The caller must owner the market given. See {MarketRegistry}\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n marketRegistry.getMarketOwner(_marketId) == _msgSender(),\n \"Caller must be the market owner\"\n );\n _trustedMarketForwarders[_marketId] = _forwarder;\n emit TrustedMarketForwarderSet(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Approves a forwarder contract to use their address as a sender for a specific market.\n * @notice The forwarder given must be trusted by the market given.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n isTrustedMarketForwarder(_marketId, _forwarder),\n \"Forwarder must be trusted by the market\"\n );\n _approvedForwarderSenders[_forwarder].add(_msgSender());\n emit MarketForwarderApproved(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Retrieves the function caller address by checking the appended calldata if the _actual_ caller is a trusted forwarder.\n * @param _marketId An ID for a lending market.\n * @return sender The address to use as the function caller.\n */\n function _msgSenderForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (address)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n address sender;\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n // Ensure the appended sender address approved the forwarder\n require(\n _approvedForwarderSenders[_msgSender()].contains(sender),\n \"Sender must approve market forwarder\"\n );\n return sender;\n }\n\n return _msgSender();\n }\n\n /**\n * @notice Retrieves the actual function calldata from a trusted forwarder call.\n * @param _marketId An ID for a lending market to verify if the caller is a trusted forwarder.\n * @return calldata The modified bytes array of the function calldata without the appended sender's address.\n */\n function _msgDataForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (bytes calldata)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n return msg.data[:msg.data.length - 20];\n } else {\n return _msgData();\n }\n }\n}\n" - }, - "contracts/libraries/DateTimeLib.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint constant SECONDS_PER_DAY = 24 * 60 * 60;\n uint constant SECONDS_PER_HOUR = 60 * 60;\n uint constant SECONDS_PER_MINUTE = 60;\n int constant OFFSET19700101 = 2440588;\n\n uint constant DOW_MON = 1;\n uint constant DOW_TUE = 2;\n uint constant DOW_WED = 3;\n uint constant DOW_THU = 4;\n uint constant DOW_FRI = 5;\n uint constant DOW_SAT = 6;\n uint constant DOW_SUN = 7;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(uint year, uint month, uint day)\n internal\n pure\n returns (uint _days)\n {\n require(year >= 1970);\n int _year = int(year);\n int _month = int(month);\n int _day = int(day);\n\n int __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n OFFSET19700101;\n\n _days = uint(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint _days)\n internal\n pure\n returns (uint year, uint month, uint day)\n {\n int __days = int(_days);\n\n int L = __days + 68569 + OFFSET19700101;\n int N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int _month = (80 * L) / 2447;\n int _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint(_year);\n month = uint(_month);\n day = uint(_day);\n }\n\n function timestampFromDate(uint year, uint month, uint day)\n internal\n pure\n returns (uint timestamp)\n {\n timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n ) internal pure returns (uint timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n hour *\n SECONDS_PER_HOUR +\n minute *\n SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint timestamp)\n internal\n pure\n returns (uint year, uint month, uint day)\n {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint timestamp)\n internal\n pure\n returns (\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n )\n {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n uint secs = timestamp % SECONDS_PER_DAY;\n hour = secs / SECONDS_PER_HOUR;\n secs = secs % SECONDS_PER_HOUR;\n minute = secs / SECONDS_PER_MINUTE;\n second = secs % SECONDS_PER_MINUTE;\n }\n\n function isValidDate(uint year, uint month, uint day)\n internal\n pure\n returns (bool valid)\n {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint timestamp) internal pure returns (bool leapYear) {\n (uint year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint year) internal pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= DOW_FRI;\n }\n\n function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;\n }\n\n function getDaysInMonth(uint timestamp)\n internal\n pure\n returns (uint daysInMonth)\n {\n (uint year, uint month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint year, uint month)\n internal\n pure\n returns (uint daysInMonth)\n {\n if (\n month == 1 ||\n month == 3 ||\n month == 5 ||\n month == 7 ||\n month == 8 ||\n month == 10 ||\n month == 12\n ) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint timestamp)\n internal\n pure\n returns (uint dayOfWeek)\n {\n uint _days = timestamp / SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint timestamp) internal pure returns (uint year) {\n (year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getMonth(uint timestamp) internal pure returns (uint month) {\n (, month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getDay(uint timestamp) internal pure returns (uint day) {\n (, , day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getHour(uint timestamp) internal pure returns (uint hour) {\n uint secs = timestamp % SECONDS_PER_DAY;\n hour = secs / SECONDS_PER_HOUR;\n }\n\n function getMinute(uint timestamp) internal pure returns (uint minute) {\n uint secs = timestamp % SECONDS_PER_HOUR;\n minute = secs / SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint timestamp) internal pure returns (uint second) {\n second = timestamp % SECONDS_PER_MINUTE;\n }\n\n function addYears(uint timestamp, uint _years)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n year += _years;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint timestamp, uint _months)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint timestamp, uint _days)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _days * SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint timestamp, uint _hours)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint timestamp, uint _minutes)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint timestamp, uint _seconds)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint timestamp, uint _years)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n year -= _years;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint timestamp, uint _months)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n uint yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint timestamp, uint _days)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _days * SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint timestamp, uint _hours)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint timestamp, uint _minutes)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint timestamp, uint _seconds)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _years)\n {\n require(fromTimestamp <= toTimestamp);\n (uint fromYear, , ) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);\n (uint toYear, , ) = _daysToDate(toTimestamp / SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _months)\n {\n require(fromTimestamp <= toTimestamp);\n (uint fromYear, uint fromMonth, ) = _daysToDate(\n fromTimestamp / SECONDS_PER_DAY\n );\n (uint toYear, uint toMonth, ) = _daysToDate(\n toTimestamp / SECONDS_PER_DAY\n );\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _days)\n {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;\n }\n\n function diffHours(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _hours)\n {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _minutes)\n {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _seconds)\n {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = MathUpgradeable.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, MathUpgradeable.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "contracts/ERC2771ContextUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n * @dev This is modified from the OZ library to remove the gap of storage variables at the end.\n */\nabstract contract ERC2771ContextUpgradeable is\n Initializable,\n ContextUpgradeable\n{\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address private immutable _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder)\n public\n view\n virtual\n returns (bool)\n {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender()\n internal\n view\n virtual\n override\n returns (address sender)\n {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData()\n internal\n view\n virtual\n override\n returns (bytes calldata)\n {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "contracts/EAS/TellerASResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IASResolver.sol\";\n\n/**\n * @title A base resolver contract\n */\nabstract contract TellerASResolver is IASResolver {\n error NotPayable();\n\n function isPayable() public pure virtual override returns (bool) {\n return false;\n }\n\n receive() external payable virtual {\n if (!isPayable()) {\n revert NotPayable();\n }\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" - }, - "contracts/interfaces/ITellerV2Context.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Context {\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external;\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "contracts/TellerV2MarketForwarder.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\n\nimport \"./interfaces/IMarketRegistry.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\n\n/**\n * @dev Simple helper contract to forward an encoded function call to the TellerV2 contract. See {TellerV2Context}\n */\nabstract contract TellerV2MarketForwarder is Initializable, ContextUpgradeable {\n using AddressUpgradeable for address;\n\n address public immutable _tellerV2;\n address public immutable _marketRegistry;\n\n struct CreateLoanArgs {\n uint256 marketId;\n address lendingToken;\n uint256 principal;\n uint32 duration;\n uint16 interestRate;\n string metadataURI;\n address recipient;\n }\n\n constructor(address _protocolAddress, address _marketRegistryAddress) {\n _tellerV2 = _protocolAddress;\n _marketRegistry = _marketRegistryAddress;\n }\n\n function getTellerV2() public view returns (address) {\n return _tellerV2;\n }\n\n function getMarketRegistry() public view returns (address) {\n return _marketRegistry;\n }\n\n function getTellerV2MarketOwner(uint256 marketId) public returns (address) {\n return IMarketRegistry(getMarketRegistry()).getMarketOwner(marketId);\n }\n\n /**\n * @dev Performs function call to the TellerV2 contract by appending an address to the calldata.\n * @param _data The encoded function calldata on TellerV2.\n * @param _msgSender The address that should be treated as the underlying function caller.\n * @return The encoded response from the called function.\n *\n * Requirements:\n * - The {_msgSender} address must set an approval on TellerV2 for this forwarder contract __before__ making this call.\n */\n function _forwardCall(bytes memory _data, address _msgSender)\n internal\n returns (bytes memory)\n {\n return\n address(_tellerV2).functionCall(\n abi.encodePacked(_data, _msgSender)\n );\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBid(\n CreateLoanArgs memory _createLoanArgs,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address)\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBidWithCollateral(\n CreateLoanArgs memory _createLoanArgs,\n Collateral[] memory _collateralInfo,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient,\n _collateralInfo\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Accepts a new loan using the TellerV2 lending protocol.\n * @param _bidId The id of the new loan.\n * @param _lender The address of the lender who will provide funds for the new loan.\n */\n function _acceptBid(uint256 _bidId, address _lender)\n internal\n virtual\n returns (bool)\n {\n // Approve the borrower's loan\n _forwardCall(\n abi.encodeWithSelector(ITellerV2.lenderAcceptBid.selector, _bidId),\n _lender\n );\n\n return true;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (metatx/MinimalForwarder.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../utils/cryptography/EIP712Upgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Simple minimal forwarder to be used together with an ERC2771 compatible contract. See {ERC2771Context}.\n *\n * MinimalForwarder is mainly meant for testing, as it is missing features to be a good production-ready forwarder. This\n * contract does not intend to have all the properties that are needed for a sound forwarding system. A fully\n * functioning forwarding system with good properties requires more complexity. We suggest you look at other projects\n * such as the GSN which do have the goal of building a system like that.\n */\ncontract MinimalForwarderUpgradeable is Initializable, EIP712Upgradeable {\n using ECDSAUpgradeable for bytes32;\n\n struct ForwardRequest {\n address from;\n address to;\n uint256 value;\n uint256 gas;\n uint256 nonce;\n bytes data;\n }\n\n bytes32 private constant _TYPEHASH =\n keccak256(\"ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data)\");\n\n mapping(address => uint256) private _nonces;\n\n function __MinimalForwarder_init() internal onlyInitializing {\n __EIP712_init_unchained(\"MinimalForwarder\", \"0.0.1\");\n }\n\n function __MinimalForwarder_init_unchained() internal onlyInitializing {}\n\n function getNonce(address from) public view returns (uint256) {\n return _nonces[from];\n }\n\n function verify(ForwardRequest calldata req, bytes calldata signature) public view returns (bool) {\n address signer = _hashTypedDataV4(\n keccak256(abi.encode(_TYPEHASH, req.from, req.to, req.value, req.gas, req.nonce, keccak256(req.data)))\n ).recover(signature);\n return _nonces[req.from] == req.nonce && signer == req.from;\n }\n\n function execute(ForwardRequest calldata req, bytes calldata signature)\n public\n payable\n returns (bool, bytes memory)\n {\n require(verify(req, signature), \"MinimalForwarder: signature does not match request\");\n _nonces[req.from] = req.nonce + 1;\n\n (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}(\n abi.encodePacked(req.data, req.from)\n );\n\n // Validate that the relayer has sent enough gas for the call.\n // See https://ronan.eth.limo/blog/ethereum-gas-dangers/\n if (gasleft() <= req.gas / 63) {\n // We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since\n // neither revert or assert consume all gas since Solidity 0.8.0\n // https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require\n /// @solidity memory-safe-assembly\n assembly {\n invalid()\n }\n }\n\n return (success, returndata);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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 if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC721_init_unchained(name_, symbol_);\n }\n\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721Upgradeable.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256, /* firstTokenId */\n uint256 batchSize\n ) internal virtual {\n if (batchSize > 1) {\n if (from != address(0)) {\n _balances[from] -= batchSize;\n }\n if (to != address(0)) {\n _balances[to] += batchSize;\n }\n }\n }\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 firstTokenId,\n uint256 batchSize\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[44] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" - }, - "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Arrays.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Arrays.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./StorageSlot.sol\";\nimport \"./math/Math.sol\";\n\n/**\n * @dev Collection of functions related to array types.\n */\nlibrary Arrays {\n using StorageSlot for bytes32;\n\n /**\n * @dev Searches a sorted `array` and returns the first index that contains\n * a value greater or equal to `element`. If no such index exists (i.e. all\n * values in the array are strictly less than `element`), the array length is\n * returned. Time complexity O(log n).\n *\n * `array` is expected to be sorted in ascending order, and to contain no\n * repeated elements.\n */\n function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {\n if (array.length == 0) {\n return 0;\n }\n\n uint256 low = 0;\n uint256 high = array.length;\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n\n // Note that mid will always be strictly less than high (i.e. it will be a valid array index)\n // because Math.average rounds down (it does integer division with truncation).\n if (unsafeAccess(array, mid).value > element) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.\n if (low > 0 && unsafeAccess(array, low - 1).value == element) {\n return low - 1;\n } else {\n return low;\n }\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getAddressSlot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getBytes32Slot();\n }\n\n /**\n * @dev Access an array in an \"unsafe\" way. Skips solidity \"index-out-of-range\" check.\n *\n * WARNING: Only use if you are certain `pos` is lower than the array length.\n */\n function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {\n bytes32 slot;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0, arr.slot)\n slot := add(keccak256(0, 0x20), pos)\n }\n return slot.getUint256Slot();\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "contracts/tests/LenderManager_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\nimport \"../TellerV2MarketForwarder.sol\";\nimport { Testable } from \"./Testable.sol\";\nimport { LenderManager } from \"../LenderManager.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\n\ncontract LenderManager_Test is Testable, LenderManager {\n LenderManagerUser private marketOwner;\n LenderManagerUser private lender;\n LenderManagerUser private borrower;\n\n LenderCommitmentTester mockTellerV2;\n MarketRegistryMock mockMarketRegistry;\n\n bool mockedHasMarketVerification;\n\n constructor()\n LenderManager(\n //address(0),\n new MarketRegistryMock(address(0))\n )\n {}\n\n function setup_beforeAll() public {\n mockTellerV2 = new LenderCommitmentTester();\n\n marketOwner = new LenderManagerUser(\n address(mockTellerV2),\n address(this)\n );\n borrower = new LenderManagerUser(address(mockTellerV2), address(this));\n lender = new LenderManagerUser(address(mockTellerV2), address(this));\n\n mockMarketRegistry = new MarketRegistryMock(address(marketOwner));\n\n delete mockedHasMarketVerification;\n }\n\n function registerLoan_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n\n super.registerLoan(bidId, address(lender));\n\n Test.eq(\n super._exists(bidId),\n true,\n \"Loan registration did not mint nft\"\n );\n }\n\n function transferFrom_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n\n super._mint(address(lender), bidId);\n\n lender.transferLoan(bidId, address(borrower));\n\n Test.eq(\n super.ownerOf(bidId),\n address(borrower),\n \"Loan nft was not transferred\"\n );\n }\n\n function transferFromToInvalidRecipient_test() public {\n mockedHasMarketVerification = true;\n\n uint256 bidId = 2;\n super._mint(address(lender), bidId);\n\n mockedHasMarketVerification = false;\n\n bool transferFailed;\n\n //I want to expect this to fail !!\n try lender.transferLoan(bidId, address(address(borrower))) {} catch {\n transferFailed = true;\n }\n\n Test.eq(transferFailed, true, \"Loan transfer should have failed\");\n\n Test.eq(\n super.ownerOf(bidId),\n address(lender),\n \"Loan nft is no longer owned by lender\"\n );\n }\n\n //override\n function _hasMarketVerification(address _lender, uint256 _bidId)\n internal\n view\n override\n returns (bool)\n {\n return mockedHasMarketVerification;\n }\n\n //should be able to test the negative case-- use foundry\n function _checkOwner() internal view override {\n // do nothing\n }\n}\n\ncontract LenderManagerUser is User {\n address lenderManager;\n\n constructor(address _tellerV2, address _lenderManager) User(_tellerV2) {\n lenderManager = _lenderManager;\n }\n\n function transferLoan(uint256 bidId, address to) public {\n IERC721(lenderManager).transferFrom(address(this), to, bidId);\n }\n}\n\n//Move to a helper or change it\ncontract LenderCommitmentTester is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "contracts/mock/MarketRegistryMock.sol": { - "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport { PaymentType } from \"../libraries/V2Calculations.sol\";\n\ncontract MarketRegistryMock is IMarketRegistry {\n address marketOwner;\n\n constructor(address _marketOwner) {\n marketOwner = _marketOwner;\n }\n\n function initialize(TellerAS _tellerAS) external {}\n\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\n public\n view\n returns (bool isVerified_, bytes32 uuid_)\n {\n isVerified_ = true;\n }\n\n function isMarketClosed(uint256 _marketId) public view returns (bool) {\n return false;\n }\n\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\n public\n view\n returns (bool isVerified_, bytes32 uuid_)\n {\n isVerified_ = true;\n }\n\n function getMarketOwner(uint256 _marketId) public view returns (address) {\n return address(marketOwner);\n }\n\n function getMarketFeeRecipient(uint256 _marketId)\n public\n view\n returns (address)\n {\n return address(marketOwner);\n }\n\n function getMarketURI(uint256 _marketId)\n public\n view\n returns (string memory)\n {\n return \"url://\";\n }\n\n function getPaymentCycle(uint256 _marketId)\n public\n view\n returns (uint32, PaymentCycleType)\n {\n return (1000, PaymentCycleType.Seconds);\n }\n\n function getPaymentDefaultDuration(uint256 _marketId)\n public\n view\n returns (uint32)\n {\n return 1000;\n }\n\n function getBidExpirationTime(uint256 _marketId)\n public\n view\n returns (uint32)\n {\n return 1000;\n }\n\n function getMarketplaceFee(uint256 _marketId) public view returns (uint16) {\n return 1000;\n }\n\n function setMarketOwner(address _owner) public {\n marketOwner = _owner;\n }\n\n function getPaymentType(uint256 _marketId)\n public\n view\n returns (PaymentType)\n {}\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) public returns (uint256) {}\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) public returns (uint256) {}\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../security/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(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/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() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.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 /**\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 _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetMinterPauser.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../extensions/ERC20Burnable.sol\";\nimport \"../extensions/ERC20Pausable.sol\";\nimport \"../../../access/AccessControlEnumerable.sol\";\nimport \"../../../utils/Context.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 *\n * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._\n */\ncontract ERC20PresetMinterPauser is Context, AccessControlEnumerable, 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) 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" - }, - "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\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 virtual override returns (address) {\n return _roleMembers[role].at(index);\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 virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\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) external view returns (address);\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) external view returns (uint256);\n}\n" - }, - "contracts/tests/V2Calculations_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/utils/Arrays.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nimport \"hardhat/console.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\nimport { Bid } from \"../TellerV2Storage.sol\";\nimport { PaymentType } from \"../libraries/V2Calculations.sol\";\n\ncontract V2Calculations_Test is Testable {\n using Arrays for uint256[];\n using EnumerableSet for EnumerableSet.UintSet;\n\n Bid __bid;\n EnumerableSet.UintSet cyclesToSkip;\n uint256[] cyclesWithExtraPayments;\n uint256[] cyclesWithExtraPaymentsAmounts;\n\n constructor() {\n __bid.loanDetails.principal = 100000e6; // 100k\n __bid.loanDetails.loanDuration = 365 days * 3; // 3 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 1000; // 10.0%\n }\n\n function setup_beforeAll() public {\n delete cyclesToSkip;\n delete cyclesWithExtraPayments;\n delete cyclesWithExtraPaymentsAmounts;\n }\n\n // EMI loan\n function _01_calculateAmountOwed_test() public {\n cyclesToSkip.add(2);\n cyclesWithExtraPayments = [3, 4];\n cyclesWithExtraPaymentsAmounts = [25000e6, 25000e6];\n\n calculateAmountOwed_runner(\n 18,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan\n function _02_calculateAmountOwed_test() public {\n cyclesToSkip.add(3);\n cyclesToSkip.add(4);\n cyclesToSkip.add(5);\n\n calculateAmountOwed_runner(\n 36,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan\n function _03_calculateAmountOwed_test() public {\n cyclesWithExtraPayments = [3, 7];\n cyclesWithExtraPaymentsAmounts = [35000e6, 20000e6];\n\n calculateAmountOwed_runner(\n 16,\n PaymentType.EMI,\n PaymentCycleType.Seconds\n );\n }\n\n // EMI loan - Monthly payment cycle\n function _04_calculateAmountOwed_test() public {\n cyclesToSkip.add(5);\n cyclesToSkip.add(7);\n\n calculateAmountOwed_runner(\n 36,\n PaymentType.EMI,\n PaymentCycleType.Monthly\n );\n }\n\n // EMI loan - Monthly payment cycle\n function _05_calculateAmountOwed_test() public {\n cyclesWithExtraPayments = [2, 6];\n cyclesWithExtraPaymentsAmounts = [35000e6, 20000e6];\n\n calculateAmountOwed_runner(\n 16,\n PaymentType.EMI,\n PaymentCycleType.Monthly\n );\n }\n\n // Bullet loan\n function _06_calculateAmountOwed_test() public {\n cyclesToSkip.add(6);\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Seconds\n );\n }\n\n // Bullet loan\n function _07_calculateAmountOwed_test() public {\n cyclesToSkip.add(12);\n cyclesWithExtraPayments = [1, 8];\n cyclesWithExtraPaymentsAmounts = [15000e6, 10000e6];\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Seconds\n );\n }\n\n // Bullet loan - Monthly payment cycle\n function _08_calculateAmountOwed_test() public {\n cyclesToSkip.add(5);\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Monthly\n );\n }\n\n // Bullet loan - Monthly paymenty cycle\n function _09_calculateAmountOwed_test() public {\n cyclesToSkip.add(8);\n cyclesWithExtraPayments = [3];\n cyclesWithExtraPaymentsAmounts = [13000e6];\n calculateAmountOwed_runner(\n 36,\n PaymentType.Bullet,\n PaymentCycleType.Monthly\n );\n }\n\n function calculateAmountOwed_runner(\n uint256 expectedTotalCycles,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType\n ) private {\n // Calculate payment cycle amount\n uint256 paymentCycleAmount = V2Calculations.calculatePaymentCycleAmount(\n _paymentType,\n _paymentCycleType,\n __bid.loanDetails.principal,\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle,\n __bid.terms.APR\n );\n\n // Set the bid's payment cycle amount\n __bid.terms.paymentCycleAmount = paymentCycleAmount;\n // Set accepted bid timestamp to now\n __bid.loanDetails.acceptedTimestamp = uint32(block.timestamp);\n\n uint256 nowTimestamp = block.timestamp;\n uint256 skippedPaymentCounter;\n uint256 owedPrincipal = __bid.loanDetails.principal;\n uint256 cycleCount = Math.ceilDiv(\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle\n );\n uint256 cycleIndex;\n while (owedPrincipal > 0) {\n // Increment cycle index\n cycleIndex++;\n\n // Increase timestamp\n nowTimestamp += __bid.terms.paymentCycle;\n\n uint256 duePrincipal;\n uint256 interest;\n (owedPrincipal, duePrincipal, interest) = V2Calculations\n .calculateAmountOwed(__bid, nowTimestamp, _paymentCycleType);\n\n // Check if we should skip this cycle for payments\n if (cyclesToSkip.length() > 0) {\n if (cyclesToSkip.contains(cycleIndex)) {\n // Add this cycle's payment amount to the next cycle's expected payment\n skippedPaymentCounter++;\n continue;\n }\n }\n\n skippedPaymentCounter = 0;\n\n uint256 extraPaymentAmount;\n // Add additional payment amounts for cycles\n if (cyclesWithExtraPayments.length > 0) {\n uint256 index = cyclesWithExtraPayments.findUpperBound(\n cycleIndex\n );\n if (\n index < cyclesWithExtraPayments.length &&\n cyclesWithExtraPayments[index] == cycleIndex\n ) {\n extraPaymentAmount = cyclesWithExtraPaymentsAmounts[index];\n }\n }\n\n // Mark repayment amounts\n uint256 principalPayment;\n principalPayment = duePrincipal + extraPaymentAmount;\n if (principalPayment > 0) {\n __bid.loanDetails.totalRepaid.principal += principalPayment;\n // Subtract principal owed for while loop execution check\n owedPrincipal -= principalPayment;\n }\n\n __bid.loanDetails.totalRepaid.interest += interest;\n\n // Set last repaid time\n __bid.loanDetails.lastRepaidTimestamp = uint32(nowTimestamp);\n }\n Test.eq(\n cycleIndex,\n expectedTotalCycles,\n \"Expected number of cycles incorrect\"\n );\n Test.eq(\n cycleIndex <= cycleCount + 1,\n true,\n \"Payment cycle exceeded agreed terms\"\n );\n }\n\n function calculateAmountOwed_test() public {\n uint256 principal = 24486571879936808846;\n uint256 repaidPrincipal = 23410087846643631232;\n uint16 interestRate = 3000;\n __bid.loanDetails.principal = principal;\n __bid.terms.APR = interestRate;\n __bid.loanDetails.totalRepaid.principal = repaidPrincipal;\n __bid.terms.paymentCycleAmount = 8567977538702439153;\n __bid.terms.paymentCycle = 2592000;\n __bid.loanDetails.acceptedTimestamp = 1646159355;\n __bid.paymentType = PaymentType.EMI;\n\n (uint256 _owedPrincipal, uint256 _duePrincipal, uint256 _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n 1658159355, // last repaid timestamp\n 1663189241, //timestamp\n PaymentCycleType.Seconds\n );\n\n console.log(\"calc amt owed test \");\n console.log(_owedPrincipal);\n console.log(_duePrincipal);\n\n Test.eq(\n _owedPrincipal,\n 1076484033293177614,\n \"Expected number of cycles incorrect\"\n );\n Test.eq(\n _duePrincipal,\n 1076484033293177614,\n \"Expected number of cycles incorrect\"\n );\n }\n\n function calculateBulletAmountOwed_test() public {\n uint256 _principal = 100000e6;\n uint256 _repaidPrincipal = 0;\n uint16 _apr = 3000;\n uint256 _acceptedTimestamp = 1646159355;\n uint256 _lastRepaidTimestamp = _acceptedTimestamp;\n __bid.loanDetails.principal = _principal;\n __bid.terms.APR = _apr;\n __bid.loanDetails.totalRepaid.principal = _repaidPrincipal;\n __bid.terms.paymentCycleAmount = 8567977538702439153;\n __bid.terms.paymentCycle = 2592000;\n __bid.loanDetails.acceptedTimestamp = uint32(_acceptedTimestamp);\n __bid.paymentType = PaymentType.Bullet;\n uint256 _paymentCycleAmount = V2Calculations\n .calculatePaymentCycleAmount(\n PaymentType.Bullet,\n PaymentCycleType.Seconds,\n _principal,\n 365 days,\n 365 days / 12,\n _apr\n );\n __bid.terms.paymentCycleAmount = _paymentCycleAmount;\n\n // Within the first payment cycle\n uint256 _timestamp = _acceptedTimestamp + ((365 days / 12) / 2);\n\n (\n uint256 _owedPrincipal,\n uint256 _duePrincipal,\n uint256 _interest\n ) = V2Calculations.calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"First cycle bullet owed principal incorrect\"\n );\n Test.eq(_duePrincipal, 0, \"First cycle bullet due principal incorrect\");\n Test.eq(_interest, 1250000000, \"First cycle bullet interest incorrect\");\n\n // Within random payment cycle\n _timestamp = _acceptedTimestamp + ((365 days / 12) * 3);\n\n __bid.terms.paymentCycle = 365 days / 12;\n __bid.loanDetails.loanDuration = 365 days;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Second cycle bullet Owed principal incorrect\"\n );\n Test.eq(_duePrincipal, 0, \"Second cycle bullet principal incorrect\");\n Test.eq(\n _interest,\n 7500000000,\n \"Second cycle bullet interest incorrect\"\n );\n\n // Last payment cycle\n _timestamp = _acceptedTimestamp + 360 days;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Final cycle bullet Owed principal incorrect\"\n );\n Test.eq(\n _duePrincipal,\n _principal,\n \"Final cycle bullet principal incorrect\"\n );\n Test.eq(\n _interest,\n 29589041095,\n \"Final cycle bullet interest incorrect\"\n );\n\n // Beyond last payment cycle (checks for overflow protection)\n _timestamp = _acceptedTimestamp + 365 days * 2;\n\n (_owedPrincipal, _duePrincipal, _interest) = V2Calculations\n .calculateAmountOwed(\n __bid,\n _lastRepaidTimestamp,\n _timestamp,\n PaymentCycleType.Seconds\n );\n\n Test.eq(\n _owedPrincipal,\n _principal,\n \"Final cycle bullet Owed principal incorrect\"\n );\n Test.eq(\n _duePrincipal,\n _principal,\n \"Final cycle bullet principal incorrect\"\n );\n Test.eq(\n _interest,\n ((_principal * _apr) / 10000) * 2,\n \"Final cycle bullet interest incorrect\"\n );\n }\n}\n" - }, - "hardhat/console.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >= 0.4.22 <0.9.0;\n\nlibrary console {\n\taddress constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n\tfunction _sendLogPayload(bytes memory payload) private view {\n\t\tuint256 payloadLength = payload.length;\n\t\taddress consoleAddress = CONSOLE_ADDRESS;\n\t\tassembly {\n\t\t\tlet payloadStart := add(payload, 32)\n\t\t\tlet r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n\t\t}\n\t}\n\n\tfunction log() internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log()\"));\n\t}\n\n\tfunction logInt(int256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(int256)\", p0));\n\t}\n\n\tfunction logUint(uint256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n\t}\n\n\tfunction logString(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction logBool(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction logAddress(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction logBytes(bytes memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n\t}\n\n\tfunction logBytes1(bytes1 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n\t}\n\n\tfunction logBytes2(bytes2 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n\t}\n\n\tfunction logBytes3(bytes3 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n\t}\n\n\tfunction logBytes4(bytes4 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n\t}\n\n\tfunction logBytes5(bytes5 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n\t}\n\n\tfunction logBytes6(bytes6 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n\t}\n\n\tfunction logBytes7(bytes7 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n\t}\n\n\tfunction logBytes8(bytes8 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n\t}\n\n\tfunction logBytes9(bytes9 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n\t}\n\n\tfunction logBytes10(bytes10 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n\t}\n\n\tfunction logBytes11(bytes11 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n\t}\n\n\tfunction logBytes12(bytes12 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n\t}\n\n\tfunction logBytes13(bytes13 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n\t}\n\n\tfunction logBytes14(bytes14 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n\t}\n\n\tfunction logBytes15(bytes15 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n\t}\n\n\tfunction logBytes16(bytes16 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n\t}\n\n\tfunction logBytes17(bytes17 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n\t}\n\n\tfunction logBytes18(bytes18 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n\t}\n\n\tfunction logBytes19(bytes19 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n\t}\n\n\tfunction logBytes20(bytes20 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n\t}\n\n\tfunction logBytes21(bytes21 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n\t}\n\n\tfunction logBytes22(bytes22 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n\t}\n\n\tfunction logBytes23(bytes23 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n\t}\n\n\tfunction logBytes24(bytes24 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n\t}\n\n\tfunction logBytes25(bytes25 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n\t}\n\n\tfunction logBytes26(bytes26 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n\t}\n\n\tfunction logBytes27(bytes27 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n\t}\n\n\tfunction logBytes28(bytes28 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n\t}\n\n\tfunction logBytes29(bytes29 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n\t}\n\n\tfunction logBytes30(bytes30 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n\t}\n\n\tfunction logBytes31(bytes31 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n\t}\n\n\tfunction logBytes32(bytes32 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n\t}\n\n\tfunction log(uint256 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256)\", p0));\n\t}\n\n\tfunction log(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction log(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction log(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n\t}\n\n\tfunction log(address p0, uint256 p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n\t}\n\n\tfunction log(address p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n\t}\n\n\tfunction log(address p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n\t}\n\n\tfunction log(address p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, uint256 p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n}\n" - }, - "contracts/tests/TellerV2Context_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport { Testable } from \"./Testable.sol\";\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\nimport { IMarketRegistry } from \"../interfaces/IMarketRegistry.sol\";\nimport { TellerV2MarketForwarder } from \"../TellerV2MarketForwarder.sol\";\nimport { LenderCommitmentForwarder } from \"../LenderCommitmentForwarder.sol\";\n\ncontract TellerV2Context_Test is Testable, TellerV2Context {\n uint256 private marketId;\n /*User private marketOwner;\n User private user1;\n User private user2;*/\n User private marketOwner;\n User private user1;\n\n constructor() TellerV2Context(address(0)) {}\n\n function setup_beforeAll() public {\n marketOwner = new User(TellerV2Context(this));\n\n marketRegistry = IMarketRegistry(\n address(new MockMarketRegistry(marketOwner))\n );\n\n Test.eq(\n marketRegistry.getMarketOwner(5),\n address(marketOwner),\n \"should have set marketOwner\"\n );\n }\n\n function isTrustedMarketForwarder_test() public returns (bool) {\n Test.eq(\n super.isTrustedMarketForwarder(89, lenderCommitmentForwarder),\n true,\n \"lenderCommitmentForwarder should be a trusted forwarder for all markets\"\n );\n //Test.eq(super.isTrustedMarketForwarder(1, address(0)) , false, \"by default address(0) should not be a trusted forwarder\");\n\n address stubbedMarketForwarder = address(\n 0xB11ca87E32075817C82Cc471994943a4290f4a14\n );\n Test.eq(\n super.isTrustedMarketForwarder(7, stubbedMarketForwarder),\n false,\n \"by default an address should not be a trusted forwarder\"\n );\n\n marketOwner.setTrustedMarketForwarder(7, stubbedMarketForwarder);\n\n Test.eq(\n super.isTrustedMarketForwarder(7, stubbedMarketForwarder),\n true,\n \" address should be a trusted forwarder after setting \"\n );\n }\n}\n\ncontract User {\n TellerV2Context public immutable context;\n\n constructor(TellerV2Context _context) {\n context = _context;\n }\n\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n context.setTrustedMarketForwarder(_marketId, _forwarder);\n }\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n context.approveMarketForwarder(_marketId, _forwarder);\n }\n}\n\ncontract MockMarketRegistry {\n User private immutable marketOwner;\n\n constructor(User _marketOwner) {\n marketOwner = _marketOwner;\n }\n\n function getMarketOwner(uint256) external view returns (address) {\n return address(marketOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/cryptography/EIP712.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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 if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Counters.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-ERC20Permit.sol\";\nimport \"../../../utils/math/Math.sol\";\nimport \"../../../governance/utils/IVotes.sol\";\nimport \"../../../utils/math/SafeCast.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n *\n * _Available since v4.2._\n */\nabstract contract ERC20Votes is IVotes, ERC20Permit {\n struct Checkpoint {\n uint32 fromBlock;\n uint224 votes;\n }\n\n bytes32 private constant _DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address => address) private _delegates;\n mapping(address => Checkpoint[]) private _checkpoints;\n Checkpoint[] private _totalSupplyCheckpoints;\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n return _checkpoints[account][pos];\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return SafeCast.toUint32(_checkpoints[account].length);\n }\n\n /**\n * @dev Get the address `account` is currently delegating to.\n */\n function delegates(address account) public view virtual override returns (address) {\n return _delegates[account];\n }\n\n /**\n * @dev Gets the current votes balance for `account`\n */\n function getVotes(address account) public view virtual override returns (uint256) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\n }\n\n /**\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_checkpoints[account], blockNumber);\n }\n\n /**\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\n * It is but NOT the sum of all the delegated votes!\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n }\n\n /**\n * @dev Lookup a value in a list of (sorted) checkpoints.\n */\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n //\n // Initially we check if the block is recent to narrow the search range.\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n // out of bounds (in which case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n // the same.\n uint256 length = ckpts.length;\n\n uint256 low = 0;\n uint256 high = length;\n\n if (length > 5) {\n uint256 mid = length - Math.sqrt(length);\n if (_unsafeAccess(ckpts, mid).fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(ckpts, mid).fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : _unsafeAccess(ckpts, high - 1).votes;\n }\n\n /**\n * @dev Delegate votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual override {\n _delegate(_msgSender(), delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= expiry, \"ERC20Votes: signature expired\");\n address signer = ECDSA.recover(\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n require(nonce == _useNonce(signer), \"ERC20Votes: invalid nonce\");\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n */\n function _maxSupply() internal view virtual returns (uint224) {\n return type(uint224).max;\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been increased.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n super._mint(account, amount);\n require(totalSupply() <= _maxSupply(), \"ERC20Votes: total supply risks overflowing votes\");\n\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been decreased.\n */\n function _burn(address account, uint256 amount) internal virtual override {\n super._burn(account, amount);\n\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {IVotes-DelegateVotesChanged} event.\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._afterTokenTransfer(from, to, amount);\n\n _moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Change delegation for `delegator` to `delegatee`.\n *\n * Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.\n */\n function _delegate(address delegator, address delegatee) internal virtual {\n address currentDelegate = delegates(delegator);\n uint256 delegatorBalance = balanceOf(delegator);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) private {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n function _writeCheckpoint(\n Checkpoint[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) private returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n\n Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);\n\n oldWeight = oldCkpt.votes;\n newWeight = op(oldWeight, delta);\n\n if (pos > 0 && oldCkpt.fromBlock == block.number) {\n _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);\n } else {\n ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));\n }\n }\n\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\n return a + b;\n }\n\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.\n */\n function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result) {\n assembly {\n mstore(0, ckpts.slot)\n result.slot := add(keccak256(0, 0x20), pos)\n }\n }\n}\n" - }, - "@openzeppelin/contracts/governance/utils/IVotes.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotes {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" - }, - "contracts/tests/PMT_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract PMT_Test is Testable, TellerV2 {\n Bid __bid;\n\n constructor() TellerV2(address(0)) {}\n\n function _01_pmt_test() public {\n __bid.loanDetails.principal = 10000e6; // 10k USDC\n __bid.loanDetails.loanDuration = 365 days * 3; // 3 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 300; // 3.0%\n pmt_runner(290812096, 365 days);\n }\n\n function _02_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 365 days * 10; // 10 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 800; // 8.0%\n pmt_runner(1213275944, 365 days);\n }\n\n function _03_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 365 days * 10; // 10 years\n __bid.terms.paymentCycle = 365 days / 12; // 1 month\n __bid.terms.APR = 0; // 0.0%\n pmt_runner(833333334, 365 days);\n }\n\n function _04_pmt_test() public {\n __bid.loanDetails.principal = 100000e6; // 100x USDC\n __bid.loanDetails.loanDuration = 45 days; // 45 days\n __bid.terms.paymentCycle = 30 days; // 1 month\n __bid.terms.APR = 600; // 6.0%\n pmt_runner(50370166243, 365 days);\n }\n\n function pmt_runner(uint256 _expected, uint256 _daysInYear) private {\n uint256 pmt = NumbersLib.pmt(\n __bid.loanDetails.principal,\n __bid.loanDetails.loanDuration,\n __bid.terms.paymentCycle,\n __bid.terms.APR,\n _daysInYear\n );\n Test.eq(pmt, _expected, \"Loan payment for cycle incorrect\");\n }\n}\n" - }, - "contracts/tests/resolvers/TestASTokenResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether a specific amount of tokens was approved to be included in an attestation.\n */\ncontract TestASTokenResolver is TellerASResolver {\n using SafeERC20 for IERC20;\n\n IERC20 private immutable _targetToken;\n uint256 private immutable _targetAmount;\n\n constructor(IERC20 targetToken, uint256 targetAmount) {\n _targetToken = targetToken;\n _targetAmount = targetAmount;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address msgSender\n ) external payable virtual override returns (bool) {\n _targetToken.safeTransferFrom(msgSender, address(this), _targetAmount);\n\n return true;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASValueResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether a specific amount of ETH was sent with an attestation.\n */\ncontract TestASValueResolver is TellerASResolver {\n uint256 private immutable _targetValue;\n\n constructor(uint256 targetValue) {\n _targetValue = targetValue;\n }\n\n function isPayable() public pure override returns (bool) {\n return true;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n return msg.value == _targetValue;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASRecipientResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether the attestation is to a specific recipient.\n */\ncontract TestASRecipientResolver is TellerASResolver {\n address private immutable _targetRecipient;\n\n constructor(address targetRecipient) {\n _targetRecipient = targetRecipient;\n }\n\n function resolve(\n address recipient,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n return recipient == _targetRecipient;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASPayingResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that pays attesters\n */\ncontract TestASPayingResolver is TellerASResolver {\n uint256 private immutable _incentive;\n\n constructor(uint256 incentive) {\n _incentive = incentive;\n }\n\n function isPayable() public pure override returns (bool) {\n return true;\n }\n\n function resolve(\n address recipient,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n payable(recipient).transfer(_incentive);\n\n return true;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASExpirationTimeResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether the expiration time is later than a specific timestamp.\n */\ncontract TestASExpirationTimeResolver is TellerASResolver {\n uint256 private immutable _validAfter;\n\n constructor(uint256 validAfter) {\n _validAfter = validAfter;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 expirationTime,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n return expirationTime >= _validAfter;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASDataResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether an attestation data is either \\x00 or \\x01.\n */\ncontract TestASDataResolver is TellerASResolver {\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata data,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n // Verifies that the data is either 0 or 1.\n return data.length == 1 && (data[0] == \"\\x00\" || data[0] == \"\\x01\");\n }\n}\n" - }, - "contracts/tests/resolvers/TestASAttesterResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\n\n/**\n * @title A sample AS resolver that checks whether the attestation is from a specific attester.\n */\ncontract TestASAttesterResolver is TellerASResolver {\n address private immutable _targetAttester;\n\n constructor(address targetAttester) {\n _targetAttester = targetAttester;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata /* data */,\n uint256 /* expirationTime */,\n address msgSender\n ) external payable virtual override returns (bool) {\n return msgSender == _targetAttester;\n }\n}\n" - }, - "contracts/tests/resolvers/TestASAttestationResolver.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../../EAS/TellerASResolver.sol\";\nimport \"../../EAS/TellerAS.sol\";\n\n/**\n * @title A sample AS resolver that checks whether an attestations attest to an existing attestation.\n */\ncontract TestASAttestationResolver is TellerASResolver {\n error Overflow();\n error OutOfBounds();\n\n TellerAS private immutable _eas;\n\n constructor(TellerAS eas) {\n _eas = eas;\n }\n\n function resolve(\n address /* recipient */,\n bytes calldata /* schema */,\n bytes calldata data,\n uint256 /* expirationTime */,\n address /* msgSender */\n ) external payable virtual override returns (bool) {\n return _eas.isAttestationValid(_toBytes32(data, 0));\n }\n\n function _toBytes32(bytes memory data, uint256 start)\n private\n pure\n returns (bytes32)\n {\n if (start + 32 < start) {\n revert Overflow();\n }\n\n if (data.length < start + 32) {\n revert OutOfBounds();\n }\n\n bytes32 tempBytes32;\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n tempBytes32 := mload(add(add(data, 0x20), start))\n }\n\n return tempBytes32;\n }\n}\n" - }, - "contracts/tests/TellerV2Autopay_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2Autopay } from \"../TellerV2Autopay.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport \"../TellerV2Storage.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\n\nimport \"../mock/TellerV2SolMock.sol\";\nimport \"../mock/MarketRegistryMock.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"../interfaces/ITellerV2Autopay.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\n\ncontract TellerV2Autopay_Test is Testable, TellerV2Autopay {\n User private marketOwner;\n User private borrower;\n User private lender;\n User private contractOwner;\n\n WethMock wethMock;\n\n address marketRegistry;\n\n constructor() TellerV2Autopay(address(new TellerV2SolMock())) {\n marketRegistry = address(new MarketRegistryMock(address(0)));\n TellerV2SolMock(address(tellerV2)).setMarketRegistry(marketRegistry);\n }\n\n function setup_beforeAll() public {\n wethMock = new WethMock();\n\n marketOwner = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n borrower = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n lender = new User(address(this), address(tellerV2), address(wethMock));\n\n contractOwner = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n\n contractOwner.initialize(5, address(contractOwner));\n }\n\n function setAutoPayEnabled_before() public {\n uint256 marketplaceId = 1;\n marketOwner.createMarketWithinRegistry(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n \"uri://\"\n );\n\n uint256 bidId = borrower.submitBid(\n address(wethMock),\n marketplaceId,\n 100,\n 4000,\n 300,\n \"ipfs://\",\n address(borrower)\n );\n }\n\n function setAutoPayEnabled_test() public {\n uint256 bidId = 0;\n\n borrower.enableAutoPay(bidId, true);\n\n Test.eq(\n loanAutoPayEnabled[bidId],\n true,\n \"Autopay not enabled after setAutoPayEnabled\"\n );\n }\n\n function setAutopayFee_test() public {\n _setAutopayFee(4);\n Test.eq(4, getAutopayFee(), \"Auto pay fee not set\");\n }\n\n function setAutopayFeeOnlyOwner_test() public {\n User user = new User(\n address(this),\n address(tellerV2),\n address(wethMock)\n );\n try user.setAutopayFee(4) {\n Test.fail(\"Auto pay fee set by non owner\");\n } catch Error(string memory reason) {\n Test.eq(\n reason,\n \"Ownable: caller is not the owner\",\n \"Should not be able to set autopay fee\"\n );\n } catch {\n Test.fail(\"Unknown error\");\n }\n }\n\n function autoPayLoanMinimum_before() public {\n uint256 marketplaceId = 1;\n\n uint256 lenderNewBalance = 500000;\n\n payable(address(lender)).transfer(lenderNewBalance);\n\n //lender approves for acceptBid\n lender.depositToWeth(lenderNewBalance);\n lender.approveWeth(address(tellerV2), lenderNewBalance);\n\n uint256 bidId = borrower.submitBid(\n address(wethMock),\n marketplaceId,\n 1000,\n 4000,\n 300,\n \"ipfs://\",\n address(borrower)\n );\n\n borrower.enableAutoPay(bidId, true);\n\n uint256 lenderBalance = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n\n lender.acceptBid(bidId);\n\n uint256 borrowerNewBalance = 500000;\n\n payable(address(borrower)).transfer(borrowerNewBalance);\n\n //borrower approve to do repay\n borrower.depositToWeth(borrowerNewBalance);\n borrower.approveWeth(address(this), borrowerNewBalance);\n }\n\n function autoPayLoanMinimum_test() public {\n uint256 bidId = 0;\n\n uint256 lenderBalanceBefore = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n uint256 borrowerBalanceBefore = ERC20(address(wethMock)).balanceOf(\n address(borrower)\n );\n\n lender.autoPayLoanMinimum(bidId);\n\n uint256 lenderBalanceAfter = ERC20(address(wethMock)).balanceOf(\n address(lender)\n );\n uint256 borrowerBalanceAfter = ERC20(address(wethMock)).balanceOf(\n address(borrower)\n );\n\n uint256 lenderBalanceDelta = lenderBalanceAfter - lenderBalanceBefore;\n\n Test.eq(\n lenderBalanceDelta,\n 2,\n \"lender did not receive the auto pay charge\"\n );\n\n uint256 borrowerBalanceDelta = borrowerBalanceBefore -\n borrowerBalanceAfter;\n\n Test.eq(borrowerBalanceDelta, 4002, \"borrower did not autopay\");\n }\n\n function getEstimatedMinimumPayment(uint256 _bidId)\n public\n override\n returns (uint256 _amount)\n {\n return 4000; //stub this for this test since there is not a good way to fast forward timestamp\n }\n}\n\ncontract User {\n address public immutable tellerV2;\n address public immutable wethMock;\n address public immutable tellerV2Autopay;\n\n constructor(address _tellerV2Autopay, address _tellerV2, address _wethMock)\n {\n tellerV2Autopay = _tellerV2Autopay;\n tellerV2 = _tellerV2;\n wethMock = _wethMock;\n }\n\n function enableAutoPay(uint256 bidId, bool enabled) public {\n ITellerV2Autopay(tellerV2Autopay).setAutoPayEnabled(bidId, enabled);\n }\n\n function createMarketWithinRegistry(\n address marketRegistry,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n string calldata _uri\n ) public {\n IMarketRegistry(marketRegistry).createMarket(\n address(this),\n _paymentCycleDuration,\n _paymentDefaultDuration,\n _bidExpirationTime,\n _feePercent,\n _requireLenderAttestation,\n _requireBorrowerAttestation,\n _paymentType,\n PaymentCycleType.Seconds,\n _uri\n );\n }\n\n function autoPayLoanMinimum(uint256 bidId) public {\n ITellerV2Autopay(tellerV2Autopay).autoPayLoanMinimum(bidId);\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public returns (uint256) {\n return\n ITellerV2(tellerV2).submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n function initialize(uint16 _newFee, address _newOwner) public {\n ITellerV2Autopay(tellerV2Autopay).initialize(_newFee, _newOwner);\n }\n\n function setAutopayFee(uint16 _newFee) public {\n ITellerV2Autopay(tellerV2Autopay).setAutopayFee(_newFee);\n }\n\n function acceptBid(uint256 _bidId) public {\n ITellerV2(tellerV2).lenderAcceptBid(_bidId);\n }\n\n function depositToWeth(uint256 amount) public {\n IWETH(wethMock).deposit{ value: amount }();\n }\n\n function approveWeth(address to, uint256 amount) public {\n ERC20(wethMock).approve(to, amount);\n }\n\n receive() external payable {}\n}\n" - }, - "contracts/TellerV2Autopay.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/ITellerV2Autopay.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { Payment } from \"./TellerV2Storage.sol\";\n\n/**\n * @dev Helper contract to autopay loans\n */\ncontract TellerV2Autopay is OwnableUpgradeable, ITellerV2Autopay {\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n\n ITellerV2 public immutable tellerV2;\n\n //bidId => enabled\n mapping(uint256 => bool) public loanAutoPayEnabled;\n\n // Autopay fee set for automatic loan payments\n uint16 private _autopayFee;\n\n /**\n * @notice This event is emitted when a loan is autopaid.\n * @param bidId The id of the bid/loan which was repaid.\n * @param msgsender The account that called the method\n */\n event AutoPaidLoanMinimum(uint256 indexed bidId, address indexed msgsender);\n\n /**\n * @notice This event is emitted when loan autopayments are enabled or disabled.\n * @param bidId The id of the bid/loan.\n * @param enabled Whether the autopayments are enabled or disabled\n */\n event AutoPayEnabled(uint256 indexed bidId, bool enabled);\n\n /**\n * @notice This event is emitted when the autopay fee has been updated.\n * @param newFee The new autopay fee set.\n * @param oldFee The previously set autopay fee.\n */\n event AutopayFeeSet(uint16 newFee, uint16 oldFee);\n\n constructor(address _protocolAddress) {\n tellerV2 = ITellerV2(_protocolAddress);\n }\n\n /**\n * @notice Initialized the proxy.\n * @param _fee The fee collected for automatic payment processing.\n * @param _owner The address of the ownership to be transferred to.\n */\n function initialize(uint16 _fee, address _owner) external initializer {\n _transferOwnership(_owner);\n _setAutopayFee(_fee);\n }\n\n /**\n * @notice Let the owner of the contract set a new autopay fee.\n * @param _newFee The new autopay fee to set.\n */\n function setAutopayFee(uint16 _newFee) public virtual onlyOwner {\n _setAutopayFee(_newFee);\n }\n\n function _setAutopayFee(uint16 _newFee) internal {\n // Skip if the fee is the same\n if (_newFee == _autopayFee) return;\n uint16 oldFee = _autopayFee;\n _autopayFee = _newFee;\n emit AutopayFeeSet(_newFee, oldFee);\n }\n\n /**\n * @notice Returns the current autopay fee.\n */\n function getAutopayFee() public view virtual returns (uint16) {\n return _autopayFee;\n }\n\n /**\n * @notice Function for a borrower to enable or disable autopayments\n * @param _bidId The id of the bid to cancel.\n * @param _autoPayEnabled boolean for allowing autopay on a loan\n */\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external {\n require(\n _msgSender() == tellerV2.getLoanBorrower(_bidId),\n \"Only the borrower can set autopay\"\n );\n\n loanAutoPayEnabled[_bidId] = _autoPayEnabled;\n\n emit AutoPayEnabled(_bidId, _autoPayEnabled);\n }\n\n /**\n * @notice Function for a minimum autopayment to be performed on a loan\n * @param _bidId The id of the bid to repay.\n */\n function autoPayLoanMinimum(uint256 _bidId) external {\n require(\n loanAutoPayEnabled[_bidId],\n \"Autopay is not enabled for that loan\"\n );\n\n address lendingToken = ITellerV2(tellerV2).getLoanLendingToken(_bidId);\n address borrower = ITellerV2(tellerV2).getLoanBorrower(_bidId);\n\n uint256 amountToRepayMinimum = getEstimatedMinimumPayment(_bidId);\n uint256 autopayFeeAmount = amountToRepayMinimum.percent(\n getAutopayFee()\n );\n\n // Pull lendingToken in from the borrower to this smart contract\n ERC20(lendingToken).safeTransferFrom(\n borrower,\n address(this),\n amountToRepayMinimum + autopayFeeAmount\n );\n\n // Transfer fee to msg sender\n ERC20(lendingToken).safeTransfer(_msgSender(), autopayFeeAmount);\n\n // Approve the lendingToken to tellerV2\n ERC20(lendingToken).approve(address(tellerV2), amountToRepayMinimum);\n\n // Use that lendingToken to repay the loan\n tellerV2.repayLoan(_bidId, amountToRepayMinimum);\n\n emit AutoPaidLoanMinimum(_bidId, msg.sender);\n }\n\n function getEstimatedMinimumPayment(uint256 _bidId)\n public\n virtual\n returns (uint256 _amount)\n {\n Payment memory estimatedPayment = tellerV2.calculateAmountDue(_bidId);\n\n _amount = estimatedPayment.principal + estimatedPayment.interest;\n }\n}\n" - }, - "contracts/mock/TellerV2SolMock.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"../TellerV2.sol\";\nimport \"../interfaces/ITellerV2.sol\";\nimport \"../TellerV2Context.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport { LoanDetails, Payment, BidState } from \"../TellerV2Storage.sol\";\n\n/*\nThis is only used for sol test so its named specifically to avoid being used for the typescript tests.\n*/\ncontract TellerV2SolMock is ITellerV2, TellerV2Storage {\n function setMarketRegistry(address _marketRegistry) public {\n marketRegistry = IMarketRegistry(_marketRegistry);\n }\n\n function getMarketRegistry() external view returns (IMarketRegistry) {\n return marketRegistry;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketId,\n uint256 _principal,\n uint32 _duration,\n uint16,\n string calldata,\n address _receiver\n ) public returns (uint256 bidId_) {\n bidId_ = bidId;\n\n Bid storage bid = bids[bidId];\n bid.borrower = msg.sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n bidId++;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public returns (uint256 bidId_) {}\n\n function repayLoanMinimum(uint256 _bidId) external {}\n\n function repayLoanFull(uint256 _bidId) external {}\n\n function repayLoan(uint256 _bidId, uint256 _amount) public {\n Bid storage bid = bids[_bidId];\n\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n msg.sender,\n address(this),\n _amount\n );\n }\n\n /*\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n function lenderAcceptBid(uint256 _bidId)\n public\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n Bid storage bid = bids[_bidId];\n\n bid.lender = msg.sender;\n\n //send tokens to caller\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n bid.lender,\n bid.receiver,\n bid.loanDetails.principal\n );\n //for the reciever\n\n return (0, bid.loanDetails.principal, 0);\n }\n\n function getBidState(uint256 _bidId) public view returns (BidState) {\n return bids[_bidId].state;\n }\n\n function getLoanDetails(uint256 _bidId)\n public\n view\n returns (LoanDetails memory)\n {\n return bids[_bidId].loanDetails;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n public\n view\n returns (uint256[] memory)\n {}\n\n function isLoanDefaulted(uint256 _bidId) public view returns (bool) {}\n\n function isPaymentLate(uint256 _bidId) public view returns (bool) {}\n\n function getLoanBorrower(uint256 _bidId)\n external\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n function getLoanLender(uint256 _bidId)\n external\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function setLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp) public {\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n}\n" - }, - "contracts/interfaces/ITellerV2Autopay.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Autopay {\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external;\n\n function autoPayLoanMinimum(uint256 _bidId) external;\n\n function initialize(uint16 _newFee, address _newOwner) external;\n\n function setAutopayFee(uint16 _newFee) external;\n}\n" - }, - "contracts/tests/MarketRegistry_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\n\nimport { TellerV2 } from \"../TellerV2.sol\";\nimport { MarketRegistry } from \"../MarketRegistry.sol\";\nimport { ReputationManager } from \"../ReputationManager.sol\";\n\nimport \"../TellerV2Storage.sol\";\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport \"../interfaces/IReputationManager.sol\";\n\nimport \"../EAS/TellerAS.sol\";\n\nimport \"../mock/WethMock.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nimport { PaymentType, PaymentCycleType } from \"../libraries/V2Calculations.sol\";\nimport \"./Test_Helpers.sol\";\n\n/*\n\nThis should have more unit tests that operate on MarketRegistry.sol \n\n*/\n\ncontract MarketRegistry_Test is Testable, TellerV2 {\n User private marketOwner;\n User private borrower;\n User private lender;\n\n WethMock wethMock;\n\n constructor() TellerV2(address(address(0))) {}\n\n function setup_beforeAll() public {\n //wethMock = new WethMock();\n\n marketOwner = new User(address(this));\n borrower = new User(address(this));\n lender = new User(address(this));\n\n lenderCommitmentForwarder = address(0);\n marketRegistry = IMarketRegistry(new MarketRegistry());\n reputationManager = IReputationManager(new ReputationManager());\n }\n\n function createMarket_test() public {\n // Standard seconds payment cycle\n marketOwner.createMarket(\n address(marketRegistry),\n 8000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Seconds,\n \"uri://\"\n );\n (\n uint32 paymentCycleDuration,\n PaymentCycleType paymentCycle\n ) = marketRegistry.getPaymentCycle(1);\n\n require(\n paymentCycle == PaymentCycleType.Seconds,\n \"Market payment cycle type incorrectly created\"\n );\n\n require(\n paymentCycleDuration == 8000,\n \"Market payment cycle duration set incorrectly\"\n );\n\n // Monthly payment cycle\n marketOwner.createMarket(\n address(marketRegistry),\n 0,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Monthly,\n \"uri://\"\n );\n (paymentCycleDuration, paymentCycle) = marketRegistry.getPaymentCycle(\n 2\n );\n\n require(\n paymentCycle == PaymentCycleType.Monthly,\n \"Monthly market payment cycle type incorrectly created\"\n );\n\n require(\n paymentCycleDuration == 30 days,\n \"Monthly market payment cycle duration set incorrectly\"\n );\n\n // Monthly payment cycle should fail\n bool createFailed;\n try\n marketOwner.createMarket(\n address(marketRegistry),\n 3000,\n 7000,\n 5000,\n 500,\n false,\n false,\n PaymentType.EMI,\n PaymentCycleType.Monthly,\n \"uri://\"\n )\n {} catch {\n createFailed = true;\n }\n require(createFailed, \"Monthly market should not have been created\");\n }\n}\n" - }, - "contracts/tests/CollateralEscrow_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Testable } from \"./Testable.sol\";\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\n\nimport { CollateralEscrowV1 } from \"../escrow/CollateralEscrowV1.sol\";\nimport \"../mock/WethMock.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol\";\nimport \"@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport { CollateralType, CollateralEscrowV1 } from \"../escrow/CollateralEscrowV1.sol\";\n\ncontract CollateralEscrow_Test is Testable {\n BeaconProxy private proxy_;\n User private borrower;\n WethMock wethMock;\n uint256 amount = 1000;\n\n function setup_beforeAll() public {\n // Deploy implementation\n CollateralEscrowV1 escrowImplementation = new CollateralEscrowV1();\n // Deploy beacon contract with implementation\n UpgradeableBeacon escrowBeacon = new UpgradeableBeacon(\n address(escrowImplementation)\n );\n // Deploy escrow\n wethMock = new WethMock();\n borrower = new User(escrowBeacon, address(wethMock));\n\n uint256 borrowerBalance = 50000;\n payable(address(borrower)).transfer(borrowerBalance);\n borrower.depositToWeth(borrowerBalance);\n }\n\n function depositAsset_test() public {\n _depositAsset();\n }\n\n function withdrawAsset_test() public {\n _depositAsset();\n\n borrower.withdraw(address(wethMock), amount, address(borrower));\n\n uint256 storedBalance = borrower.getBalance(address(wethMock));\n\n Test.eq(storedBalance, 0, \"Escrow withdraw unsuccessful\");\n\n try borrower.withdraw(address(wethMock), amount, address(borrower)) {\n Test.fail(\"No collateral balance for asset\");\n } catch Error(string memory reason) {\n Test.eq(\n reason,\n \"No collateral balance for asset\",\n \"Should not be able to withdraw already withdrawn assets\"\n );\n } catch {\n Test.fail(\"Unknown error\");\n }\n }\n\n function _depositAsset() internal {\n borrower.approveWeth(amount);\n\n borrower.deposit(CollateralType.ERC20, address(wethMock), amount, 0);\n\n uint256 storedBalance = borrower.getBalance(address(wethMock));\n\n Test.eq(storedBalance, amount, \"Escrow deposit unsuccessful\");\n }\n}\n\ncontract User {\n CollateralEscrowV1 public escrow;\n address public immutable wethMock;\n\n constructor(UpgradeableBeacon escrowBeacon, address _wethMock) {\n // Deploy escrow\n BeaconProxy proxy_ = new BeaconProxy(\n address(escrowBeacon),\n abi.encodeWithSelector(CollateralEscrowV1.initialize.selector, 0)\n );\n escrow = CollateralEscrowV1(address(proxy_));\n wethMock = _wethMock;\n }\n\n function deposit(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) public {\n escrow.depositAsset(\n _collateralType,\n _collateralAddress,\n _amount,\n _tokenId\n );\n }\n\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) public {\n escrow.withdraw(_collateralAddress, _amount, _recipient);\n }\n\n function depositToWeth(uint256 amount) public {\n IWETH(wethMock).deposit{ value: amount }();\n }\n\n function approveWeth(uint256 amount) public {\n ERC20(wethMock).approve(address(escrow), amount);\n }\n\n function getBalance(address _collateralAddress)\n public\n returns (uint256 amount_)\n {\n (, amount_, , ) = escrow.collateralBalances(_collateralAddress);\n }\n\n receive() external payable {}\n}\n" - }, - "contracts/tests/LenderCommitmentForwarder_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"./resolvers/TestERC20Token.sol\";\nimport \"../TellerV2MarketForwarder.sol\";\nimport \"../TellerV2Context.sol\";\nimport { Testable } from \"./Testable.sol\";\nimport { LenderCommitmentForwarder } from \"../LenderCommitmentForwarder.sol\";\n\nimport { Collateral, CollateralType } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\n/* \n add tests for each token type \n\n add test for conversion of collateral type -- simple \n\n */\n\ncontract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder {\n LenderCommitmentForwarderTest_TellerV2Mock private tellerV2Mock;\n MarketRegistryMock mockMarketRegistry;\n\n LenderCommitmentUser private marketOwner;\n LenderCommitmentUser private lender;\n LenderCommitmentUser private borrower;\n\n // address tokenAddress;\n uint256 marketId;\n uint256 maxAmount;\n\n address[] emptyArray;\n address[] borrowersArray;\n\n uint32 maxLoanDuration;\n uint16 minInterestRate;\n uint32 expiration;\n\n bool acceptBidWasCalled;\n bool submitBidWasCalled;\n bool submitBidWithCollateralWasCalled;\n\n TestERC20Token principalToken;\n uint8 constant principalTokenDecimals = 18;\n\n TestERC20Token collateralToken;\n uint8 constant collateralTokenDecimals = 6;\n\n constructor()\n LenderCommitmentForwarder(\n address(new LenderCommitmentForwarderTest_TellerV2Mock()), ///_protocolAddress\n address(new MarketRegistryMock(address(0)))\n )\n {}\n\n function setup_beforeAll() public {\n tellerV2Mock = LenderCommitmentForwarderTest_TellerV2Mock(\n address(getTellerV2())\n );\n mockMarketRegistry = MarketRegistryMock(address(getMarketRegistry()));\n\n marketOwner = new LenderCommitmentUser(address(tellerV2Mock), (this));\n borrower = new LenderCommitmentUser(address(tellerV2Mock), (this));\n lender = new LenderCommitmentUser(address(tellerV2Mock), (this));\n tellerV2Mock.__setMarketOwner(marketOwner);\n\n mockMarketRegistry.setMarketOwner(address(marketOwner));\n\n //tokenAddress = address(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);\n marketId = 2;\n maxAmount = 100000000000000000000;\n maxLoanDuration = 2480000;\n minInterestRate = 3000;\n expiration = uint32(block.timestamp) + uint32(64000);\n\n marketOwner.setTrustedMarketForwarder(marketId, address(this));\n lender.approveMarketForwarder(marketId, address(this));\n\n borrowersArray = new address[](1);\n borrowersArray[0] = address(borrower);\n\n principalToken = new TestERC20Token(\n \"Test Wrapped ETH\",\n \"TWETH\",\n 0,\n principalTokenDecimals\n );\n\n collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n collateralTokenDecimals\n );\n\n delete acceptBidWasCalled;\n delete submitBidWasCalled;\n delete submitBidWithCollateralWasCalled;\n\n delete commitmentCount;\n }\n\n function _createCommitment(\n CommitmentCollateralType _collateralType,\n uint256 _maxPrincipalPerCollateral\n ) internal returns (Commitment storage commitment_) {\n commitment_ = commitments[0];\n commitment_.marketId = marketId;\n commitment_.principalTokenAddress = address(principalToken);\n commitment_.maxPrincipal = maxAmount;\n commitment_.maxDuration = maxLoanDuration;\n commitment_.minInterestRate = minInterestRate;\n commitment_.expiration = expiration;\n commitment_.lender = address(lender);\n\n commitment_.collateralTokenType = _collateralType;\n commitment_.maxPrincipalPerCollateralAmount =\n _maxPrincipalPerCollateral *\n 10**principalTokenDecimals;\n\n if (_collateralType == CommitmentCollateralType.ERC20) {\n commitment_.collateralTokenAddress = address(collateralToken);\n } else if (_collateralType == CommitmentCollateralType.ERC721) {\n commitment_.collateralTokenAddress = address(\n 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\n );\n } else if (_collateralType == CommitmentCollateralType.ERC1155) {\n commitment_.collateralTokenAddress = address(\n 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\n );\n }\n }\n\n function createCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage existingCommitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6 * 1e18\n );\n\n lender._createCommitment(existingCommitment, emptyArray);\n }\n\n function updateCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage existingCommitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n Test.eq(\n address(lender),\n existingCommitment.lender,\n \"Not the owner of created commitment\"\n );\n\n lender._updateCommitment(commitmentId, existingCommitment);\n }\n\n function deleteCommitment_test() public {\n uint256 commitmentId = 0;\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n Test.eq(\n commitment.lender,\n address(lender),\n \"Not the owner of created commitment\"\n );\n\n lender._deleteCommitment(commitmentId);\n\n Test.eq(\n commitment.lender,\n address(0),\n \"The commitment was not deleted\"\n );\n }\n\n function acceptCommitment_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n Test.eq(\n acceptBidWasCalled,\n false,\n \"Expect accept bid not called before exercise\"\n );\n\n uint256 bidId = borrower._acceptCommitment(\n commitmentId,\n maxAmount - 100, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n\n Test.eq(\n commitment.maxPrincipal == 100,\n true,\n \"Commitment max principal was not decremented\"\n );\n\n bidId = borrower._acceptCommitment(\n commitmentId,\n 100, //principalAmount\n 100, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(commitment.maxPrincipal == 0, true, \"commitment not accepted\");\n\n bool acceptCommitTwiceFails;\n\n try\n borrower._acceptCommitment(\n commitmentId,\n 100, //principalAmount\n 100, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n acceptCommitTwiceFails = true;\n }\n\n Test.eq(\n acceptCommitTwiceFails,\n true,\n \"Should fail when accepting commit twice\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_valid_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n uint256 bidId = borrower._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_invalid_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n bool acceptCommitAsMarketOwnerFails;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n acceptCommitAsMarketOwnerFails = true;\n }\n\n Test.eq(\n acceptCommitAsMarketOwnerFails,\n true,\n \"Should fail when accepting as invalid borrower\"\n );\n\n lender._updateCommitmentBorrowers(commitmentId, emptyArray);\n\n acceptBidWasCalled = false;\n\n marketOwner._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentWithBorrowersArray_reset_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n maxAmount\n );\n\n lender._updateCommitmentBorrowers(commitmentId, borrowersArray);\n\n lender._updateCommitmentBorrowers(commitmentId, emptyArray);\n\n marketOwner._acceptCommitment(\n commitmentId,\n 0, //principal\n maxAmount, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n );\n\n Test.eq(\n acceptBidWasCalled,\n true,\n \"Expect accept bid called after exercise\"\n );\n }\n\n function acceptCommitmentFailsWithInsufficientCollateral_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n bool failedToAcceptCommitment;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n 0, //collateralAmount\n 0, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n failedToAcceptCommitment = true;\n }\n\n Test.eq(\n failedToAcceptCommitment,\n true,\n \"Should fail to accept commitment with insufficient collateral\"\n );\n }\n\n function acceptCommitmentFailsWithInvalidAmount_test() public {\n uint256 commitmentId = 0;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC721,\n 1000e6\n );\n\n bool failedToAcceptCommitment;\n\n try\n marketOwner._acceptCommitment(\n commitmentId,\n 100, //principal\n 2, //collateralAmount\n 22, //collateralTokenId\n address(collateralToken),\n minInterestRate,\n maxLoanDuration\n )\n {} catch {\n failedToAcceptCommitment = true;\n }\n\n Test.eq(\n failedToAcceptCommitment,\n true,\n \"Should fail to accept commitment with invalid amount for ERC721\"\n );\n }\n\n function decrementCommitment_before() public {}\n\n function decrementCommitment_test() public {\n uint256 commitmentId = 0;\n uint256 _decrementAmount = 22;\n\n Commitment storage commitment = _createCommitment(\n CommitmentCollateralType.ERC20,\n 1000e6\n );\n\n _decrementCommitment(commitmentId, _decrementAmount);\n\n Test.eq(\n commitment.maxPrincipal == maxAmount - _decrementAmount,\n true,\n \"Commitment max principal was not decremented\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 700 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_700_USDC__500_per_WETH_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test Wrapped ETH\",\n \"TWETH\",\n 0,\n 18\n );\n Test.eq(\n super.getRequiredCollateral(\n 700 * (1e6), // 700 USDC loan\n 500 * (1e6) * (1e6), // 500 USDC loan allowed per WETH, expanded by principal token decimals\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 14e17, // 1.4 WETH\n \"expected 1.4 WETH collateral\"\n );\n }\n\n /**\n * collateral token = NFT (10**0)\n * principal token = USDC (10**6)\n * principal = 700 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_700_USDC_loan__500_per_ERC1155_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 700e6, // 700 USDC loan\n 500e6 * (10**6) * (10**0), // 500 USDC per NFT\n CommitmentCollateralType.ERC1155,\n address(0),\n address(usdcToken)\n ),\n 2, // 2 NFTs\n \"expected 2 NFTs collateral\"\n );\n }\n\n /**\n * collateral token = NFT (10**0)\n * principal token = USDC (10**6)\n * principal = 500 USDC\n * max principal per collateral = 500 USDC\n */\n function getRequiredCollateral_500_USDC_loan__500_per_ERC721_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 500e6, // 7500 USDC loan\n 500e6 * (1e6), // 500 USDC per NFT, expanded by principal token decimals\n CommitmentCollateralType.ERC721,\n address(0),\n address(usdcToken)\n ),\n 1, // 1 NFT\n \"expected 1 NFT collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 WETH\n * max principal per collateral = 0.00059 WETH\n */\n function getRequiredCollateral_1_WETH_loan__00059_per_USDC_test() public {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e18, // 1 WETH loan\n 59e13 * (1e18), // 0.00059 WETH per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1_694_915_255, // 1,694.915255 USDC (1694.915254237 rounded up to 6 decimals)\n \"expected 1,694.915255 USDC collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 1000 USDC $\n * max principal per collateral = 1.0 WETH\n */\n function getRequiredCollateral_1000_USDC_loan_9_gwei_per_usdc_unit_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 1000 * (1e6), // 1000 USDC loan //principal\n 1e9 * (1e6), // 1000000000 wei per USDC base unit //ratio\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 1e18, // 1 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**6)\n * principal = 8888 USDC $\n * max principal per collateral = 1 gwei per USDDC base unit\n */\n function getRequiredCollateral_8888_USDC_loan__9_gwei_per_usdc_unit_test()\n public\n {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 8888 * (1e6), // 8888 USDC loan //principal\n 1e9 * (1e6), // 1000000000 wei per USDC base unit //ratio\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 8888e15, // 8.888 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = WETH (10**18)\n * principal token = USDC (10**8)\n * principal = 8888 USDC\n * max principal per collateral = 8888000000 wei per USDC base unit\n */\n function getRequiredCollateral_8888_USDC_loan__unit_test() public {\n TestERC20Token usdcToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test WETH\",\n \"TWETH\",\n 0,\n 18\n );\n\n Test.eq(\n super.getRequiredCollateral(\n 8888 * (1e6), // 8888 USDC loan //principal\n 8888000000 * (1e6), // 8888000000 wei per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(usdcToken)\n ),\n 1e18, // 1 wETH\n \"expected 1 ETH required collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = GWEI (10**9)\n * principal = 6 GWEI\n * max principal per collateral = 0.00059 USDC per gwei\n */\n function getRequiredCollateral_6_GWEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token gweiToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 9\n );\n\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 6 gwei, // 6 GWEI loan\n 59e13 * (1e9), // 0.00059 USDC per gwei\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(gweiToken)\n ),\n 11, // 0.000011 USDC (0.000010169 rounded up to 6 decimals)\n \"expected 0.000011 USDC collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WEI (10**0)\n * principal = 1 WEI\n * max principal per collateral = // 0.00059 WETH per usdc base unit\n */\n function getRequiredCollateral_1_WEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1, // 1 WEI loan\n 59e13 * 1e18, // 0.00059 WETH per USDC base unit\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1, // 0.001695 USDC rounded up\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 GWEI\n * max principal per collateral = 0.00059 WETH per gwei\n */\n function getRequiredCollateral_1_GWEI_loan__00059_WETH_per_USDC_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e9, // 1 GWEI loan\n 59e13 * 1e18, // 0.00059 WETH per USDC base unit (hence why not multiplying by 1e6)\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 2,\n \"expected at least 2 units of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 GWEI\n * max principal per collateral = 1 wei per usdc $\n */\n function getRequiredCollateral_1_wei_loan__1_Wei_per_USDC_test() public {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1e9, // 1 gwei\n (1 * 1e6) * 1e18, // must provide 1:1 ratio usdc $ to wei\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1e3 * 1e6, // 1000 usdc $\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /**\n * collateral token = USDC (10**6)\n * principal token = WETH (10**18)\n * principal = 1 wei\n * max principal per collateral = 1 wei per usdc $\n */\n function getRequiredCollateral_1_wei_loan__1_Wei_per_USDC_unit_test()\n public\n {\n TestERC20Token collateralToken = new TestERC20Token(\n \"Test USDC\",\n \"TUSDC\",\n 0,\n 6\n );\n Test.eq(\n super.getRequiredCollateral(\n 1, // 1 wei\n (1 * 1e6) * 1e18, // must provide 1 usdc to get loan of 1 wei, expanded by principal decimals\n CommitmentCollateralType.ERC20,\n address(collateralToken),\n address(principalToken)\n ),\n 1, // 1 usdc base unit\n \"expected at least 1 unit of collateral\"\n );\n }\n\n /*\n Overrider methods for exercise \n */\n\n function _submitBid(CreateLoanArgs memory, address)\n internal\n override\n returns (uint256 bidId)\n {\n submitBidWasCalled = true;\n return 1;\n }\n\n function _submitBidWithCollateral(\n CreateLoanArgs memory,\n Collateral[] memory,\n address\n ) internal override returns (uint256 bidId) {\n submitBidWithCollateralWasCalled = true;\n return 1;\n }\n\n function _acceptBid(uint256, address) internal override returns (bool) {\n acceptBidWasCalled = true;\n\n Test.eq(\n submitBidWithCollateralWasCalled,\n true,\n \"Submit bid must be called before accept bid\"\n );\n\n return true;\n }\n}\n\ncontract LenderCommitmentUser is User {\n LenderCommitmentForwarder public immutable commitmentForwarder;\n\n constructor(\n address _tellerV2,\n LenderCommitmentForwarder _commitmentForwarder\n ) User(_tellerV2) {\n commitmentForwarder = _commitmentForwarder;\n }\n\n function _createCommitment(\n LenderCommitmentForwarder.Commitment calldata _commitment,\n address[] calldata borrowerAddressList\n ) public returns (uint256) {\n return\n commitmentForwarder.createCommitment(\n _commitment,\n borrowerAddressList\n );\n }\n\n function _updateCommitment(\n uint256 commitmentId,\n LenderCommitmentForwarder.Commitment calldata _commitment\n ) public {\n commitmentForwarder.updateCommitment(commitmentId, _commitment);\n }\n\n function _updateCommitmentBorrowers(\n uint256 commitmentId,\n address[] calldata borrowerAddressList\n ) public {\n commitmentForwarder.updateCommitmentBorrowers(\n commitmentId,\n borrowerAddressList\n );\n }\n\n function _acceptCommitment(\n uint256 commitmentId,\n uint256 principal,\n uint256 collateralAmount,\n uint256 collateralTokenId,\n address collateralTokenAddress,\n uint16 interestRate,\n uint32 loanDuration\n ) public returns (uint256) {\n return\n commitmentForwarder.acceptCommitment(\n commitmentId,\n principal,\n collateralAmount,\n collateralTokenId,\n collateralTokenAddress,\n interestRate,\n loanDuration\n );\n }\n\n function _deleteCommitment(uint256 _commitmentId) public {\n commitmentForwarder.deleteCommitment(_commitmentId);\n }\n}\n\n//Move to a helper file !\ncontract LenderCommitmentForwarderTest_TellerV2Mock is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "contracts/tests/MarketForwarder_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"hardhat/console.sol\";\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport { Testable } from \"./Testable.sol\";\nimport { TellerV2Context } from \"../TellerV2Context.sol\";\nimport { IMarketRegistry } from \"../interfaces/IMarketRegistry.sol\";\nimport { TellerV2MarketForwarder } from \"../TellerV2MarketForwarder.sol\";\n\nimport { User } from \"./Test_Helpers.sol\";\n\nimport \"../mock/MarketRegistryMock.sol\";\n\ncontract MarketForwarder_Test is Testable, TellerV2MarketForwarder {\n MarketForwarderTester private tellerV2Mock;\n\n MarketRegistryMock mockMarketRegistry;\n\n uint256 private marketId;\n MarketForwarderUser private marketOwner;\n MarketForwarderUser private user1;\n MarketForwarderUser private user2;\n\n constructor()\n TellerV2MarketForwarder(\n address(new MarketForwarderTester()),\n address(new MarketRegistryMock(address(0)))\n )\n {}\n\n function setup_beforeAll() public {\n mockMarketRegistry = MarketRegistryMock(address(getMarketRegistry()));\n tellerV2Mock = MarketForwarderTester(address(getTellerV2()));\n\n marketOwner = new MarketForwarderUser(address(tellerV2Mock));\n user1 = new MarketForwarderUser(address(tellerV2Mock));\n user2 = new MarketForwarderUser(address(tellerV2Mock));\n\n tellerV2Mock.__setMarketOwner(marketOwner);\n\n mockMarketRegistry.setMarketOwner(address(marketOwner));\n\n delete marketId;\n }\n\n function setTrustedMarketForwarder_before() public {\n marketOwner.setTrustedMarketForwarder(marketId, address(this));\n }\n\n function setTrustedMarketForwarder_test() public {\n Test.eq(\n tellerV2Mock.isTrustedMarketForwarder(marketId, address(this)),\n true,\n \"Trusted forwarder was not set\"\n );\n }\n\n function approveMarketForwarder_before() public {\n setTrustedMarketForwarder_before();\n\n user1.approveMarketForwarder(marketId, address(this));\n user2.approveMarketForwarder(marketId, address(this));\n }\n\n function approveMarketForwarder_test() public {\n Test.eq(\n tellerV2Mock.hasApprovedMarketForwarder(\n marketId,\n address(this),\n address(user1)\n ),\n true,\n \"Borrower did not set market forwarder approval\"\n );\n Test.eq(\n tellerV2Mock.hasApprovedMarketForwarder(\n marketId,\n address(this),\n address(user2)\n ),\n true,\n \"Lender did not set market forwarder approval\"\n );\n }\n\n function forwardUserCall_before() public {\n approveMarketForwarder_before();\n }\n\n function forwardUserCall_test() public {\n address expectedSender = address(user1);\n address sender = abi.decode(\n _forwardCall(\n abi.encodeWithSelector(\n MarketForwarderTester.getSenderForMarket.selector,\n marketId\n ),\n expectedSender\n ),\n (address)\n );\n Test.eq(\n sender,\n expectedSender,\n \"Sender address for market does not match expected\"\n );\n\n bytes memory expectedData = abi.encodeWithSelector(\n MarketForwarderTester.getDataForMarket.selector,\n marketId\n );\n bytes memory data = abi.decode(\n _forwardCall(expectedData, expectedSender),\n (bytes)\n );\n Test.eq0(\n data,\n expectedData,\n \"Function calldata for market does not match expected\"\n );\n }\n}\n\n//This should use the user helper !!\ncontract MarketForwarderUser is User {\n constructor(address _tellerV2) User(_tellerV2) {}\n}\n\n//Move to a helper\n//this is a tellerV2 mock\ncontract MarketForwarderTester is TellerV2Context {\n constructor() TellerV2Context(address(0)) {}\n\n function __setMarketOwner(User _marketOwner) external {\n marketRegistry = IMarketRegistry(\n address(new MarketRegistryMock(address(_marketOwner)))\n );\n }\n\n function getSenderForMarket(uint256 _marketId)\n external\n view\n returns (address)\n {\n return _msgSenderForMarket(_marketId);\n }\n\n function getDataForMarket(uint256 _marketId)\n external\n view\n returns (bytes calldata)\n {\n return _msgDataForMarket(_marketId);\n }\n}\n" - }, - "contracts/ProtocolFeeMock.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./ProtocolFee.sol\";\n\ncontract ProtocolFeeMock is ProtocolFee {\n bool public setProtocolFeeCalled;\n\n function initialize(uint16 _initFee) external initializer {\n __ProtocolFee_init(_initFee);\n }\n\n function setProtocolFee(uint16 newFee) public override onlyOwner {\n setProtocolFeeCalled = true;\n\n bool _isInitializing;\n assembly {\n _isInitializing := sload(1)\n }\n\n // Only call the actual function if we are not initializing\n if (!_isInitializing) {\n super.setProtocolFee(newFee);\n }\n }\n}\n" - }, - "contracts/tests/NextDueDate_test.sol": { - "content": "pragma solidity ^0.8.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract NextDueDate_Test is Testable, TellerV2 {\n Bid __bid;\n\n constructor() TellerV2(address(0)) {\n __bid.loanDetails.principal = 10000e6; // 10k USDC\n __bid.loanDetails.loanDuration = 365 days * 2; // 2 years\n __bid.terms.paymentCycle = 30 days; // 1 month\n __bid.terms.APR = 450; // 4.5%\n __bid.state = BidState.ACCEPTED;\n }\n\n function _01_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2020, 1, 31) // Leap year\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is Feb 29th\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2020, 2, 29));\n nextDueDate_runner(expectedDate);\n }\n\n function _02_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2020, 2, 29)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 29th\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2020, 3, 29));\n nextDueDate_runner(expectedDate);\n }\n\n function _03_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 2, 1)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 1st\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2023, 3, 1));\n nextDueDate_runner(expectedDate);\n }\n\n function _04_nextDueDate_test() public {\n __bid.loanDetails.acceptedTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 1, 31)\n );\n __bid.loanDetails.lastRepaidTimestamp = uint32(\n BPBDTL.timestampFromDate(2023, 2, 1)\n );\n bids[1] = __bid;\n bidPaymentCycleType[1] = PaymentCycleType.Monthly;\n // Expected date is March 31st\n uint32 expectedDate = uint32(BPBDTL.timestampFromDate(2023, 3, 31));\n nextDueDate_runner(expectedDate);\n }\n\n function nextDueDate_runner(uint256 _expected) private {\n uint256 nextDueDate = calculateNextDueDate(1);\n Test.eq(nextDueDate, _expected, \"Next due date incorrect\");\n }\n}\n" - }, - "contracts/tests/GetMetaDataURI_Test.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@mangrovedao/hardhat-test-solidity/test.sol\";\n\nimport \"./Testable.sol\";\nimport \"../TellerV2.sol\";\n\ncontract GetMetaDataURI_Test is Testable, TellerV2 {\n constructor() TellerV2(address(0)) {}\n\n function setup_beforeAll() public {\n // Old depreciated _metadataURI on bid struct\n bids[0]\n ._metadataURI = 0x0000000000000000000000000000000086004f3f419f88be1cab574b4bd01b6d;\n // New metadataURI from uris mapping\n uris[59] = \"ipfs://QmMyDataHash\";\n }\n\n function getMetaDataURI_test() public {\n string memory oldURI = getMetadataURI(0);\n Test.eq(\n oldURI,\n \"0x0000000000000000000000000000000086004f3f419f88be1cab574b4bd01b6d\",\n \"Expected URI does not match stored depreciated value in the Bid struct\"\n );\n string memory newURI = getMetadataURI(59);\n Test.eq(\n newURI,\n \"ipfs://QmMyDataHash\",\n \"Expected URI does not match new value in uri mapping\"\n );\n }\n}\n" - }, - "contracts/EAS/TellerASEIP712Verifier.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IEASEIP712Verifier.sol\";\n\n/**\n * @title EIP712 typed signatures verifier for EAS delegated attestations.\n */\ncontract TellerASEIP712Verifier is IEASEIP712Verifier {\n error InvalidSignature();\n\n string public constant VERSION = \"0.8\";\n\n // EIP712 domain separator, making signatures from different domains incompatible.\n bytes32 public immutable DOMAIN_SEPARATOR; // solhint-disable-line var-name-mixedcase\n\n // The hash of the data type used to relay calls to the attest function. It's the value of\n // keccak256(\"Attest(address recipient,bytes32 schema,uint256 expirationTime,bytes32 refUUID,bytes data,uint256 nonce)\").\n bytes32 public constant ATTEST_TYPEHASH =\n 0x39c0608dd995a3a25bfecb0fffe6801a81bae611d94438af988caa522d9d1476;\n\n // The hash of the data type used to relay calls to the revoke function. It's the value of\n // keccak256(\"Revoke(bytes32 uuid,uint256 nonce)\").\n bytes32 public constant REVOKE_TYPEHASH =\n 0xbae0931f3a99efd1b97c2f5b6b6e79d16418246b5055d64757e16de5ad11a8ab;\n\n // Replay protection nonces.\n mapping(address => uint256) private _nonces;\n\n /**\n * @dev Creates a new EIP712Verifier instance.\n */\n constructor() {\n uint256 chainId;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n chainId := chainid()\n }\n\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n ),\n keccak256(bytes(\"EAS\")),\n keccak256(bytes(VERSION)),\n chainId,\n address(this)\n )\n );\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function getNonce(address account)\n external\n view\n override\n returns (uint256)\n {\n return _nonces[account];\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(\n ATTEST_TYPEHASH,\n recipient,\n schema,\n expirationTime,\n refUUID,\n keccak256(data),\n _nonces[attester]++\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n if (recoveredAddress == address(0) || recoveredAddress != attester) {\n revert InvalidSignature();\n }\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function revoke(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(REVOKE_TYPEHASH, uuid, _nonces[attester]++)\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n if (recoveredAddress == address(0) || recoveredAddress != attester) {\n revert InvalidSignature();\n }\n }\n}\n" - }, - "contracts/EAS/TellerASRegistry.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../Types.sol\";\nimport \"../interfaces/IASRegistry.sol\";\nimport \"../interfaces/IASResolver.sol\";\n\n/**\n * @title The global AS registry.\n */\ncontract TellerASRegistry is IASRegistry {\n error AlreadyExists();\n\n string public constant VERSION = \"0.8\";\n\n // The global mapping between AS records and their IDs.\n mapping(bytes32 => ASRecord) private _registry;\n\n // The global counter for the total number of attestations.\n uint256 private _asCount;\n\n /**\n * @inheritdoc IASRegistry\n */\n function register(bytes calldata schema, IASResolver resolver)\n external\n override\n returns (bytes32)\n {\n uint256 index = ++_asCount;\n\n ASRecord memory asRecord = ASRecord({\n uuid: EMPTY_UUID,\n index: index,\n schema: schema,\n resolver: resolver\n });\n\n bytes32 uuid = _getUUID(asRecord);\n if (_registry[uuid].uuid != EMPTY_UUID) {\n revert AlreadyExists();\n }\n\n asRecord.uuid = uuid;\n _registry[uuid] = asRecord;\n\n emit Registered(uuid, index, schema, resolver, msg.sender);\n\n return uuid;\n }\n\n /**\n * @inheritdoc IASRegistry\n */\n function getAS(bytes32 uuid)\n external\n view\n override\n returns (ASRecord memory)\n {\n return _registry[uuid];\n }\n\n /**\n * @inheritdoc IASRegistry\n */\n function getASCount() external view override returns (uint256) {\n return _asCount;\n }\n\n /**\n * @dev Calculates a UUID for a given AS.\n *\n * @param asRecord The input AS.\n *\n * @return AS UUID.\n */\n function _getUUID(ASRecord memory asRecord) private pure returns (bytes32) {\n return keccak256(abi.encodePacked(asRecord.schema, asRecord.resolver));\n }\n}\n" - }, - "contracts/TellerV2Mock.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2.sol\";\n\ncontract TellerV2Mock is TellerV2 {\n constructor(address trustedForwarder) TellerV2(trustedForwarder) {}\n\n function mockBid(Bid calldata _bid) external {\n bids[bidId] = _bid;\n borrowerBids[_msgSender()].push(bidId);\n bidId++;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId, uint32 _timestamp) external {\n require(_timestamp > 0, \"Accepted timestamp 0\");\n bids[_bidId].loanDetails.acceptedTimestamp = _timestamp;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId) external {\n bids[_bidId].loanDetails.acceptedTimestamp = uint32(block.timestamp);\n }\n\n function mockLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp)\n external\n {\n require(_timestamp > 0, \"Repaid timestamp 0\");\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n\n function setVersion(uint256 _version) public {\n version = _version;\n }\n}\n" - }, - "contracts/TLR.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract TLR is ERC20Votes, Ownable {\n uint224 private immutable MAX_SUPPLY;\n\n /**\n * @dev Sets the value of the `cap`. This value is immutable, it can only be\n * set once during construction.\n */\n constructor(uint224 _supplyCap, address tokenOwner)\n ERC20(\"Teller\", \"TLR\")\n ERC20Permit(\"Teller\")\n {\n require(_supplyCap > 0, \"ERC20Capped: cap is 0\");\n MAX_SUPPLY = _supplyCap;\n _transferOwnership(tokenOwner);\n }\n\n /**\n * @dev Max supply has been overridden to cap the token supply upon initialization of the contract\n * @dev See OpenZeppelin's implementation of ERC20Votes _mint() function\n */\n function _maxSupply() internal view override returns (uint224) {\n return MAX_SUPPLY;\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function mint(address account, uint256 amount) external onlyOwner {\n _mint(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) external onlyOwner {\n _burn(account, amount);\n }\n}\n" - }, - "contracts/type-imports.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n//SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\n" - }, - "contracts/TellerV0Storage.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/*\n\n THIS IS ONLY USED FOR SUBGRAPH \n \n\n*/\n\ncontract TellerV0Storage {\n enum BidState {\n NONEXISTENT,\n PENDING,\n CANCELLED,\n ACCEPTED,\n PAID,\n LIQUIDATED\n }\n\n /**\n * @notice Represents a total amount for a payment.\n * @param principal Amount that counts towards the principal.\n * @param interest Amount that counts toward interest.\n */\n struct Payment {\n uint256 principal;\n uint256 interest;\n }\n\n /**\n * @notice Details about the loan.\n * @param lendingToken The token address for the loan.\n * @param principal The amount of tokens initially lent out.\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\n * @param loanDuration The duration of the loan.\n */\n struct LoanDetails {\n ERC20 lendingToken;\n uint256 principal;\n Payment totalRepaid;\n uint32 timestamp;\n uint32 acceptedTimestamp;\n uint32 lastRepaidTimestamp;\n uint32 loanDuration;\n }\n\n /**\n * @notice Details about a loan request.\n * @param borrower Account address who is requesting a loan.\n * @param receiver Account address who will receive the loan amount.\n * @param lender Account address who accepted and funded the loan request.\n * @param marketplaceId ID of the marketplace the bid was submitted to.\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\n * @param loanDetails Struct of the specific loan details.\n * @param terms Struct of the loan request terms.\n * @param state Represents the current state of the loan.\n */\n struct Bid0 {\n address borrower;\n address receiver;\n address _lender; // DEPRECATED\n uint256 marketplaceId;\n bytes32 _metadataURI; // DEPRECATED\n LoanDetails loanDetails;\n Terms terms;\n BidState state;\n }\n\n /**\n * @notice Information on the terms of a loan request\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\n */\n struct Terms {\n uint256 paymentCycleAmount;\n uint32 paymentCycle;\n uint16 APR;\n }\n\n // Mapping of bidId to bid information.\n mapping(uint256 => Bid0) public bids;\n}\n" - }, - "contracts/interfaces/IUniswapV2Router.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n @notice This interface defines the different functions available for a UniswapV2Router.\n @author develop@teller.finance\n */\ninterface IUniswapV2Router {\n function factory() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETH(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function quote(uint256 amountA, uint256 reserveA, uint256 reserveB)\n external\n pure\n returns (uint256 amountB);\n\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountOut);\n\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountIn);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n /**\n @notice It returns the address of the canonical WETH address;\n */\n function WETH() external pure returns (address);\n\n /**\n @notice Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountIn The amount of input tokens to send.\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the output tokens.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n */\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /**\n @notice Swaps an exact amount of tokens for as much ETH as possible, along the route determined by the path. The first element of path is the input token, the last must be WETH, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountIn The amount of input tokens to send.\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the ETH.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n @dev If the to address is a smart contract, it must have the ability to receive ETH.\n */\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /**\n @notice Swaps an exact amount of ETH for as many output tokens as possible, along the route determined by the path. The first element of path must be WETH, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the output tokens.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n */\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapTokensForExactETH(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapETHForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\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/packages/contracts/deployments/goerli/solcInputs/704ec39527d925eea3260ddc4e8d1e8a.json b/packages/contracts/deployments/goerli/solcInputs/e0730cda169a6d13b8fda0f782338556.json similarity index 75% rename from packages/contracts/deployments/goerli/solcInputs/704ec39527d925eea3260ddc4e8d1e8a.json rename to packages/contracts/deployments/goerli/solcInputs/e0730cda169a6d13b8fda0f782338556.json index 96e074557..b96dc66b2 100644 --- a/packages/contracts/deployments/goerli/solcInputs/704ec39527d925eea3260ddc4e8d1e8a.json +++ b/packages/contracts/deployments/goerli/solcInputs/e0730cda169a6d13b8fda0f782338556.json @@ -19,9 +19,6 @@ "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the proxy with `beacon`.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity\n * constructor.\n *\n * Requirements:\n *\n * - `beacon` must be a contract with the interface {IBeacon}.\n */\n constructor(address beacon, bytes memory data) payable {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n\n /**\n * @dev Returns the current beacon address.\n */\n function _beacon() internal view virtual returns (address) {\n return _getBeacon();\n }\n\n /**\n * @dev Returns the current implementation address of the associated beacon.\n */\n function _implementation() internal view virtual override returns (address) {\n return IBeacon(_getBeacon()).implementation();\n }\n\n /**\n * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n *\n * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n *\n * Requirements:\n *\n * - `beacon` must be a contract.\n * - The implementation returned by `beacon` must be a contract.\n */\n function _setBeacon(address beacon, bytes memory data) internal virtual {\n _upgradeBeaconToAndCall(beacon, data, false);\n }\n}\n" }, - "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" }, @@ -34,6 +31,9 @@ "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^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 *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSetUpgradeable {\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 // 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) {\n // 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 if (lastIndex != toDeleteIndex) {\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] = valueIndex; // Replace lastValue's index to valueIndex\n }\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 return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 in 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 /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" }, + "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, "contracts/TellerV2Storage.sol": { "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport { IMarketRegistry } from \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/IReputationManager.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./interfaces/ICollateralManager.sol\";\nimport { PaymentType, PaymentCycleType } from \"./libraries/V2Calculations.sol\";\nimport \"./interfaces/ILenderManager.sol\";\n\nenum BidState {\n NONEXISTENT,\n PENDING,\n CANCELLED,\n ACCEPTED,\n PAID,\n LIQUIDATED\n}\n\n/**\n * @notice Represents a total amount for a payment.\n * @param principal Amount that counts towards the principal.\n * @param interest Amount that counts toward interest.\n */\nstruct Payment {\n uint256 principal;\n uint256 interest;\n}\n\n/**\n * @notice Details about a loan request.\n * @param borrower Account address who is requesting a loan.\n * @param receiver Account address who will receive the loan amount.\n * @param lender Account address who accepted and funded the loan request.\n * @param marketplaceId ID of the marketplace the bid was submitted to.\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\n * @param loanDetails Struct of the specific loan details.\n * @param terms Struct of the loan request terms.\n * @param state Represents the current state of the loan.\n */\nstruct Bid {\n address borrower;\n address receiver;\n address lender; // if this is the LenderManager address, we use that .owner() as source of truth\n uint256 marketplaceId;\n bytes32 _metadataURI; // DEPRECATED\n LoanDetails loanDetails;\n Terms terms;\n BidState state;\n PaymentType paymentType;\n}\n\n/**\n * @notice Details about the loan.\n * @param lendingToken The token address for the loan.\n * @param principal The amount of tokens initially lent out.\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\n * @param loanDuration The duration of the loan.\n */\nstruct LoanDetails {\n ERC20 lendingToken;\n uint256 principal;\n Payment totalRepaid;\n uint32 timestamp;\n uint32 acceptedTimestamp;\n uint32 lastRepaidTimestamp;\n uint32 loanDuration;\n}\n\n/**\n * @notice Information on the terms of a loan request\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\n */\nstruct Terms {\n uint256 paymentCycleAmount;\n uint32 paymentCycle;\n uint16 APR;\n}\n\nabstract contract TellerV2Storage_G0 {\n /** Storage Variables */\n\n // Current number of bids.\n uint256 public bidId = 0;\n\n // Mapping of bidId to bid information.\n mapping(uint256 => Bid) public bids;\n\n // Mapping of borrowers to borrower requests.\n mapping(address => uint256[]) public borrowerBids;\n\n // Mapping of volume filled by lenders.\n mapping(address => uint256) public __lenderVolumeFilled; // DEPRECIATED\n\n // Volume filled by all lenders.\n uint256 public __totalVolumeFilled; // DEPRECIATED\n\n // List of allowed lending tokens\n EnumerableSet.AddressSet internal __lendingTokensSet; // DEPRECATED\n\n IMarketRegistry public marketRegistry;\n IReputationManager public reputationManager;\n\n // Mapping of borrowers to borrower requests.\n mapping(address => EnumerableSet.UintSet) internal _borrowerBidsActive;\n\n mapping(uint256 => uint32) public bidDefaultDuration;\n mapping(uint256 => uint32) public bidExpirationTime;\n\n // Mapping of volume filled by lenders.\n // Asset address => Lender address => Volume amount\n mapping(address => mapping(address => uint256)) public lenderVolumeFilled;\n\n // Volume filled by all lenders.\n // Asset address => Volume amount\n mapping(address => uint256) public totalVolumeFilled;\n\n uint256 public version;\n\n // Mapping of metadataURIs by bidIds.\n // Bid Id => metadataURI string\n mapping(uint256 => string) public uris;\n}\n\nabstract contract TellerV2Storage_G1 is TellerV2Storage_G0 {\n // market ID => trusted forwarder\n mapping(uint256 => address) internal _trustedMarketForwarders;\n // trusted forwarder => set of pre-approved senders\n mapping(address => EnumerableSet.AddressSet)\n internal _approvedForwarderSenders;\n}\n\nabstract contract TellerV2Storage_G2 is TellerV2Storage_G1 {\n address public lenderCommitmentForwarder;\n}\n\nabstract contract TellerV2Storage_G3 is TellerV2Storage_G2 {\n ICollateralManager public collateralManager;\n}\n\nabstract contract TellerV2Storage_G4 is TellerV2Storage_G3 {\n // Address of the lender manager contract\n ILenderManager public lenderManager;\n // BidId to payment cycle type (custom or monthly)\n mapping(uint256 => PaymentCycleType) public bidPaymentCycleType;\n}\n\nabstract contract TellerV2Storage is TellerV2Storage_G4 {}\n" }, @@ -127,17 +127,26 @@ "@openzeppelin/contracts/utils/StorageSlot.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" }, - "contracts/LenderCommitmentForwarder.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./TellerV2MarketForwarder.sol\";\n\n// Interfaces\nimport \"./interfaces/ICollateralManager.sol\";\nimport { Collateral, CollateralType } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n// Libraries\nimport { MathUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\ncontract LenderCommitmentForwarder is TellerV2MarketForwarder {\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n\n enum CommitmentCollateralType {\n NONE, // no collateral required\n ERC20,\n ERC721,\n ERC1155,\n ERC721_ANY_ID,\n ERC1155_ANY_ID\n }\n\n /**\n * @notice Details about a lender's capital commitment.\n * @param maxPrincipal Amount of tokens being committed by the lender. Max amount that can be loaned.\n * @param expiration Expiration time in seconds, when the commitment expires.\n * @param maxDuration Length of time, in seconds that the lender's capital can be lent out for.\n * @param minInterestRate Minimum Annual percentage to be applied for loans using the lender's capital.\n * @param collateralTokenAddress The address for the token contract that must be used to provide collateral for loans for this commitment.\n * @param maxPrincipalPerCollateralAmount The amount of principal that can be used for a loan per each unit of collateral, expanded additionally by principal decimals.\n * @param collateralTokenType The type of asset of the collateralTokenAddress (ERC20, ERC721, or ERC1155).\n * @param lender The address of the lender for this commitment.\n * @param marketId The market id for this commitment.\n * @param principalTokenAddress The address for the token contract that will be used to provide principal for loans of this commitment.\n */\n struct Commitment {\n uint256 maxPrincipal;\n uint32 expiration;\n uint32 maxDuration;\n uint16 minInterestRate;\n address collateralTokenAddress;\n uint256 collateralTokenId;\n uint256 maxPrincipalPerCollateralAmount;\n CommitmentCollateralType collateralTokenType;\n address lender;\n uint256 marketId;\n address principalTokenAddress;\n }\n\n // CommitmentId => commitment\n mapping(uint256 => Commitment) public commitments;\n\n uint256 commitmentCount;\n\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet)\n internal commitmentBorrowersList;\n\n /**\n * @notice This event is emitted when a lender's commitment is created.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event CreatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when a lender's commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event UpdatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when the allowed borrowers for a commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n */\n event UpdatedCommitmentBorrowers(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment has been deleted.\n * @param commitmentId The id of the commitment that was deleted.\n */\n event DeletedCommitment(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment is exercised for a loan.\n * @param commitmentId The id of the commitment that was exercised.\n * @param borrower The address of the borrower.\n * @param tokenAmount The amount of the asset being committed.\n * @param bidId The bid id for the loan from TellerV2.\n */\n event ExercisedCommitment(\n uint256 indexed commitmentId,\n address borrower,\n uint256 tokenAmount,\n uint256 bidId\n );\n\n error InsufficientCommitmentAllocation(\n uint256 allocated,\n uint256 requested\n );\n error InsufficientBorrowerCollateral(uint256 required, uint256 actual);\n\n /** Modifiers **/\n\n modifier commitmentLender(uint256 _commitmentId) {\n require(\n commitments[_commitmentId].lender == _msgSender(),\n \"unauthorized commitment lender\"\n );\n _;\n }\n\n function validateCommitment(Commitment storage _commitment) internal {\n require(\n _commitment.expiration > uint32(block.timestamp),\n \"expired commitment\"\n );\n require(\n _commitment.maxPrincipal > 0,\n \"commitment principal allocation 0\"\n );\n\n if (_commitment.collateralTokenType != CommitmentCollateralType.NONE) {\n require(\n _commitment.maxPrincipalPerCollateralAmount > 0,\n \"commitment collateral ratio 0\"\n );\n\n if (\n _commitment.collateralTokenType ==\n CommitmentCollateralType.ERC20\n ) {\n require(\n _commitment.collateralTokenId == 0,\n \"commitment collateral token id must be 0 for ERC20\"\n );\n }\n }\n }\n\n /** External Functions **/\n\n constructor(address _protocolAddress, address _marketRegistry)\n TellerV2MarketForwarder(_protocolAddress, _marketRegistry)\n {}\n\n /**\n * @notice Creates a loan commitment from a lender for a market.\n * @param _commitment The new commitment data expressed as a struct\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\n * @return commitmentId_ returns the commitmentId for the created commitment\n */\n function createCommitment(\n Commitment calldata _commitment,\n address[] calldata _borrowerAddressList\n ) public returns (uint256 commitmentId_) {\n commitmentId_ = commitmentCount++;\n\n require(\n _commitment.lender == _msgSender(),\n \"unauthorized commitment creator\"\n );\n\n commitments[commitmentId_] = _commitment;\n\n validateCommitment(commitments[commitmentId_]);\n\n _addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList);\n\n emit CreatedCommitment(\n commitmentId_,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n /**\n * @notice Updates the commitment of a lender to a market.\n * @param _commitmentId The Id of the commitment to update.\n * @param _commitment The new commitment data expressed as a struct\n */\n function updateCommitment(\n uint256 _commitmentId,\n Commitment calldata _commitment\n ) public commitmentLender(_commitmentId) {\n require(\n _commitment.principalTokenAddress ==\n commitments[_commitmentId].principalTokenAddress,\n \"Principal token address cannot be updated.\"\n );\n require(\n _commitment.marketId == commitments[_commitmentId].marketId,\n \"Market Id cannot be updated.\"\n );\n\n commitments[_commitmentId] = _commitment;\n\n validateCommitment(commitments[_commitmentId]);\n\n emit UpdatedCommitment(\n _commitmentId,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n /**\n * @notice Updates the borrowers allowed to accept a commitment\n * @param _commitmentId The Id of the commitment to update.\n * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment\n */\n function updateCommitmentBorrowers(\n uint256 _commitmentId,\n address[] calldata _borrowerAddressList\n ) public commitmentLender(_commitmentId) {\n delete commitmentBorrowersList[_commitmentId];\n _addBorrowersToCommitmentAllowlist(_commitmentId, _borrowerAddressList);\n }\n\n /**\n * @notice Adds a borrower to the allowlist for a commmitment.\n * @param _commitmentId The id of the commitment that will allow the new borrower\n * @param _borrowerArray the address array of the borrowers that will be allowed to accept loans using the commitment\n */\n function _addBorrowersToCommitmentAllowlist(\n uint256 _commitmentId,\n address[] calldata _borrowerArray\n ) internal {\n for (uint256 i = 0; i < _borrowerArray.length; i++) {\n commitmentBorrowersList[_commitmentId].add(_borrowerArray[i]);\n }\n emit UpdatedCommitmentBorrowers(_commitmentId);\n }\n\n /**\n * @notice Removes the commitment of a lender to a market.\n * @param _commitmentId The id of the commitment to delete.\n */\n function deleteCommitment(uint256 _commitmentId)\n public\n commitmentLender(_commitmentId)\n {\n delete commitments[_commitmentId];\n delete commitmentBorrowersList[_commitmentId];\n emit DeletedCommitment(_commitmentId);\n }\n\n /**\n * @notice Reduces the commitment amount for a lender to a market.\n * @param _commitmentId The id of the commitment to modify.\n * @param _tokenAmountDelta The amount of change in the maxPrincipal.\n */\n function _decrementCommitment(\n uint256 _commitmentId,\n uint256 _tokenAmountDelta\n ) internal {\n commitments[_commitmentId].maxPrincipal -= _tokenAmountDelta;\n }\n\n /**\n * @notice Accept the commitment to submitBid and acceptBid using the funds\n * @dev LoanDuration must be longer than the market payment cycle\n * @param _commitmentId The id of the commitment being accepted.\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId of collateral to use for the loan if ERC721 or ERC1155.\n * @param _collateralTokenAddress The contract address to use for the loan collateral tokens.\n * @param _interestRate The interest rate APY to use for the loan in basis points.\n * @param _loanDuration The overall duration for the loan. Must be longer than market payment cycle duration.\n * @return bidId The ID of the loan that was created on TellerV2\n */\n function acceptCommitment(\n uint256 _commitmentId,\n uint256 _principalAmount,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n address _collateralTokenAddress,\n uint16 _interestRate,\n uint32 _loanDuration\n ) external returns (uint256 bidId) {\n address borrower = _msgSender();\n\n Commitment storage commitment = commitments[_commitmentId];\n\n validateCommitment(commitment);\n\n require(\n _collateralTokenAddress == commitment.collateralTokenAddress,\n \"Mismatching collateral token\"\n );\n require(\n _interestRate >= commitment.minInterestRate,\n \"Invalid interest rate\"\n );\n require(\n _loanDuration <= commitment.maxDuration,\n \"Invalid loan max duration\"\n );\n\n require(\n commitmentBorrowersList[_commitmentId].length() == 0 ||\n commitmentBorrowersList[_commitmentId].contains(borrower),\n \"unauthorized commitment borrower\"\n );\n\n if (_principalAmount > commitment.maxPrincipal) {\n revert InsufficientCommitmentAllocation({\n allocated: commitment.maxPrincipal,\n requested: _principalAmount\n });\n }\n\n uint256 requiredCollateral = getRequiredCollateral(\n _principalAmount,\n commitment.maxPrincipalPerCollateralAmount,\n commitment.collateralTokenType,\n commitment.collateralTokenAddress,\n commitment.principalTokenAddress\n );\n if (_collateralAmount < requiredCollateral) {\n revert InsufficientBorrowerCollateral({\n required: requiredCollateral,\n actual: _collateralAmount\n });\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType ==\n CommitmentCollateralType.ERC721_ANY_ID\n ) {\n require(\n _collateralAmount == 1,\n \"invalid commitment collateral amount for ERC721\"\n );\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType == CommitmentCollateralType.ERC1155\n ) {\n require(\n commitment.collateralTokenId == _collateralTokenId,\n \"invalid commitment collateral tokenId\"\n );\n }\n\n bidId = _submitBidFromCommitment(\n borrower,\n commitment.marketId,\n commitment.principalTokenAddress,\n _principalAmount,\n commitment.collateralTokenAddress,\n _collateralAmount,\n _collateralTokenId,\n commitment.collateralTokenType,\n _loanDuration,\n _interestRate\n );\n\n _acceptBid(bidId, commitment.lender);\n\n _decrementCommitment(_commitmentId, _principalAmount);\n\n emit ExercisedCommitment(\n _commitmentId,\n borrower,\n _principalAmount,\n bidId\n );\n }\n\n /**\n * @notice Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _maxPrincipalPerCollateralAmount The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\n * @param _collateralTokenType The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\n * @param _collateralTokenAddress The contract address for the collateral for the loan.\n * @param _principalTokenAddress The contract address for the principal for the loan.\n */\n function getRequiredCollateral(\n uint256 _principalAmount,\n uint256 _maxPrincipalPerCollateralAmount,\n CommitmentCollateralType _collateralTokenType,\n address _collateralTokenAddress,\n address _principalTokenAddress\n ) public view virtual returns (uint256) {\n if (_collateralTokenType == CommitmentCollateralType.NONE) {\n return 0;\n }\n\n uint8 collateralDecimals;\n uint8 principalDecimals = IERC20MetadataUpgradeable(\n _principalTokenAddress\n ).decimals();\n\n if (_collateralTokenType == CommitmentCollateralType.ERC20) {\n collateralDecimals = IERC20MetadataUpgradeable(\n _collateralTokenAddress\n ).decimals();\n }\n\n /*\n * The principalAmount is expanded by (collateralDecimals+principalDecimals) to increase precision\n * and then it is divided by _maxPrincipalPerCollateralAmount which should already been expanded by principalDecimals\n */\n return\n MathUpgradeable.mulDiv(\n _principalAmount,\n (10**(collateralDecimals + principalDecimals)),\n _maxPrincipalPerCollateralAmount,\n MathUpgradeable.Rounding.Up\n );\n }\n\n /**\n * @notice Return the array of borrowers that are allowlisted for a commitment\n * @param _commitmentId The commitment id for the commitment to query.\n * @return borrowers_ An array of addresses restricted to accept the commitment. Empty array means unrestricted.\n */\n function getCommitmentBorrowers(uint256 _commitmentId)\n external\n view\n returns (address[] memory borrowers_)\n {\n borrowers_ = commitmentBorrowersList[_commitmentId].values();\n }\n\n /**\n * @notice Internal function to submit a bid to the lending protocol using a commitment\n * @param _borrower The address of the borrower for the loan.\n * @param _marketId The id for the market of the loan in the lending protocol.\n * @param _principalTokenAddress The contract address for the principal token.\n * @param _principalAmount The amount of principal to borrow for the loan.\n * @param _collateralTokenAddress The contract address for the collateral token.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId for the collateral (if it is ERC721 or ERC1155).\n * @param _collateralTokenType The type of collateral token (ERC20,ERC721,ERC1177,None).\n * @param _loanDuration The duration of the loan in seconds delta. Must be longer than loan payment cycle for the market.\n * @param _interestRate The amount of interest APY for the loan expressed in basis points.\n */\n function _submitBidFromCommitment(\n address _borrower,\n uint256 _marketId,\n address _principalTokenAddress,\n uint256 _principalAmount,\n address _collateralTokenAddress,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n CommitmentCollateralType _collateralTokenType,\n uint32 _loanDuration,\n uint16 _interestRate\n ) internal returns (uint256 bidId) {\n CreateLoanArgs memory createLoanArgs;\n createLoanArgs.marketId = _marketId;\n createLoanArgs.lendingToken = _principalTokenAddress;\n createLoanArgs.principal = _principalAmount;\n createLoanArgs.duration = _loanDuration;\n createLoanArgs.interestRate = _interestRate;\n\n Collateral[] memory collateralInfo;\n if (_collateralTokenType != CommitmentCollateralType.NONE) {\n collateralInfo = new Collateral[](1);\n collateralInfo[0] = Collateral({\n _collateralType: _getEscrowCollateralType(_collateralTokenType),\n _tokenId: _collateralTokenId,\n _amount: _collateralAmount,\n _collateralAddress: _collateralTokenAddress\n });\n }\n\n bidId = _submitBidWithCollateral(\n createLoanArgs,\n collateralInfo,\n _borrower\n );\n }\n\n /**\n * @notice Return the collateral type based on the commitmentcollateral type. Collateral type is used in the base lending protocol.\n * @param _type The type of collateral to be used for the loan.\n */\n function _getEscrowCollateralType(CommitmentCollateralType _type)\n internal\n pure\n returns (CollateralType)\n {\n if (_type == CommitmentCollateralType.ERC20) {\n return CollateralType.ERC20;\n }\n if (\n _type == CommitmentCollateralType.ERC721 ||\n _type == CommitmentCollateralType.ERC721_ANY_ID\n ) {\n return CollateralType.ERC721;\n }\n if (\n _type == CommitmentCollateralType.ERC1155 ||\n _type == CommitmentCollateralType.ERC1155_ANY_ID\n ) {\n return CollateralType.ERC1155;\n }\n\n revert(\"Unknown Collateral Type\");\n }\n}\n" + "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC721_init_unchained(name_, symbol_);\n }\n\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721Upgradeable.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256, /* firstTokenId */\n uint256 batchSize\n ) internal virtual {\n if (batchSize > 1) {\n if (from != address(0)) {\n _balances[from] -= batchSize;\n }\n if (to != address(0)) {\n _balances[to] += batchSize;\n }\n }\n }\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 firstTokenId,\n uint256 batchSize\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[44] private __gap;\n}\n" }, - "contracts/TellerV2MarketForwarder.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\n\nimport \"./interfaces/IMarketRegistry.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\n\n/**\n * @dev Simple helper contract to forward an encoded function call to the TellerV2 contract. See {TellerV2Context}\n */\nabstract contract TellerV2MarketForwarder is Initializable, ContextUpgradeable {\n using AddressUpgradeable for address;\n\n address public immutable _tellerV2;\n address public immutable _marketRegistry;\n\n struct CreateLoanArgs {\n uint256 marketId;\n address lendingToken;\n uint256 principal;\n uint32 duration;\n uint16 interestRate;\n string metadataURI;\n address recipient;\n }\n\n constructor(address _protocolAddress, address _marketRegistryAddress) {\n _tellerV2 = _protocolAddress;\n _marketRegistry = _marketRegistryAddress;\n }\n\n function getTellerV2() public view returns (address) {\n return _tellerV2;\n }\n\n function getMarketRegistry() public view returns (address) {\n return _marketRegistry;\n }\n\n function getTellerV2MarketOwner(uint256 marketId) public returns (address) {\n return IMarketRegistry(getMarketRegistry()).getMarketOwner(marketId);\n }\n\n /**\n * @dev Performs function call to the TellerV2 contract by appending an address to the calldata.\n * @param _data The encoded function calldata on TellerV2.\n * @param _msgSender The address that should be treated as the underlying function caller.\n * @return The encoded response from the called function.\n *\n * Requirements:\n * - The {_msgSender} address must set an approval on TellerV2 for this forwarder contract __before__ making this call.\n */\n function _forwardCall(bytes memory _data, address _msgSender)\n internal\n returns (bytes memory)\n {\n return\n address(_tellerV2).functionCall(\n abi.encodePacked(_data, _msgSender)\n );\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBid(\n CreateLoanArgs memory _createLoanArgs,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address)\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBidWithCollateral(\n CreateLoanArgs memory _createLoanArgs,\n Collateral[] memory _collateralInfo,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient,\n _collateralInfo\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Accepts a new loan using the TellerV2 lending protocol.\n * @param _bidId The id of the new loan.\n * @param _lender The address of the lender who will provide funds for the new loan.\n */\n function _acceptBid(uint256 _bidId, address _lender)\n internal\n virtual\n returns (bool)\n {\n // Approve the borrower's loan\n _forwardCall(\n abi.encodeWithSelector(ITellerV2.lenderAcceptBid.selector, _bidId),\n _lender\n );\n\n return true;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = MathUpgradeable.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, MathUpgradeable.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" }, "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" }, - "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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 if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" }, "contracts/MarketLiquidityRewards.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\nimport \"./interfaces/IMarketLiquidityRewards.sol\";\n\nimport \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/ICollateralManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\n\nimport { BidState } from \"./TellerV2Storage.sol\";\n\n// Libraries\nimport { MathUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\n/*\n- Claim reward for a loan based on loanId (use a brand new contract)\n- This contract holds the reward tokens in escrow.\n- There will be an allocateReward() function, only called by marketOwner, deposits tokens in escrow\n- There will be a claimReward() function -> reads state of loans , only called by borrower -> withdraws tokens from escrow and makes those loans as having claimed rewards\n- unallocateReward()\n\nThis contract could give out 1 OHM when someone takes out a loan (for every 1000 USDC)\n\n\n ryan ideas : \n\n\n1. the claimer could be the lender or borrower \nie we might be incentivizing one or the other, or both (or some other address? idk a use case yet tho)\nprincipalTokenAddress\n2.ie the loan had to be made in USDC or x token\ncollateralTokenAddress\nie Olympus wants to incentivize holders to lock up gOHM as collateral\nmaxPrincipalPerCollateral\n3. ie we might incentivize a collateral ratio greater than or less than some number. or this might be blank (would not use an oracle but raw units ? )\n\n4. make sure loans are REPAID before any reward \n\n*/\n\ncontract MarketLiquidityRewards is IMarketLiquidityRewards, Initializable {\n address immutable tellerV2;\n address immutable marketRegistry;\n address immutable collateralManager;\n\n uint256 allocationCount;\n\n //allocationId => rewardAllocation\n mapping(uint256 => RewardAllocation) public allocatedRewards;\n\n //bidId => allocationId => rewardWasClaimed\n mapping(uint256 => mapping(uint256 => bool)) public rewardClaimedForBid;\n\n modifier onlyMarketOwner(uint256 _marketId) {\n require(\n msg.sender ==\n IMarketRegistry(marketRegistry).getMarketOwner(_marketId),\n \"Only market owner can call this function.\"\n );\n _;\n }\n\n event CreatedAllocation(\n uint256 allocationId,\n address allocator,\n uint256 marketId\n );\n\n event UpdatedAllocation(uint256 allocationId);\n\n event IncreasedAllocation(uint256 allocationId, uint256 amount);\n\n event DecreasedAllocation(uint256 allocationId, uint256 amount);\n\n event DeletedAllocation(uint256 allocationId);\n\n event ClaimedRewards(\n uint256 allocationId,\n uint256 bidId,\n address recipient,\n uint256 amount\n );\n\n constructor(\n address _tellerV2,\n address _marketRegistry,\n address _collateralManager\n ) {\n tellerV2 = _tellerV2;\n marketRegistry = _marketRegistry;\n collateralManager = _collateralManager;\n }\n\n function initialize() external initializer {}\n\n /**\n * @notice Creates a new token allocation and transfers the token amount into escrow in this contract\n * @param _allocation - The RewardAllocation struct data to create\n * @return allocationId_\n */\n function allocateRewards(RewardAllocation calldata _allocation)\n public\n virtual\n returns (uint256 allocationId_)\n {\n allocationId_ = allocationCount++;\n\n require(\n _allocation.allocator == msg.sender,\n \"Invalid allocator address\"\n );\n\n IERC20Upgradeable(_allocation.rewardTokenAddress).transferFrom(\n msg.sender,\n address(this),\n _allocation.rewardTokenAmount\n );\n\n allocatedRewards[allocationId_] = _allocation;\n\n emit CreatedAllocation(\n allocationId_,\n _allocation.allocator,\n _allocation.marketId\n );\n }\n\n /**\n * @notice Allows the allocator to update properties of an allocation\n * @param _allocationId - The id for the allocation\n * @param _minimumCollateralPerPrincipalAmount - The required collateralization ratio\n * @param _rewardPerLoanPrincipalAmount - The reward to give per principal amount\n * @param _bidStartTimeMin - The block timestamp that loans must have been accepted after to claim rewards\n * @param _bidStartTimeMax - The block timestamp that loans must have been accepted before to claim rewards\n */\n function updateAllocation(\n uint256 _allocationId,\n uint256 _minimumCollateralPerPrincipalAmount,\n uint256 _rewardPerLoanPrincipalAmount,\n uint32 _bidStartTimeMin,\n uint32 _bidStartTimeMax\n ) public virtual {\n RewardAllocation storage allocation = allocatedRewards[_allocationId];\n\n require(\n msg.sender == allocation.allocator,\n \"Only the allocator can update allocation rewards.\"\n );\n\n allocation\n .minimumCollateralPerPrincipalAmount = _minimumCollateralPerPrincipalAmount;\n allocation.rewardPerLoanPrincipalAmount = _rewardPerLoanPrincipalAmount;\n allocation.bidStartTimeMin = _bidStartTimeMin;\n allocation.bidStartTimeMax = _bidStartTimeMax;\n\n emit UpdatedAllocation(_allocationId);\n }\n\n /**\n * @notice Allows anyone to add tokens to an allocation\n * @param _allocationId - The id for the allocation\n * @param _tokenAmount - The amount of tokens to add\n */\n function increaseAllocationAmount(\n uint256 _allocationId,\n uint256 _tokenAmount\n ) public virtual {\n IERC20Upgradeable(allocatedRewards[_allocationId].rewardTokenAddress)\n .transferFrom(msg.sender, address(this), _tokenAmount);\n allocatedRewards[_allocationId].rewardTokenAmount += _tokenAmount;\n\n emit IncreasedAllocation(_allocationId, _tokenAmount);\n }\n\n /**\n * @notice Allows the allocator to withdraw some or all of the funds within an allocation\n * @param _allocationId - The id for the allocation\n * @param _tokenAmount - The amount of tokens to withdraw\n */\n function deallocateRewards(uint256 _allocationId, uint256 _tokenAmount)\n public\n virtual\n {\n require(\n msg.sender == allocatedRewards[_allocationId].allocator,\n \"Only the allocator can deallocate rewards.\"\n );\n\n if (_tokenAmount > allocatedRewards[_allocationId].rewardTokenAmount) {\n _tokenAmount = allocatedRewards[_allocationId].rewardTokenAmount;\n }\n\n //subtract amount reward before transfer\n _decrementAllocatedAmount(_allocationId, _tokenAmount);\n\n IERC20Upgradeable(allocatedRewards[_allocationId].rewardTokenAddress)\n .transfer(msg.sender, _tokenAmount);\n\n if (allocatedRewards[_allocationId].rewardTokenAmount == 0) {\n delete allocatedRewards[_allocationId];\n\n emit DeletedAllocation(_allocationId);\n } else {\n emit DecreasedAllocation(_allocationId, _tokenAmount);\n }\n }\n\n /**\n * @notice Allows a borrower or lender to withdraw the allocated ERC20 reward for their loan\n * @param _allocationId - The id for the reward allocation\n * @param _bidId - The id for the loan. Each loan only grants one reward per allocation.\n */\n function claimRewards(uint256 _allocationId, uint256 _bidId)\n external\n virtual\n {\n RewardAllocation storage allocatedReward = allocatedRewards[\n _allocationId\n ];\n\n require(\n !rewardClaimedForBid[_bidId][_allocationId],\n \"reward already claimed\"\n );\n rewardClaimedForBid[_bidId][_allocationId] = true; // leave this here to defend against re-entrancy\n\n (\n address borrower,\n address lender,\n uint256 marketId,\n address principalTokenAddress,\n uint256 principalAmount,\n uint32 acceptedTimestamp,\n BidState bidState\n ) = ITellerV2(tellerV2).getLoanSummary(_bidId);\n\n address collateralTokenAddress = allocatedReward\n .requiredCollateralTokenAddress;\n\n //require that the loan was started in the correct timeframe\n _verifyLoanStartTime(\n acceptedTimestamp,\n allocatedReward.bidStartTimeMin,\n allocatedReward.bidStartTimeMax\n );\n\n if (collateralTokenAddress != address(0)) {\n uint256 collateralAmount = ICollateralManager(collateralManager)\n .getCollateralAmount(_bidId, collateralTokenAddress);\n\n //require collateral amount\n _verifyCollateralAmount(\n collateralTokenAddress,\n collateralAmount,\n principalTokenAddress,\n principalAmount,\n allocatedReward.minimumCollateralPerPrincipalAmount\n );\n }\n\n _verifyExpectedTokenAddress(\n principalTokenAddress,\n allocatedReward.requiredPrincipalTokenAddress\n );\n\n _verifyExpectedTokenAddress(\n collateralTokenAddress,\n allocatedReward.requiredCollateralTokenAddress\n );\n\n require(\n marketId == allocatedRewards[_allocationId].marketId,\n \"MarketId mismatch for allocation\"\n );\n\n uint256 principalTokenDecimals = IERC20MetadataUpgradeable(\n principalTokenAddress\n ).decimals();\n\n address rewardRecipient = _verifyAndReturnRewardRecipient(\n allocatedReward.allocationStrategy,\n bidState,\n borrower,\n lender\n );\n\n uint256 amountToReward = _calculateRewardAmount(\n principalAmount,\n principalTokenDecimals,\n allocatedReward.rewardPerLoanPrincipalAmount\n );\n\n _decrementAllocatedAmount(_allocationId, amountToReward);\n\n //transfer tokens reward to the msgsender\n IERC20Upgradeable(allocatedRewards[_allocationId].rewardTokenAddress)\n .transfer(rewardRecipient, amountToReward);\n\n emit ClaimedRewards(\n _allocationId,\n _bidId,\n rewardRecipient,\n amountToReward\n );\n }\n\n /**\n * @notice Verifies that the bid state is appropriate for claiming rewards based on the allocation strategy and then returns the address of the reward recipient(borrower or lender)\n * @param _strategy - The strategy for the reward allocation.\n * @param _bidState - The bid state of the loan.\n * @param _borrower - The borrower of the loan.\n * @param _lender - The lender of the loan.\n * @return rewardRecipient_ The address that will receive the rewards. Either the borrower or lender.\n */\n function _verifyAndReturnRewardRecipient(\n AllocationStrategy _strategy,\n BidState _bidState,\n address _borrower,\n address _lender\n ) internal virtual returns (address rewardRecipient_) {\n if (_strategy == AllocationStrategy.BORROWER) {\n require(_bidState == BidState.PAID, \"Invalid bid state for loan.\");\n\n rewardRecipient_ = _borrower;\n } else if (_strategy == AllocationStrategy.LENDER) {\n //Loan must have been accepted in the past\n require(\n _bidState >= BidState.ACCEPTED,\n \"Invalid bid state for loan.\"\n );\n\n rewardRecipient_ = _lender;\n } else {\n revert(\"Unknown allocation strategy\");\n }\n }\n\n /**\n * @notice Decrements the amount allocated to keep track of tokens in escrow\n * @param _allocationId - The id for the allocation to decrement\n * @param _amount - The amount of ERC20 to decrement\n */\n function _decrementAllocatedAmount(uint256 _allocationId, uint256 _amount)\n internal\n {\n allocatedRewards[_allocationId].rewardTokenAmount -= _amount;\n }\n\n /**\n * @notice Calculates the reward to claim for the allocation\n * @param _loanPrincipal - The amount of principal for the loan for which to reward\n * @param _principalTokenDecimals - The number of decimals of the principal token\n * @param _rewardPerLoanPrincipalAmount - The amount of reward per loan principal amount, expanded by the principal token decimals\n * @return The amount of ERC20 to reward\n */\n function _calculateRewardAmount(\n uint256 _loanPrincipal,\n uint256 _principalTokenDecimals,\n uint256 _rewardPerLoanPrincipalAmount\n ) internal view returns (uint256) {\n return\n MathUpgradeable.mulDiv(\n _loanPrincipal,\n _rewardPerLoanPrincipalAmount, //expanded by principal token decimals\n 10**_principalTokenDecimals\n );\n }\n\n /**\n * @notice Verifies that the collateral ratio for the loan was sufficient based on _minimumCollateralPerPrincipalAmount of the allocation\n * @param _collateralTokenAddress - The contract address for the collateral token\n * @param _collateralAmount - The number of decimals of the collateral token\n * @param _principalTokenAddress - The contract address for the principal token\n * @param _principalAmount - The number of decimals of the principal token\n * @param _minimumCollateralPerPrincipalAmount - The amount of collateral required per principal amount. Expanded by the principal token decimals and collateral token decimals.\n */\n function _verifyCollateralAmount(\n address _collateralTokenAddress,\n uint256 _collateralAmount,\n address _principalTokenAddress,\n uint256 _principalAmount,\n uint256 _minimumCollateralPerPrincipalAmount\n ) internal virtual {\n uint256 principalTokenDecimals = IERC20MetadataUpgradeable(\n _principalTokenAddress\n ).decimals();\n\n uint256 collateralTokenDecimals = IERC20MetadataUpgradeable(\n _collateralTokenAddress\n ).decimals();\n\n uint256 minCollateral = _requiredCollateralAmount(\n _principalAmount,\n principalTokenDecimals,\n collateralTokenDecimals,\n _minimumCollateralPerPrincipalAmount\n );\n\n require(\n _collateralAmount >= minCollateral,\n \"Loan does not meet minimum collateralization ratio.\"\n );\n }\n\n /**\n * @notice Calculates the minimum amount of collateral the loan requires based on principal amount\n * @param _principalAmount - The number of decimals of the principal token\n * @param _principalTokenDecimals - The number of decimals of the principal token\n * @param _collateralTokenDecimals - The number of decimals of the collateral token\n * @param _minimumCollateralPerPrincipalAmount - The amount of collateral required per principal amount. Expanded by the principal token decimals and collateral token decimals.\n */\n function _requiredCollateralAmount(\n uint256 _principalAmount,\n uint256 _principalTokenDecimals,\n uint256 _collateralTokenDecimals,\n uint256 _minimumCollateralPerPrincipalAmount\n ) internal view virtual returns (uint256) {\n return\n MathUpgradeable.mulDiv(\n _principalAmount,\n _minimumCollateralPerPrincipalAmount, //expanded by principal token decimals and collateral token decimals\n 10**(_principalTokenDecimals + _collateralTokenDecimals)\n );\n }\n\n /**\n * @notice Verifies that the loan start time is within the bounds set by the allocation requirements\n * @param _loanStartTime - The timestamp when the loan was accepted\n * @param _minStartTime - The minimum time required, after which the loan must have been accepted\n * @param _maxStartTime - The maximum time required, before which the loan must have been accepted\n */\n function _verifyLoanStartTime(\n uint32 _loanStartTime,\n uint32 _minStartTime,\n uint32 _maxStartTime\n ) internal virtual {\n require(\n _minStartTime == 0 || _loanStartTime > _minStartTime,\n \"Loan was accepted before the min start time.\"\n );\n require(\n _maxStartTime == 0 || _loanStartTime < _maxStartTime,\n \"Loan was accepted after the max start time.\"\n );\n }\n\n /**\n * @notice Verifies that the loan principal token address is per the requirements of the allocation\n * @param _loanTokenAddress - The contract address of the token\n * @param _expectedTokenAddress - The expected contract address per the allocation\n */\n function _verifyExpectedTokenAddress(\n address _loanTokenAddress,\n address _expectedTokenAddress\n ) internal virtual {\n require(\n _expectedTokenAddress == address(0) ||\n _loanTokenAddress == _expectedTokenAddress,\n \"Invalid expected token address.\"\n );\n }\n}\n" @@ -145,27 +154,33 @@ "contracts/interfaces/IMarketLiquidityRewards.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IMarketLiquidityRewards {\n struct RewardAllocation {\n address allocator;\n address rewardTokenAddress;\n uint256 rewardTokenAmount;\n uint256 marketId;\n //requirements for loan\n address requiredPrincipalTokenAddress; //0 for any\n address requiredCollateralTokenAddress; //0 for any -- could be an enumerable set?\n uint256 minimumCollateralPerPrincipalAmount;\n uint256 rewardPerLoanPrincipalAmount;\n uint32 bidStartTimeMin;\n uint32 bidStartTimeMax;\n AllocationStrategy allocationStrategy;\n }\n\n enum AllocationStrategy {\n BORROWER,\n LENDER\n }\n\n function allocateRewards(RewardAllocation calldata _allocation)\n external\n returns (uint256 allocationId_);\n\n function increaseAllocationAmount(\n uint256 _allocationId,\n uint256 _tokenAmount\n ) external;\n\n function deallocateRewards(uint256 _allocationId, uint256 _amount) external;\n\n function claimRewards(uint256 _allocationId, uint256 _bidId) external;\n\n function rewardClaimedForBid(uint256 _bidId, uint256 _allocationId)\n external\n view\n returns (bool);\n\n function initialize() external;\n}\n" }, - "contracts/mock/TellerV2SolMock.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"../TellerV2.sol\";\nimport \"../interfaces/ITellerV2.sol\";\nimport \"../TellerV2Context.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport { LoanDetails, Payment, BidState } from \"../TellerV2Storage.sol\";\n\n/*\nThis is only used for sol test so its named specifically to avoid being used for the typescript tests.\n*/\ncontract TellerV2SolMock is ITellerV2, TellerV2Storage {\n function setMarketRegistry(address _marketRegistry) public {\n marketRegistry = IMarketRegistry(_marketRegistry);\n }\n\n function getMarketRegistry() external view returns (IMarketRegistry) {\n return marketRegistry;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketId,\n uint256 _principal,\n uint32 _duration,\n uint16,\n string calldata,\n address _receiver\n ) public returns (uint256 bidId_) {\n bidId_ = bidId;\n\n Bid storage bid = bids[bidId];\n bid.borrower = msg.sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n bidId++;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public returns (uint256 bidId_) {}\n\n function repayLoanMinimum(uint256 _bidId) external {}\n\n function repayLoanFull(uint256 _bidId) external {}\n\n function repayLoan(uint256 _bidId, uint256 _amount) public {\n Bid storage bid = bids[_bidId];\n\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n msg.sender,\n address(this),\n _amount\n );\n }\n\n /*\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n function lenderAcceptBid(uint256 _bidId)\n public\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n Bid storage bid = bids[_bidId];\n\n bid.lender = msg.sender;\n\n //send tokens to caller\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n bid.lender,\n bid.receiver,\n bid.loanDetails.principal\n );\n //for the reciever\n\n return (0, bid.loanDetails.principal, 0);\n }\n\n function getBidState(uint256 _bidId) public view returns (BidState) {\n return bids[_bidId].state;\n }\n\n function getLoanDetails(uint256 _bidId)\n public\n view\n returns (LoanDetails memory)\n {\n return bids[_bidId].loanDetails;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n public\n view\n returns (uint256[] memory)\n {}\n\n function isLoanDefaulted(uint256 _bidId) public view returns (bool) {}\n\n function isLoanLiquidateable(uint256 _bidId) public view returns (bool) {}\n\n function isPaymentLate(uint256 _bidId) public view returns (bool) {}\n\n function getLoanBorrower(uint256 _bidId)\n external\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n function getLoanLender(uint256 _bidId)\n external\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function getLoanSummary(uint256 _bidId)\n external\n view\n returns (\n address borrower,\n address lender,\n uint256 marketId,\n address principalTokenAddress,\n uint256 principalAmount,\n uint32 acceptedTimestamp,\n BidState bidState\n )\n {\n Bid storage bid = bids[_bidId];\n\n borrower = bid.borrower;\n lender = bid.lender;\n marketId = bid.marketplaceId;\n principalTokenAddress = address(bid.loanDetails.lendingToken);\n principalAmount = bid.loanDetails.principal;\n acceptedTimestamp = bid.loanDetails.acceptedTimestamp;\n bidState = bid.state;\n }\n\n function setLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp) public {\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n}\n" + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "contracts/TellerV2MarketForwarder.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\n\nimport \"./interfaces/IMarketRegistry.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\n\n/**\n * @dev Simple helper contract to forward an encoded function call to the TellerV2 contract. See {TellerV2Context}\n */\nabstract contract TellerV2MarketForwarder is Initializable, ContextUpgradeable {\n using AddressUpgradeable for address;\n\n address public immutable _tellerV2;\n address public immutable _marketRegistry;\n\n struct CreateLoanArgs {\n uint256 marketId;\n address lendingToken;\n uint256 principal;\n uint32 duration;\n uint16 interestRate;\n string metadataURI;\n address recipient;\n }\n\n constructor(address _protocolAddress, address _marketRegistryAddress) {\n _tellerV2 = _protocolAddress;\n _marketRegistry = _marketRegistryAddress;\n }\n\n function getTellerV2() public view returns (address) {\n return _tellerV2;\n }\n\n function getMarketRegistry() public view returns (address) {\n return _marketRegistry;\n }\n\n function getTellerV2MarketOwner(uint256 marketId) public returns (address) {\n return IMarketRegistry(getMarketRegistry()).getMarketOwner(marketId);\n }\n\n /**\n * @dev Performs function call to the TellerV2 contract by appending an address to the calldata.\n * @param _data The encoded function calldata on TellerV2.\n * @param _msgSender The address that should be treated as the underlying function caller.\n * @return The encoded response from the called function.\n *\n * Requirements:\n * - The {_msgSender} address must set an approval on TellerV2 for this forwarder contract __before__ making this call.\n */\n function _forwardCall(bytes memory _data, address _msgSender)\n internal\n returns (bytes memory)\n {\n return\n address(_tellerV2).functionCall(\n abi.encodePacked(_data, _msgSender)\n );\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBid(\n CreateLoanArgs memory _createLoanArgs,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address)\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Creates a new loan using the TellerV2 lending protocol.\n * @param _createLoanArgs Details describing the loan agreement.]\n * @param _borrower The borrower address for the new loan.\n */\n function _submitBidWithCollateral(\n CreateLoanArgs memory _createLoanArgs,\n Collateral[] memory _collateralInfo,\n address _borrower\n ) internal virtual returns (uint256 bidId) {\n bytes memory responseData;\n\n responseData = _forwardCall(\n abi.encodeWithSignature(\n \"submitBid(address,uint256,uint256,uint32,uint16,string,address,(uint8,uint256,uint256,address)[])\",\n _createLoanArgs.lendingToken,\n _createLoanArgs.marketId,\n _createLoanArgs.principal,\n _createLoanArgs.duration,\n _createLoanArgs.interestRate,\n _createLoanArgs.metadataURI,\n _createLoanArgs.recipient,\n _collateralInfo\n ),\n _borrower\n );\n\n return abi.decode(responseData, (uint256));\n }\n\n /**\n * @notice Accepts a new loan using the TellerV2 lending protocol.\n * @param _bidId The id of the new loan.\n * @param _lender The address of the lender who will provide funds for the new loan.\n */\n function _acceptBid(uint256 _bidId, address _lender)\n internal\n virtual\n returns (bool)\n {\n // Approve the borrower's loan\n _forwardCall(\n abi.encodeWithSelector(ITellerV2.lenderAcceptBid.selector, _bidId),\n _lender\n );\n\n return true;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" }, "contracts/TellerV2.sol": { "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./ProtocolFee.sol\";\nimport \"./TellerV2Storage.sol\";\nimport \"./TellerV2Context.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/IMarketRegistry.sol\";\nimport \"./interfaces/IReputationManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport { Collateral } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\nimport { BokkyPooBahsDateTimeLibrary as BPBDTL } from \"./libraries/DateTimeLib.sol\";\nimport { V2Calculations, PaymentCycleType } from \"./libraries/V2Calculations.sol\";\n\n/* Errors */\n/**\n * @notice This error is reverted when the action isn't allowed\n * @param bidId The id of the bid.\n * @param action The action string (i.e: 'repayLoan', 'cancelBid', 'etc)\n * @param message The message string to return to the user explaining why the tx was reverted\n */\nerror ActionNotAllowed(uint256 bidId, string action, string message);\n\n/**\n * @notice This error is reverted when repayment amount is less than the required minimum\n * @param bidId The id of the bid the borrower is attempting to repay.\n * @param payment The payment made by the borrower\n * @param minimumOwed The minimum owed value\n */\nerror PaymentNotMinimum(uint256 bidId, uint256 payment, uint256 minimumOwed);\n\ncontract TellerV2 is\n ITellerV2,\n OwnableUpgradeable,\n ProtocolFee,\n PausableUpgradeable,\n TellerV2Storage,\n TellerV2Context\n{\n using Address for address;\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /** Events */\n\n /**\n * @notice This event is emitted when a new bid is submitted.\n * @param bidId The id of the bid submitted.\n * @param borrower The address of the bid borrower.\n * @param metadataURI URI for additional bid information as part of loan bid.\n */\n event SubmittedBid(\n uint256 indexed bidId,\n address indexed borrower,\n address receiver,\n bytes32 indexed metadataURI\n );\n\n /**\n * @notice This event is emitted when a bid has been accepted by a lender.\n * @param bidId The id of the bid accepted.\n * @param lender The address of the accepted bid lender.\n */\n event AcceptedBid(uint256 indexed bidId, address indexed lender);\n\n /**\n * @notice This event is emitted when a previously submitted bid has been cancelled.\n * @param bidId The id of the cancelled bid.\n */\n event CancelledBid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when market owner has cancelled a pending bid in their market.\n * @param bidId The id of the bid funded.\n *\n * Note: The `CancelledBid` event will also be emitted.\n */\n event MarketOwnerCancelledBid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a payment is made towards an active loan.\n * @param bidId The id of the bid/loan to which the payment was made.\n */\n event LoanRepayment(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a loan has been fully repaid.\n * @param bidId The id of the bid/loan which was repaid.\n */\n event LoanRepaid(uint256 indexed bidId);\n\n /**\n * @notice This event is emitted when a loan has been fully repaid.\n * @param bidId The id of the bid/loan which was repaid.\n */\n event LoanLiquidated(uint256 indexed bidId, address indexed liquidator);\n\n /**\n * @notice This event is emitted when a fee has been paid related to a bid.\n * @param bidId The id of the bid.\n * @param feeType The name of the fee being paid.\n * @param amount The amount of the fee being paid.\n */\n event FeePaid(\n uint256 indexed bidId,\n string indexed feeType,\n uint256 indexed amount\n );\n\n /** Modifiers */\n\n /**\n * @notice This modifier is used to check if the state of a bid is pending, before running an action.\n * @param _bidId The id of the bid to check the state for.\n * @param _action The desired action to run on the bid.\n */\n modifier pendingBid(uint256 _bidId, string memory _action) {\n if (bids[_bidId].state != BidState.PENDING) {\n revert ActionNotAllowed(_bidId, _action, \"Bid must be pending\");\n }\n\n _;\n }\n\n /**\n * @notice This modifier is used to check if the state of a loan has been accepted, before running an action.\n * @param _bidId The id of the bid to check the state for.\n * @param _action The desired action to run on the bid.\n */\n modifier acceptedLoan(uint256 _bidId, string memory _action) {\n if (bids[_bidId].state != BidState.ACCEPTED) {\n revert ActionNotAllowed(_bidId, _action, \"Loan must be accepted\");\n }\n\n _;\n }\n\n /** Constant Variables **/\n\n uint8 public constant CURRENT_CODE_VERSION = 9;\n\n uint32 public constant LIQUIDATION_DELAY = 86400; //ONE DAY IN SECONDS\n\n /** Constructor **/\n\n constructor(address trustedForwarder) TellerV2Context(trustedForwarder) {}\n\n /** External Functions **/\n\n /**\n * @notice Initializes the proxy.\n * @param _protocolFee The fee collected by the protocol for loan processing.\n * @param _marketRegistry The address of the market registry contract for the protocol.\n * @param _reputationManager The address of the reputation manager contract.\n * @param _lenderCommitmentForwarder The address of the lender commitment forwarder contract.\n * @param _collateralManager The address of the collateral manager contracts.\n * @param _lenderManager The address of the lender manager contract for loans on the protocol.\n */\n function initialize(\n uint16 _protocolFee,\n address _marketRegistry,\n address _reputationManager,\n address _lenderCommitmentForwarder,\n address _collateralManager,\n address _lenderManager\n ) external initializer {\n __ProtocolFee_init(_protocolFee);\n\n __Pausable_init();\n\n require(\n _lenderCommitmentForwarder.isContract(),\n \"LenderCommitmentForwarder must be a contract\"\n );\n lenderCommitmentForwarder = _lenderCommitmentForwarder;\n\n require(\n _marketRegistry.isContract(),\n \"MarketRegistry must be a contract\"\n );\n marketRegistry = IMarketRegistry(_marketRegistry);\n\n require(\n _reputationManager.isContract(),\n \"ReputationManager must be a contract\"\n );\n reputationManager = IReputationManager(_reputationManager);\n\n require(\n _collateralManager.isContract(),\n \"CollateralManager must be a contract\"\n );\n collateralManager = ICollateralManager(_collateralManager);\n\n _setLenderManager(_lenderManager);\n }\n\n function setLenderManager(address _lenderManager)\n external\n reinitializer(8)\n onlyOwner\n {\n _setLenderManager(_lenderManager);\n }\n\n function _setLenderManager(address _lenderManager)\n internal\n onlyInitializing\n {\n require(\n _lenderManager.isContract(),\n \"LenderManager must be a contract\"\n );\n lenderManager = ILenderManager(_lenderManager);\n }\n\n /**\n * @notice Gets the metadataURI for a bidId.\n * @param _bidId The id of the bid to return the metadataURI for\n * @return metadataURI_ The metadataURI for the bid, as a string.\n */\n function getMetadataURI(uint256 _bidId)\n public\n view\n returns (string memory metadataURI_)\n {\n // Check uri mapping first\n metadataURI_ = uris[_bidId];\n // If the URI is not present in the mapping\n if (\n keccak256(abi.encodePacked(metadataURI_)) ==\n 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 // hardcoded constant of keccak256('')\n ) {\n // Return depreciated bytes32 uri as a string\n uint256 convertedURI = uint256(bids[_bidId]._metadataURI);\n metadataURI_ = StringsUpgradeable.toHexString(convertedURI, 32);\n }\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol to set a new reputation manager contract.\n * @param _reputationManager The new contract address.\n */\n function setReputationManager(address _reputationManager) public onlyOwner {\n reputationManager = IReputationManager(_reputationManager);\n }\n\n /**\n * @notice Function for a borrower to create a bid for a loan without Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) public override whenNotPaused returns (uint256 bidId_) {\n bidId_ = _submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n }\n\n /**\n * @notice Function for a borrower to create a bid for a loan with Collateral.\n * @param _lendingToken The lending token asset requested to be borrowed.\n * @param _marketplaceId The unique id of the marketplace for the bid.\n * @param _principal The principal amount of the loan bid.\n * @param _duration The recurrent length of time before which a payment is due.\n * @param _APR The proposed interest rate for the loan bid.\n * @param _metadataURI The URI for additional borrower loan information as part of loan bid.\n * @param _receiver The address where the loan amount will be sent to.\n * @param _collateralInfo Additional information about the collateral asset.\n */\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public override whenNotPaused returns (uint256 bidId_) {\n bidId_ = _submitBid(\n _lendingToken,\n _marketplaceId,\n _principal,\n _duration,\n _APR,\n _metadataURI,\n _receiver\n );\n\n bool validation = collateralManager.commitCollateral(\n bidId_,\n _collateralInfo\n );\n\n require(\n validation == true,\n \"Collateral balance could not be validated\"\n );\n }\n\n function _submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver\n ) internal returns (uint256 bidId_) {\n address sender = _msgSenderForMarket(_marketplaceId);\n (bool isVerified, ) = marketRegistry.isVerifiedBorrower(\n _marketplaceId,\n sender\n );\n require(isVerified, \"Not verified borrower\");\n require(\n !marketRegistry.isMarketClosed(_marketplaceId),\n \"Market is closed\"\n );\n\n // Set response bid ID.\n bidId_ = bidId;\n\n // Create and store our bid into the mapping\n Bid storage bid = bids[bidId];\n bid.borrower = sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketplaceId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n // Set payment cycle type based on market setting (custom or monthly)\n (bid.terms.paymentCycle, bidPaymentCycleType[bidId]) = marketRegistry\n .getPaymentCycle(_marketplaceId);\n\n bid.terms.APR = _APR;\n\n bidDefaultDuration[bidId] = marketRegistry.getPaymentDefaultDuration(\n _marketplaceId\n );\n\n bidExpirationTime[bidId] = marketRegistry.getBidExpirationTime(\n _marketplaceId\n );\n\n bid.paymentType = marketRegistry.getPaymentType(_marketplaceId);\n\n bid.terms.paymentCycleAmount = V2Calculations\n .calculatePaymentCycleAmount(\n bid.paymentType,\n bidPaymentCycleType[bidId],\n _principal,\n _duration,\n bid.terms.paymentCycle,\n _APR\n );\n\n uris[bidId] = _metadataURI;\n bid.state = BidState.PENDING;\n\n emit SubmittedBid(\n bidId,\n bid.borrower,\n bid.receiver,\n keccak256(abi.encodePacked(_metadataURI))\n );\n\n // Store bid inside borrower bids mapping\n borrowerBids[bid.borrower].push(bidId);\n\n // Increment bid id counter\n bidId++;\n }\n\n /**\n * @notice Function for a borrower to cancel their pending bid.\n * @param _bidId The id of the bid to cancel.\n */\n function cancelBid(uint256 _bidId) external {\n if (\n _msgSenderForMarket(bids[_bidId].marketplaceId) !=\n bids[_bidId].borrower\n ) {\n revert ActionNotAllowed({\n bidId: _bidId,\n action: \"cancelBid\",\n message: \"Only the bid owner can cancel!\"\n });\n }\n _cancelBid(_bidId);\n }\n\n /**\n * @notice Function for a market owner to cancel a bid in the market.\n * @param _bidId The id of the bid to cancel.\n */\n function marketOwnerCancelBid(uint256 _bidId) external {\n if (\n _msgSender() !=\n marketRegistry.getMarketOwner(bids[_bidId].marketplaceId)\n ) {\n revert ActionNotAllowed({\n bidId: _bidId,\n action: \"marketOwnerCancelBid\",\n message: \"Only the market owner can cancel!\"\n });\n }\n _cancelBid(_bidId);\n emit MarketOwnerCancelledBid(_bidId);\n }\n\n /**\n * @notice Function for users to cancel a bid.\n * @param _bidId The id of the bid to be cancelled.\n */\n function _cancelBid(uint256 _bidId)\n internal\n pendingBid(_bidId, \"cancelBid\")\n {\n // Set the bid state to CANCELLED\n bids[_bidId].state = BidState.CANCELLED;\n\n // Emit CancelledBid event\n emit CancelledBid(_bidId);\n }\n\n /**\n * @notice Function for a lender to accept a proposed loan bid.\n * @param _bidId The id of the loan bid to accept.\n */\n function lenderAcceptBid(uint256 _bidId)\n external\n override\n pendingBid(_bidId, \"lenderAcceptBid\")\n whenNotPaused\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n // Retrieve bid\n Bid storage bid = bids[_bidId];\n\n address sender = _msgSenderForMarket(bid.marketplaceId);\n\n (bool isVerified, ) = marketRegistry.isVerifiedLender(\n bid.marketplaceId,\n sender\n );\n require(isVerified, \"Not verified lender\");\n\n require(\n !marketRegistry.isMarketClosed(bid.marketplaceId),\n \"Market is closed\"\n );\n\n require(!isLoanExpired(_bidId), \"Bid has expired\");\n\n // Set timestamp\n bid.loanDetails.acceptedTimestamp = uint32(block.timestamp);\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\n\n // Mark borrower's request as accepted\n bid.state = BidState.ACCEPTED;\n\n // Declare the bid acceptor as the lender of the bid\n bid.lender = sender;\n\n // Tell the collateral manager to deploy the escrow and pull funds from the borrower if applicable\n collateralManager.deployAndDeposit(_bidId);\n\n // Transfer funds to borrower from the lender\n amountToProtocol = bid.loanDetails.principal.percent(protocolFee());\n amountToMarketplace = bid.loanDetails.principal.percent(\n marketRegistry.getMarketplaceFee(bid.marketplaceId)\n );\n amountToBorrower =\n bid.loanDetails.principal -\n amountToProtocol -\n amountToMarketplace;\n //transfer fee to protocol\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n owner(),\n amountToProtocol\n );\n\n //transfer fee to marketplace\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n marketRegistry.getMarketFeeRecipient(bid.marketplaceId),\n amountToMarketplace\n );\n\n //transfer funds to borrower\n bid.loanDetails.lendingToken.safeTransferFrom(\n sender,\n bid.receiver,\n amountToBorrower\n );\n\n // Record volume filled by lenders\n lenderVolumeFilled[address(bid.loanDetails.lendingToken)][sender] += bid\n .loanDetails\n .principal;\n totalVolumeFilled[address(bid.loanDetails.lendingToken)] += bid\n .loanDetails\n .principal;\n\n // Add borrower's active bid\n _borrowerBidsActive[bid.borrower].add(_bidId);\n\n // Emit AcceptedBid\n emit AcceptedBid(_bidId, sender);\n\n emit FeePaid(_bidId, \"protocol\", amountToProtocol);\n emit FeePaid(_bidId, \"marketplace\", amountToMarketplace);\n }\n\n function claimLoanNFT(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"claimLoanNFT\")\n whenNotPaused\n {\n // Retrieve bid\n Bid storage bid = bids[_bidId];\n\n address sender = _msgSenderForMarket(bid.marketplaceId);\n require(sender == bid.lender, \"only lender can claim NFT\");\n // mint an NFT with the lender manager\n lenderManager.registerLoan(_bidId, sender);\n // set lender address to the lender manager so we know to check the owner of the NFT for the true lender\n bid.lender = address(lenderManager);\n }\n\n /**\n * @notice Function for users to make the minimum amount due for an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanMinimum(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (\n uint256 owedPrincipal,\n uint256 duePrincipal,\n uint256 interest\n ) = V2Calculations.calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: duePrincipal, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n /**\n * @notice Function for users to repay an active loan in full.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function repayLoanFull(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: owedPrincipal, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n // function that the borrower (ideally) sends to repay the loan\n /**\n * @notice Function for users to make a payment towards an active loan.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _amount The amount of the payment.\n */\n function repayLoan(uint256 _bidId, uint256 _amount)\n external\n acceptedLoan(_bidId, \"repayLoan\")\n {\n (\n uint256 owedPrincipal,\n uint256 duePrincipal,\n uint256 interest\n ) = V2Calculations.calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n uint256 minimumOwed = duePrincipal + interest;\n\n // If amount is less than minimumOwed, we revert\n if (_amount < minimumOwed) {\n revert PaymentNotMinimum(_bidId, _amount, minimumOwed);\n }\n\n _repayLoan(\n _bidId,\n Payment({ principal: _amount - interest, interest: interest }),\n owedPrincipal + interest,\n true\n );\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol implement an emergency stop mechanism.\n */\n function pauseProtocol() public virtual onlyOwner whenNotPaused {\n _pause();\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol undo a previously implemented emergency stop.\n */\n function unpauseProtocol() public virtual onlyOwner whenPaused {\n _unpause();\n }\n\n //TODO: add an incentive for liquidator\n /**\n * @notice Function for users to liquidate a defaulted loan.\n * @param _bidId The id of the loan to make the payment towards.\n */\n function liquidateLoanFull(uint256 _bidId)\n external\n acceptedLoan(_bidId, \"liquidateLoan\")\n {\n require(isLoanLiquidateable(_bidId), \"Loan must be liquidateable.\");\n\n Bid storage bid = bids[_bidId];\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bid,\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n _repayLoan(\n _bidId,\n Payment({ principal: owedPrincipal, interest: interest }),\n owedPrincipal + interest,\n false\n );\n\n bid.state = BidState.LIQUIDATED;\n\n // If loan is backed by collateral, withdraw and send to the liquidator\n address liquidator = _msgSenderForMarket(bid.marketplaceId);\n collateralManager.liquidateCollateral(_bidId, liquidator);\n\n emit LoanLiquidated(_bidId, liquidator);\n }\n\n /**\n * @notice Internal function to make a loan payment.\n * @param _bidId The id of the loan to make the payment towards.\n * @param _payment The Payment struct with payments amounts towards principal and interest respectively.\n * @param _owedAmount The total amount owed on the loan.\n */\n function _repayLoan(\n uint256 _bidId,\n Payment memory _payment,\n uint256 _owedAmount,\n bool _shouldWithdrawCollateral\n ) internal {\n Bid storage bid = bids[_bidId];\n uint256 paymentAmount = _payment.principal + _payment.interest;\n\n RepMark mark = reputationManager.updateAccountReputation(\n bid.borrower,\n _bidId\n );\n\n // Check if we are sending a payment or amount remaining\n if (paymentAmount >= _owedAmount) {\n paymentAmount = _owedAmount;\n bid.state = BidState.PAID;\n\n // Remove borrower's active bid\n _borrowerBidsActive[bid.borrower].remove(_bidId);\n\n // If loan is is being liquidated and backed by collateral, withdraw and send to borrower\n if (_shouldWithdrawCollateral) {\n collateralManager.withdraw(_bidId);\n }\n\n emit LoanRepaid(_bidId);\n } else {\n emit LoanRepayment(_bidId);\n }\n\n address lender = getLoanLender(_bidId);\n\n // Send payment to the lender\n bid.loanDetails.lendingToken.safeTransferFrom(\n _msgSenderForMarket(bid.marketplaceId),\n lender,\n paymentAmount\n );\n\n // update our mappings\n bid.loanDetails.totalRepaid.principal += _payment.principal;\n bid.loanDetails.totalRepaid.interest += _payment.interest;\n bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);\n\n // If the loan is paid in full and has a mark, we should update the current reputation\n if (mark != RepMark.Good) {\n reputationManager.updateAccountReputation(bid.borrower, _bidId);\n }\n }\n\n /**\n * @notice Calculates the total amount owed for a bid.\n * @param _bidId The id of the loan bid to calculate the owed amount for.\n */\n function calculateAmountOwed(uint256 _bidId)\n public\n view\n returns (Payment memory owed)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return owed;\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n owed.principal = owedPrincipal;\n owed.interest = interest;\n }\n\n /**\n * @notice Calculates the total amount owed for a loan bid at a specific timestamp.\n * @param _bidId The id of the loan bid to calculate the owed amount for.\n * @param _timestamp The timestamp at which to calculate the loan owed amount at.\n */\n function calculateAmountOwed(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory owed)\n {\n Bid storage bid = bids[_bidId];\n if (\n bid.state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return owed;\n\n (uint256 owedPrincipal, , uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n owed.principal = owedPrincipal;\n owed.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Returns the next due date for a loan payment.\n * @param _bidId The id of the loan bid.\n */\n function calculateNextDueDate(uint256 _bidId)\n public\n view\n returns (uint32 dueDate_)\n {\n Bid storage bid = bids[_bidId];\n if (bids[_bidId].state != BidState.ACCEPTED) return dueDate_;\n\n uint32 lastRepaidTimestamp = lastRepaidTimestamp(_bidId);\n\n // Calculate due date if payment cycle is set to monthly\n if (bidPaymentCycleType[_bidId] == PaymentCycleType.Monthly) {\n // Calculate the cycle number the last repayment was made\n uint256 lastPaymentCycle = BPBDTL.diffMonths(\n bid.loanDetails.acceptedTimestamp,\n lastRepaidTimestamp\n );\n if (\n BPBDTL.getDay(lastRepaidTimestamp) >\n BPBDTL.getDay(bid.loanDetails.acceptedTimestamp)\n ) {\n lastPaymentCycle += 2;\n } else {\n lastPaymentCycle += 1;\n }\n\n dueDate_ = uint32(\n BPBDTL.addMonths(\n bid.loanDetails.acceptedTimestamp,\n lastPaymentCycle\n )\n );\n } else if (bidPaymentCycleType[_bidId] == PaymentCycleType.Seconds) {\n // Start with the original due date being 1 payment cycle since bid was accepted\n dueDate_ =\n bid.loanDetails.acceptedTimestamp +\n bid.terms.paymentCycle;\n // Calculate the cycle number the last repayment was made\n uint32 delta = lastRepaidTimestamp -\n bid.loanDetails.acceptedTimestamp;\n if (delta > 0) {\n uint32 repaymentCycle = uint32(\n Math.ceilDiv(delta, bid.terms.paymentCycle)\n );\n dueDate_ += (repaymentCycle * bid.terms.paymentCycle);\n }\n }\n\n uint32 endOfLoan = bid.loanDetails.acceptedTimestamp +\n bid.loanDetails.loanDuration;\n //if we are in the last payment cycle, the next due date is the end of loan duration\n if (dueDate_ > endOfLoan) {\n dueDate_ = endOfLoan;\n }\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n */\n function isPaymentLate(uint256 _bidId) public view override returns (bool) {\n if (bids[_bidId].state != BidState.ACCEPTED) return false;\n return uint32(block.timestamp) > calculateNextDueDate(_bidId);\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n * @return bool True if the loan is defaulted.\n */\n function isLoanDefaulted(uint256 _bidId)\n public\n view\n override\n returns (bool)\n {\n return _canLiquidateLoan(_bidId, 0);\n }\n\n /**\n * @notice Checks to see if a loan was delinquent for longer than liquidation delay.\n * @param _bidId The id of the loan bid to check for.\n * @return bool True if the loan is liquidateable.\n */\n function isLoanLiquidateable(uint256 _bidId)\n public\n view\n override\n returns (bool)\n {\n return _canLiquidateLoan(_bidId, LIQUIDATION_DELAY);\n }\n\n /**\n * @notice Checks to see if a borrower is delinquent.\n * @param _bidId The id of the loan bid to check for.\n * @param _liquidationDelay Amount of additional seconds after a loan defaulted to allow a liquidation.\n * @return bool True if the loan is liquidateable.\n */\n function _canLiquidateLoan(uint256 _bidId, uint32 _liquidationDelay)\n internal\n view\n returns (bool)\n {\n Bid storage bid = bids[_bidId];\n\n // Make sure loan cannot be liquidated if it is not active\n if (bid.state != BidState.ACCEPTED) return false;\n\n if (bidDefaultDuration[_bidId] == 0) return false;\n\n return (uint32(block.timestamp) -\n _liquidationDelay -\n lastRepaidTimestamp(_bidId) >\n bidDefaultDuration[_bidId]);\n }\n\n function getBidState(uint256 _bidId)\n external\n view\n override\n returns (BidState)\n {\n return bids[_bidId].state;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n external\n view\n override\n returns (uint256[] memory)\n {\n return _borrowerBidsActive[_borrower].values();\n }\n\n function getBorrowerLoanIds(address _borrower)\n external\n view\n returns (uint256[] memory)\n {\n return borrowerBids[_borrower];\n }\n\n /**\n * @notice Checks to see if a pending loan has expired so it is no longer able to be accepted.\n * @param _bidId The id of the loan bid to check for.\n */\n function isLoanExpired(uint256 _bidId) public view returns (bool) {\n Bid storage bid = bids[_bidId];\n\n if (bid.state != BidState.PENDING) return false;\n if (bidExpirationTime[_bidId] == 0) return false;\n\n return (uint32(block.timestamp) >\n bid.loanDetails.timestamp + bidExpirationTime[_bidId]);\n }\n\n /**\n * @notice Returns the last repaid timestamp for a loan.\n * @param _bidId The id of the loan bid to get the timestamp for.\n */\n function lastRepaidTimestamp(uint256 _bidId) public view returns (uint32) {\n return V2Calculations.lastRepaidTimestamp(bids[_bidId]);\n }\n\n /**\n * @notice Returns the borrower address for a given bid.\n * @param _bidId The id of the bid/loan to get the borrower for.\n * @return borrower_ The address of the borrower associated with the bid.\n */\n function getLoanBorrower(uint256 _bidId)\n public\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n /**\n * @notice Returns the lender address for a given bid. If the stored lender address is the `LenderManager` NFT address, return the `ownerOf` for the bid ID.\n * @param _bidId The id of the bid/loan to get the lender for.\n * @return lender_ The address of the lender associated with the bid.\n */\n function getLoanLender(uint256 _bidId)\n public\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n\n if (lender_ == address(lenderManager)) {\n return lenderManager.ownerOf(_bidId);\n }\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n function getLoanSummary(uint256 _bidId)\n external\n view\n returns (\n address borrower,\n address lender,\n uint256 marketId,\n address principalTokenAddress,\n uint256 principalAmount,\n uint32 acceptedTimestamp,\n BidState bidState\n )\n {\n Bid storage bid = bids[_bidId];\n\n borrower = bid.borrower;\n lender = bid.lender;\n marketId = bid.marketplaceId;\n principalTokenAddress = address(bid.loanDetails.lendingToken);\n principalAmount = bid.loanDetails.principal;\n acceptedTimestamp = bid.loanDetails.acceptedTimestamp;\n bidState = bid.state;\n }\n\n /** OpenZeppelin Override Functions **/\n\n function _msgSender()\n internal\n view\n virtual\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\n returns (address sender)\n {\n sender = ERC2771ContextUpgradeable._msgSender();\n }\n\n function _msgData()\n internal\n view\n virtual\n override(ERC2771ContextUpgradeable, ContextUpgradeable)\n returns (bytes calldata)\n {\n return ERC2771ContextUpgradeable._msgData();\n }\n}\n" }, - "contracts/TellerV2Context.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2Storage.sol\";\nimport \"./ERC2771ContextUpgradeable.sol\";\n\n/**\n * @dev This contract should not use any storage\n */\n\nabstract contract TellerV2Context is\n ERC2771ContextUpgradeable,\n TellerV2Storage\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n event TrustedMarketForwarderSet(\n uint256 indexed marketId,\n address forwarder,\n address sender\n );\n event MarketForwarderApproved(\n uint256 indexed marketId,\n address indexed forwarder,\n address sender\n );\n\n constructor(address trustedForwarder)\n ERC2771ContextUpgradeable(trustedForwarder)\n {}\n\n /**\n * @notice Checks if an address is a trusted forwarder contract for a given market.\n * @param _marketId An ID for a lending market.\n * @param _trustedMarketForwarder An address to check if is a trusted forwarder in the given market.\n * @return A boolean indicating the forwarder address is trusted in a market.\n */\n function isTrustedMarketForwarder(\n uint256 _marketId,\n address _trustedMarketForwarder\n ) public view returns (bool) {\n return\n _trustedMarketForwarders[_marketId] == _trustedMarketForwarder ||\n lenderCommitmentForwarder == _trustedMarketForwarder;\n }\n\n /**\n * @notice Checks if an account has approved a forwarder for a market.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n * @param _account The address to verify set an approval.\n * @return A boolean indicating if an approval was set.\n */\n function hasApprovedMarketForwarder(\n uint256 _marketId,\n address _forwarder,\n address _account\n ) public view returns (bool) {\n return\n isTrustedMarketForwarder(_marketId, _forwarder) &&\n _approvedForwarderSenders[_forwarder].contains(_account);\n }\n\n /**\n * @notice Sets a trusted forwarder for a lending market.\n * @notice The caller must owner the market given. See {MarketRegistry}\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n marketRegistry.getMarketOwner(_marketId) == _msgSender(),\n \"Caller must be the market owner\"\n );\n _trustedMarketForwarders[_marketId] = _forwarder;\n emit TrustedMarketForwarderSet(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Approves a forwarder contract to use their address as a sender for a specific market.\n * @notice The forwarder given must be trusted by the market given.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n isTrustedMarketForwarder(_marketId, _forwarder),\n \"Forwarder must be trusted by the market\"\n );\n _approvedForwarderSenders[_forwarder].add(_msgSender());\n emit MarketForwarderApproved(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Retrieves the function caller address by checking the appended calldata if the _actual_ caller is a trusted forwarder.\n * @param _marketId An ID for a lending market.\n * @return sender The address to use as the function caller.\n */\n function _msgSenderForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (address)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n address sender;\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n // Ensure the appended sender address approved the forwarder\n require(\n _approvedForwarderSenders[_msgSender()].contains(sender),\n \"Sender must approve market forwarder\"\n );\n return sender;\n }\n\n return _msgSender();\n }\n\n /**\n * @notice Retrieves the actual function calldata from a trusted forwarder call.\n * @param _marketId An ID for a lending market to verify if the caller is a trusted forwarder.\n * @return calldata The modified bytes array of the function calldata without the appended sender's address.\n */\n function _msgDataForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (bytes calldata)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n return msg.data[:msg.data.length - 20];\n } else {\n return _msgData();\n }\n }\n}\n" - }, "contracts/ProtocolFee.sol": { "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract ProtocolFee is OwnableUpgradeable {\n // Protocol fee set for loan processing.\n uint16 private _protocolFee;\n\n /**\n * @notice This event is emitted when the protocol fee has been updated.\n * @param newFee The new protocol fee set.\n * @param oldFee The previously set protocol fee.\n */\n event ProtocolFeeSet(uint16 newFee, uint16 oldFee);\n\n /**\n * @notice Initialized the protocol fee.\n * @param initFee The initial protocol fee to be set on the protocol.\n */\n function __ProtocolFee_init(uint16 initFee) internal onlyInitializing {\n __Ownable_init();\n __ProtocolFee_init_unchained(initFee);\n }\n\n function __ProtocolFee_init_unchained(uint16 initFee)\n internal\n onlyInitializing\n {\n setProtocolFee(initFee);\n }\n\n /**\n * @notice Returns the current protocol fee.\n */\n function protocolFee() public view virtual returns (uint16) {\n return _protocolFee;\n }\n\n /**\n * @notice Lets the DAO/owner of the protocol to set a new protocol fee.\n * @param newFee The new protocol fee to be set.\n */\n function setProtocolFee(uint16 newFee) public virtual onlyOwner {\n // Skip if the fee is the same\n if (newFee == _protocolFee) return;\n\n uint16 oldFee = _protocolFee;\n _protocolFee = newFee;\n emit ProtocolFeeSet(newFee, oldFee);\n }\n}\n" }, + "contracts/TellerV2Context.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2Storage.sol\";\nimport \"./ERC2771ContextUpgradeable.sol\";\n\n/**\n * @dev This contract should not use any storage\n */\n\nabstract contract TellerV2Context is\n ERC2771ContextUpgradeable,\n TellerV2Storage\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n\n event TrustedMarketForwarderSet(\n uint256 indexed marketId,\n address forwarder,\n address sender\n );\n event MarketForwarderApproved(\n uint256 indexed marketId,\n address indexed forwarder,\n address sender\n );\n\n constructor(address trustedForwarder)\n ERC2771ContextUpgradeable(trustedForwarder)\n {}\n\n /**\n * @notice Checks if an address is a trusted forwarder contract for a given market.\n * @param _marketId An ID for a lending market.\n * @param _trustedMarketForwarder An address to check if is a trusted forwarder in the given market.\n * @return A boolean indicating the forwarder address is trusted in a market.\n */\n function isTrustedMarketForwarder(\n uint256 _marketId,\n address _trustedMarketForwarder\n ) public view returns (bool) {\n return\n _trustedMarketForwarders[_marketId] == _trustedMarketForwarder ||\n lenderCommitmentForwarder == _trustedMarketForwarder;\n }\n\n /**\n * @notice Checks if an account has approved a forwarder for a market.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n * @param _account The address to verify set an approval.\n * @return A boolean indicating if an approval was set.\n */\n function hasApprovedMarketForwarder(\n uint256 _marketId,\n address _forwarder,\n address _account\n ) public view returns (bool) {\n return\n isTrustedMarketForwarder(_marketId, _forwarder) &&\n _approvedForwarderSenders[_forwarder].contains(_account);\n }\n\n /**\n * @notice Sets a trusted forwarder for a lending market.\n * @notice The caller must owner the market given. See {MarketRegistry}\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n marketRegistry.getMarketOwner(_marketId) == _msgSender(),\n \"Caller must be the market owner\"\n );\n _trustedMarketForwarders[_marketId] = _forwarder;\n emit TrustedMarketForwarderSet(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Approves a forwarder contract to use their address as a sender for a specific market.\n * @notice The forwarder given must be trusted by the market given.\n * @param _marketId An ID for a lending market.\n * @param _forwarder A forwarder contract address.\n */\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external\n {\n require(\n isTrustedMarketForwarder(_marketId, _forwarder),\n \"Forwarder must be trusted by the market\"\n );\n _approvedForwarderSenders[_forwarder].add(_msgSender());\n emit MarketForwarderApproved(_marketId, _forwarder, _msgSender());\n }\n\n /**\n * @notice Retrieves the function caller address by checking the appended calldata if the _actual_ caller is a trusted forwarder.\n * @param _marketId An ID for a lending market.\n * @return sender The address to use as the function caller.\n */\n function _msgSenderForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (address)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n address sender;\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n // Ensure the appended sender address approved the forwarder\n require(\n _approvedForwarderSenders[_msgSender()].contains(sender),\n \"Sender must approve market forwarder\"\n );\n return sender;\n }\n\n return _msgSender();\n }\n\n /**\n * @notice Retrieves the actual function calldata from a trusted forwarder call.\n * @param _marketId An ID for a lending market to verify if the caller is a trusted forwarder.\n * @return calldata The modified bytes array of the function calldata without the appended sender's address.\n */\n function _msgDataForMarket(uint256 _marketId)\n internal\n view\n virtual\n returns (bytes calldata)\n {\n if (isTrustedMarketForwarder(_marketId, _msgSender())) {\n return msg.data[:msg.data.length - 20];\n } else {\n return _msgData();\n }\n }\n}\n" + }, "contracts/libraries/DateTimeLib.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint constant SECONDS_PER_DAY = 24 * 60 * 60;\n uint constant SECONDS_PER_HOUR = 60 * 60;\n uint constant SECONDS_PER_MINUTE = 60;\n int constant OFFSET19700101 = 2440588;\n\n uint constant DOW_MON = 1;\n uint constant DOW_TUE = 2;\n uint constant DOW_WED = 3;\n uint constant DOW_THU = 4;\n uint constant DOW_FRI = 5;\n uint constant DOW_SAT = 6;\n uint constant DOW_SUN = 7;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(uint year, uint month, uint day)\n internal\n pure\n returns (uint _days)\n {\n require(year >= 1970);\n int _year = int(year);\n int _month = int(month);\n int _day = int(day);\n\n int __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n OFFSET19700101;\n\n _days = uint(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint _days)\n internal\n pure\n returns (uint year, uint month, uint day)\n {\n int __days = int(_days);\n\n int L = __days + 68569 + OFFSET19700101;\n int N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int _month = (80 * L) / 2447;\n int _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint(_year);\n month = uint(_month);\n day = uint(_day);\n }\n\n function timestampFromDate(uint year, uint month, uint day)\n internal\n pure\n returns (uint timestamp)\n {\n timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n ) internal pure returns (uint timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n hour *\n SECONDS_PER_HOUR +\n minute *\n SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint timestamp)\n internal\n pure\n returns (uint year, uint month, uint day)\n {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint timestamp)\n internal\n pure\n returns (\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n )\n {\n (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n uint secs = timestamp % SECONDS_PER_DAY;\n hour = secs / SECONDS_PER_HOUR;\n secs = secs % SECONDS_PER_HOUR;\n minute = secs / SECONDS_PER_MINUTE;\n second = secs % SECONDS_PER_MINUTE;\n }\n\n function isValidDate(uint year, uint month, uint day)\n internal\n pure\n returns (bool valid)\n {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint year,\n uint month,\n uint day,\n uint hour,\n uint minute,\n uint second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint timestamp) internal pure returns (bool leapYear) {\n (uint year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint year) internal pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= DOW_FRI;\n }\n\n function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;\n }\n\n function getDaysInMonth(uint timestamp)\n internal\n pure\n returns (uint daysInMonth)\n {\n (uint year, uint month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint year, uint month)\n internal\n pure\n returns (uint daysInMonth)\n {\n if (\n month == 1 ||\n month == 3 ||\n month == 5 ||\n month == 7 ||\n month == 8 ||\n month == 10 ||\n month == 12\n ) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint timestamp)\n internal\n pure\n returns (uint dayOfWeek)\n {\n uint _days = timestamp / SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint timestamp) internal pure returns (uint year) {\n (year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getMonth(uint timestamp) internal pure returns (uint month) {\n (, month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getDay(uint timestamp) internal pure returns (uint day) {\n (, , day) = _daysToDate(timestamp / SECONDS_PER_DAY);\n }\n\n function getHour(uint timestamp) internal pure returns (uint hour) {\n uint secs = timestamp % SECONDS_PER_DAY;\n hour = secs / SECONDS_PER_HOUR;\n }\n\n function getMinute(uint timestamp) internal pure returns (uint minute) {\n uint secs = timestamp % SECONDS_PER_HOUR;\n minute = secs / SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint timestamp) internal pure returns (uint second) {\n second = timestamp % SECONDS_PER_MINUTE;\n }\n\n function addYears(uint timestamp, uint _years)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n year += _years;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint timestamp, uint _months)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint timestamp, uint _days)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _days * SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint timestamp, uint _hours)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint timestamp, uint _minutes)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint timestamp, uint _seconds)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint timestamp, uint _years)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n year -= _years;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint timestamp, uint _months)\n internal\n pure\n returns (uint newTimestamp)\n {\n (uint year, uint month, uint day) = _daysToDate(\n timestamp / SECONDS_PER_DAY\n );\n uint yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp =\n _daysFromDate(year, month, day) *\n SECONDS_PER_DAY +\n (timestamp % SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint timestamp, uint _days)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _days * SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint timestamp, uint _hours)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint timestamp, uint _minutes)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint timestamp, uint _seconds)\n internal\n pure\n returns (uint newTimestamp)\n {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _years)\n {\n require(fromTimestamp <= toTimestamp);\n (uint fromYear, , ) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);\n (uint toYear, , ) = _daysToDate(toTimestamp / SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _months)\n {\n require(fromTimestamp <= toTimestamp);\n (uint fromYear, uint fromMonth, ) = _daysToDate(\n fromTimestamp / SECONDS_PER_DAY\n );\n (uint toYear, uint toMonth, ) = _daysToDate(\n toTimestamp / SECONDS_PER_DAY\n );\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _days)\n {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;\n }\n\n function diffHours(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _hours)\n {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _minutes)\n {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint fromTimestamp, uint toTimestamp)\n internal\n pure\n returns (uint _seconds)\n {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n" }, - "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = MathUpgradeable.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, MathUpgradeable.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" - }, "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" }, @@ -175,8 +190,71 @@ "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" }, - "contracts/TellerV2Mock.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2.sol\";\n\ncontract TellerV2Mock is TellerV2 {\n constructor(address trustedForwarder) TellerV2(trustedForwarder) {}\n\n function mockBid(Bid calldata _bid) external {\n bids[bidId] = _bid;\n borrowerBids[_msgSender()].push(bidId);\n bidId++;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId, uint32 _timestamp) external {\n require(_timestamp > 0, \"Accepted timestamp 0\");\n bids[_bidId].loanDetails.acceptedTimestamp = _timestamp;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId) external {\n bids[_bidId].loanDetails.acceptedTimestamp = uint32(block.timestamp);\n }\n\n function mockLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp)\n external\n {\n require(_timestamp > 0, \"Repaid timestamp 0\");\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n\n function setVersion(uint256 _version) public {\n version = _version;\n }\n}\n" + "contracts/mock/TellerV2SolMock.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"../TellerV2.sol\";\nimport \"../interfaces/ITellerV2.sol\";\nimport \"../TellerV2Context.sol\";\nimport { Collateral } from \"../interfaces/escrow/ICollateralEscrowV1.sol\";\nimport { LoanDetails, Payment, BidState } from \"../TellerV2Storage.sol\";\n\n/*\nThis is only used for sol test so its named specifically to avoid being used for the typescript tests.\n*/\ncontract TellerV2SolMock is ITellerV2, TellerV2Storage {\n function setMarketRegistry(address _marketRegistry) public {\n marketRegistry = IMarketRegistry(_marketRegistry);\n }\n\n function getMarketRegistry() external view returns (IMarketRegistry) {\n return marketRegistry;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketId,\n uint256 _principal,\n uint32 _duration,\n uint16,\n string calldata,\n address _receiver\n ) public returns (uint256 bidId_) {\n bidId_ = bidId;\n\n Bid storage bid = bids[bidId];\n bid.borrower = msg.sender;\n bid.receiver = _receiver != address(0) ? _receiver : bid.borrower;\n bid.marketplaceId = _marketId;\n bid.loanDetails.lendingToken = ERC20(_lendingToken);\n bid.loanDetails.principal = _principal;\n bid.loanDetails.loanDuration = _duration;\n bid.loanDetails.timestamp = uint32(block.timestamp);\n\n bidId++;\n }\n\n function submitBid(\n address _lendingToken,\n uint256 _marketplaceId,\n uint256 _principal,\n uint32 _duration,\n uint16 _APR,\n string calldata _metadataURI,\n address _receiver,\n Collateral[] calldata _collateralInfo\n ) public returns (uint256 bidId_) {}\n\n function repayLoanMinimum(uint256 _bidId) external {}\n\n function repayLoanFull(uint256 _bidId) external {}\n\n function repayLoan(uint256 _bidId, uint256 _amount) public {\n Bid storage bid = bids[_bidId];\n\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n msg.sender,\n address(this),\n _amount\n );\n }\n\n /*\n * @notice Calculates the minimum payment amount due for a loan.\n * @param _bidId The id of the loan bid to get the payment amount for.\n */\n function calculateAmountDue(uint256 _bidId)\n public\n view\n returns (Payment memory due)\n {\n if (bids[_bidId].state != BidState.ACCEPTED) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(\n bids[_bidId],\n block.timestamp,\n bidPaymentCycleType[_bidId]\n );\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n /**\n * @notice Calculates the minimum payment amount due for a loan at a specific timestamp.\n * @param _bidId The id of the loan bid to get the payment amount for.\n * @param _timestamp The timestamp at which to get the due payment at.\n */\n function calculateAmountDue(uint256 _bidId, uint256 _timestamp)\n public\n view\n returns (Payment memory due)\n {\n Bid storage bid = bids[_bidId];\n if (\n bids[_bidId].state != BidState.ACCEPTED ||\n bid.loanDetails.acceptedTimestamp >= _timestamp\n ) return due;\n\n (, uint256 duePrincipal, uint256 interest) = V2Calculations\n .calculateAmountOwed(bid, _timestamp, bidPaymentCycleType[_bidId]);\n due.principal = duePrincipal;\n due.interest = interest;\n }\n\n function lenderAcceptBid(uint256 _bidId)\n public\n returns (\n uint256 amountToProtocol,\n uint256 amountToMarketplace,\n uint256 amountToBorrower\n )\n {\n Bid storage bid = bids[_bidId];\n\n bid.lender = msg.sender;\n\n //send tokens to caller\n IERC20(bid.loanDetails.lendingToken).transferFrom(\n bid.lender,\n bid.receiver,\n bid.loanDetails.principal\n );\n //for the reciever\n\n return (0, bid.loanDetails.principal, 0);\n }\n\n function getBidState(uint256 _bidId) public view returns (BidState) {\n return bids[_bidId].state;\n }\n\n function getLoanDetails(uint256 _bidId)\n public\n view\n returns (LoanDetails memory)\n {\n return bids[_bidId].loanDetails;\n }\n\n function getBorrowerActiveLoanIds(address _borrower)\n public\n view\n returns (uint256[] memory)\n {}\n\n function isLoanDefaulted(uint256 _bidId) public view returns (bool) {}\n\n function isLoanLiquidateable(uint256 _bidId) public view returns (bool) {}\n\n function isPaymentLate(uint256 _bidId) public view returns (bool) {}\n\n function getLoanBorrower(uint256 _bidId)\n external\n view\n returns (address borrower_)\n {\n borrower_ = bids[_bidId].borrower;\n }\n\n function getLoanLender(uint256 _bidId)\n external\n view\n returns (address lender_)\n {\n lender_ = bids[_bidId].lender;\n }\n\n function getLoanMarketId(uint256 _bidId)\n external\n view\n returns (uint256 _marketId)\n {\n _marketId = bids[_bidId].marketplaceId;\n }\n\n function getLoanLendingToken(uint256 _bidId)\n external\n view\n returns (address token_)\n {\n token_ = address(bids[_bidId].loanDetails.lendingToken);\n }\n\n function getLoanSummary(uint256 _bidId)\n external\n view\n returns (\n address borrower,\n address lender,\n uint256 marketId,\n address principalTokenAddress,\n uint256 principalAmount,\n uint32 acceptedTimestamp,\n BidState bidState\n )\n {\n Bid storage bid = bids[_bidId];\n\n borrower = bid.borrower;\n lender = bid.lender;\n marketId = bid.marketplaceId;\n principalTokenAddress = address(bid.loanDetails.lendingToken);\n principalAmount = bid.loanDetails.principal;\n acceptedTimestamp = bid.loanDetails.acceptedTimestamp;\n bidState = bid.state;\n }\n\n function setLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp) public {\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n}\n" + }, + "contracts/mock/CollateralManagerMock.sol": { + "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/ICollateralManager.sol\";\n\ncontract CollateralManagerMock is ICollateralManager {\n function commitCollateral(\n uint256 _bidId,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validation_) {\n return true;\n }\n\n function commitCollateral(\n uint256 _bidId,\n Collateral calldata _collateralInfo\n ) external returns (bool validation_) {\n return true;\n }\n\n function checkBalances(\n address _borrowerAddress,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validated_, bool[] memory checks_) {\n validated_ = true;\n checks_ = new bool[](0);\n }\n\n /**\n * @notice Deploys a new collateral escrow.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function deployAndDeposit(uint256 _bidId) external {}\n\n /**\n * @notice Gets the address of a deployed escrow.\n * @notice _bidId The bidId to return the escrow for.\n * @return The address of the escrow.\n */\n function getEscrow(uint256 _bidId) external view returns (address) {\n return address(0);\n }\n\n /**\n * @notice Gets the collateral info for a given bid id.\n * @param _bidId The bidId to return the collateral info for.\n */\n function getCollateralInfo(uint256 _bidId)\n external\n view\n returns (Collateral[] memory collateral_)\n {\n collateral_ = new Collateral[](0);\n }\n\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\n external\n view\n returns (uint256 _amount)\n {\n return 500;\n }\n\n /**\n * @notice Withdraws deposited collateral from the created escrow of a bid.\n * @param _bidId The id of the bid to withdraw collateral for.\n */\n function withdraw(uint256 _bidId) external {}\n\n /**\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\n * @param _bidId The id of the associated bid.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function revalidateCollateral(uint256 _bidId) external returns (bool) {\n return true;\n }\n\n /**\n * @notice Sends the deposited collateral to a liquidator of a bid.\n * @notice Can only be called by the protocol.\n * @param _bidId The id of the liquidated bid.\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\n */\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\n external\n {}\n}\n" + }, + "contracts/LenderCommitmentForwarder.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"./TellerV2MarketForwarder.sol\";\n\n// Interfaces\nimport \"./interfaces/ICollateralManager.sol\";\n\nimport \"./interfaces/allowlist/IAllowlistManager.sol\";\nimport \"./interfaces/allowlist/IEnumerableSetAllowlist.sol\";\n\nimport \"./interfaces/ILenderCommitmentForwarder.sol\";\n\nimport { Collateral, CollateralType } from \"./interfaces/escrow/ICollateralEscrowV1.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n// Libraries\nimport { MathUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol\";\n\n\n\n\ncontract LenderCommitmentForwarder is TellerV2MarketForwarder, ILenderCommitmentForwarder {\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n\n enum CommitmentCollateralType {\n NONE, // no collateral required\n ERC20,\n ERC721,\n ERC1155,\n ERC721_ANY_ID,\n ERC1155_ANY_ID\n }\n\n /**\n * @notice Details about a lender's capital commitment.\n * @param maxPrincipal Amount of tokens being committed by the lender. Max amount that can be loaned.\n * @param expiration Expiration time in seconds, when the commitment expires.\n * @param maxDuration Length of time, in seconds that the lender's capital can be lent out for.\n * @param minInterestRate Minimum Annual percentage to be applied for loans using the lender's capital.\n * @param collateralTokenAddress The address for the token contract that must be used to provide collateral for loans for this commitment.\n * @param maxPrincipalPerCollateralAmount The amount of principal that can be used for a loan per each unit of collateral, expanded additionally by principal decimals.\n * @param collateralTokenType The type of asset of the collateralTokenAddress (ERC20, ERC721, or ERC1155).\n * @param lender The address of the lender for this commitment.\n * @param marketId The market id for this commitment.\n * @param principalTokenAddress The address for the token contract that will be used to provide principal for loans of this commitment.\n */\n struct Commitment {\n uint256 maxPrincipal;\n uint32 expiration;\n uint32 maxDuration;\n uint16 minInterestRate;\n address collateralTokenAddress;\n uint256 collateralTokenId;\n uint256 maxPrincipalPerCollateralAmount;\n CommitmentCollateralType collateralTokenType;\n address lender;\n uint256 marketId;\n address principalTokenAddress;\n }\n\n // CommitmentId => commitment\n mapping(uint256 => Commitment) public commitments;\n\n uint256 commitmentCount;\n\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet)\n internal __commitmentBorrowersList; //DEPRECATED -> moved to manager\n\n mapping(uint256 => address) public commitmentAllowListManagers;\n\n /**\n * @notice This event is emitted when a lender's commitment is created.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event CreatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n /**\n * @notice This event is emitted when a lender's commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n * @param lender The address of the lender.\n * @param marketId The Id of the market the commitment applies to.\n * @param lendingToken The address of the asset being committed.\n * @param tokenAmount The amount of the asset being committed.\n */\n event UpdatedCommitment(\n uint256 indexed commitmentId,\n address lender,\n uint256 marketId,\n address lendingToken,\n uint256 tokenAmount\n );\n\n event UpdatedAllowlistManager(\n uint256 indexed commitmentId,\n address manager\n );\n\n /**\n * @notice This event is emitted when the allowed borrowers for a commitment is updated.\n * @param commitmentId The id of the commitment that was updated.\n */\n event UpdatedCommitmentBorrowers(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment has been deleted.\n * @param commitmentId The id of the commitment that was deleted.\n */\n event DeletedCommitment(uint256 indexed commitmentId);\n\n /**\n * @notice This event is emitted when a lender's commitment is exercised for a loan.\n * @param commitmentId The id of the commitment that was exercised.\n * @param borrower The address of the borrower.\n * @param tokenAmount The amount of the asset being committed.\n * @param bidId The bid id for the loan from TellerV2.\n */\n event ExercisedCommitment(\n uint256 indexed commitmentId,\n address borrower,\n uint256 tokenAmount,\n uint256 bidId\n );\n\n error InsufficientCommitmentAllocation(\n uint256 allocated,\n uint256 requested\n );\n error InsufficientBorrowerCollateral(uint256 required, uint256 actual);\n\n /** Modifiers **/\n\n modifier commitmentLender(uint256 _commitmentId) {\n require(\n commitments[_commitmentId].lender == _msgSender(),\n \"unauthorized commitment lender\"\n );\n _;\n }\n\n\n function getCommitmentLender(uint256 _commitmentId) public returns (address lender_){\n lender_ = commitments[_commitmentId].lender;\n }\n\n function validateCommitment(Commitment storage _commitment) internal {\n require(\n _commitment.expiration > uint32(block.timestamp),\n \"expired commitment\"\n );\n require(\n _commitment.maxPrincipal > 0,\n \"commitment principal allocation 0\"\n );\n\n if (_commitment.collateralTokenType != CommitmentCollateralType.NONE) {\n require(\n _commitment.maxPrincipalPerCollateralAmount > 0,\n \"commitment collateral ratio 0\"\n );\n\n if (\n _commitment.collateralTokenType ==\n CommitmentCollateralType.ERC20\n ) {\n require(\n _commitment.collateralTokenId == 0,\n \"commitment collateral token id must be 0 for ERC20\"\n );\n }\n }\n }\n\n /** External Functions **/\n\n constructor(address _protocolAddress, address _marketRegistry)\n TellerV2MarketForwarder(_protocolAddress, _marketRegistry)\n {}\n\n /**\n * @notice Creates a loan commitment from a lender for a market.\n * @param _commitment The new commitment data expressed as a struct\n * @param borrowerAllowlistManager The address of the allowlist contract \n * @return commitmentId_ returns the commitmentId for the created commitment\n */\n function createCommitment(\n Commitment calldata _commitment,\n address borrowerAllowlistManager\n ) public returns (uint256 commitmentId_) {\n commitmentId_ = commitmentCount++;\n\n require(\n _commitment.lender == _msgSender(),\n \"unauthorized commitment creator\"\n );\n\n commitments[commitmentId_] = _commitment;\n commitmentAllowListManagers[commitmentId_] = borrowerAllowlistManager;\n\n validateCommitment(commitments[commitmentId_]);\n\n //_addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList);\n\n emit CreatedCommitment(\n commitmentId_,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n\n emit UpdatedAllowlistManager(\n commitmentId_,\n borrowerAllowlistManager\n );\n }\n\n /**\n * @notice Updates the commitment of a lender to a market.\n * @param _commitmentId The Id of the commitment to update.\n * @param _commitment The new commitment data expressed as a struct\n */\n function updateCommitment(\n uint256 _commitmentId,\n Commitment calldata _commitment\n ) public commitmentLender(_commitmentId) {\n require(\n _commitment.principalTokenAddress ==\n commitments[_commitmentId].principalTokenAddress,\n \"Principal token address cannot be updated.\"\n );\n require(\n _commitment.marketId == commitments[_commitmentId].marketId,\n \"Market Id cannot be updated.\"\n );\n\n commitments[_commitmentId] = _commitment;\n\n validateCommitment(commitments[_commitmentId]);\n\n emit UpdatedCommitment(\n _commitmentId,\n _commitment.lender,\n _commitment.marketId,\n _commitment.principalTokenAddress,\n _commitment.maxPrincipal\n );\n }\n\n function updateAllowlistManager(\n uint256 _commitmentId,\n address _allowlistManager\n ) public commitmentLender(_commitmentId) {\n \n commitmentAllowListManagers[_commitmentId] = _allowlistManager;\n\n emit UpdatedAllowlistManager(_commitmentId,_allowlistManager);\n }\n \n\n /**\n * @notice Removes the commitment of a lender to a market.\n * @param _commitmentId The id of the commitment to delete.\n */\n function deleteCommitment(uint256 _commitmentId)\n public\n commitmentLender(_commitmentId)\n {\n delete commitments[_commitmentId];\n //delete commitmentBorrowersList[_commitmentId];\n emit DeletedCommitment(_commitmentId);\n }\n\n /**\n * @notice Reduces the commitment amount for a lender to a market.\n * @param _commitmentId The id of the commitment to modify.\n * @param _tokenAmountDelta The amount of change in the maxPrincipal.\n */\n function _decrementCommitment(\n uint256 _commitmentId,\n uint256 _tokenAmountDelta\n ) internal {\n commitments[_commitmentId].maxPrincipal -= _tokenAmountDelta;\n }\n\n /**\n * @notice Accept the commitment to submitBid and acceptBid using the funds\n * @dev LoanDuration must be longer than the market payment cycle\n * @param _commitmentId The id of the commitment being accepted.\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId of collateral to use for the loan if ERC721 or ERC1155.\n * @param _collateralTokenAddress The contract address to use for the loan collateral tokens.\n * @param _interestRate The interest rate APY to use for the loan in basis points.\n * @param _loanDuration The overall duration for the loan. Must be longer than market payment cycle duration.\n * @return bidId The ID of the loan that was created on TellerV2\n */\n function acceptCommitment(\n uint256 _commitmentId,\n uint256 _principalAmount,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n address _collateralTokenAddress,\n uint16 _interestRate,\n uint32 _loanDuration\n ) external returns (uint256 bidId) {\n address borrower = _msgSender();\n\n Commitment storage commitment = commitments[_commitmentId];\n\n validateCommitment(commitment);\n\n require(\n _collateralTokenAddress == commitment.collateralTokenAddress,\n \"Mismatching collateral token\"\n );\n require(\n _interestRate >= commitment.minInterestRate,\n \"Invalid interest rate\"\n );\n require(\n _loanDuration <= commitment.maxDuration,\n \"Invalid loan max duration\"\n );\n\n require(\n __commitmentBorrowersList[_commitmentId].length() == 0 ||\n commitmentAllowListManagers[_commitmentId] != address(0),\n \"Commitments with legacy borrower list must now set an allow list manager\"\n ); \n \n\n require(commitmentAllowListManagers[_commitmentId] == address(0) ||\n IAllowlistManager(commitmentAllowListManagers[_commitmentId]).addressIsAllowed(\n _commitmentId, borrower\n ),\n \"Borrower not allowlisted\"\n );\n \n\n if (_principalAmount > commitment.maxPrincipal) {\n revert InsufficientCommitmentAllocation({\n allocated: commitment.maxPrincipal,\n requested: _principalAmount\n });\n }\n\n uint256 requiredCollateral = getRequiredCollateral(\n _principalAmount,\n commitment.maxPrincipalPerCollateralAmount,\n commitment.collateralTokenType,\n commitment.collateralTokenAddress,\n commitment.principalTokenAddress\n );\n if (_collateralAmount < requiredCollateral) {\n revert InsufficientBorrowerCollateral({\n required: requiredCollateral,\n actual: _collateralAmount\n });\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType ==\n CommitmentCollateralType.ERC721_ANY_ID\n ) {\n require(\n _collateralAmount == 1,\n \"invalid commitment collateral amount for ERC721\"\n );\n }\n\n if (\n commitment.collateralTokenType == CommitmentCollateralType.ERC721 ||\n commitment.collateralTokenType == CommitmentCollateralType.ERC1155\n ) {\n require(\n commitment.collateralTokenId == _collateralTokenId,\n \"invalid commitment collateral tokenId\"\n );\n }\n\n bidId = _submitBidFromCommitment(\n borrower,\n commitment.marketId,\n commitment.principalTokenAddress,\n _principalAmount,\n commitment.collateralTokenAddress,\n _collateralAmount,\n _collateralTokenId,\n commitment.collateralTokenType,\n _loanDuration,\n _interestRate\n );\n\n _acceptBid(bidId, commitment.lender);\n\n _decrementCommitment(_commitmentId, _principalAmount);\n\n emit ExercisedCommitment(\n _commitmentId,\n borrower,\n _principalAmount,\n bidId\n );\n }\n\n \n\n /**\n * @notice Calculate the amount of collateral required to borrow a loan with _principalAmount of principal\n * @param _principalAmount The amount of currency to borrow for the loan.\n * @param _maxPrincipalPerCollateralAmount The ratio for the amount of principal that can be borrowed for each amount of collateral. This is expanded additionally by the principal decimals.\n * @param _collateralTokenType The type of collateral for the loan either ERC20, ERC721, ERC1155, or None.\n * @param _collateralTokenAddress The contract address for the collateral for the loan.\n * @param _principalTokenAddress The contract address for the principal for the loan.\n */\n function getRequiredCollateral(\n uint256 _principalAmount,\n uint256 _maxPrincipalPerCollateralAmount,\n CommitmentCollateralType _collateralTokenType,\n address _collateralTokenAddress,\n address _principalTokenAddress\n ) public view virtual returns (uint256) {\n if (_collateralTokenType == CommitmentCollateralType.NONE) {\n return 0;\n }\n\n uint8 collateralDecimals;\n uint8 principalDecimals = IERC20MetadataUpgradeable(\n _principalTokenAddress\n ).decimals();\n\n if (_collateralTokenType == CommitmentCollateralType.ERC20) {\n collateralDecimals = IERC20MetadataUpgradeable(\n _collateralTokenAddress\n ).decimals();\n }\n\n /*\n * The principalAmount is expanded by (collateralDecimals+principalDecimals) to increase precision\n * and then it is divided by _maxPrincipalPerCollateralAmount which should already been expanded by principalDecimals\n */\n return\n MathUpgradeable.mulDiv(\n _principalAmount,\n (10**(collateralDecimals + principalDecimals)),\n _maxPrincipalPerCollateralAmount,\n MathUpgradeable.Rounding.Up\n );\n }\n\n /**\n * @notice Return the array of borrowers that are allowlisted for a commitment\n * @param _commitmentId The commitment id for the commitment to query.\n * @return borrowers_ An array of addresses restricted to accept the commitment. Empty array means unrestricted.\n */\n /* function getCommitmentBorrowers(uint256 _commitmentId)\n external\n view\n returns (address[] memory borrowers_)\n {\n borrowers_ = commitmentBorrowersList[_commitmentId].values();\n }*/\n\n /**\n * @notice Internal function to submit a bid to the lending protocol using a commitment\n * @param _borrower The address of the borrower for the loan.\n * @param _marketId The id for the market of the loan in the lending protocol.\n * @param _principalTokenAddress The contract address for the principal token.\n * @param _principalAmount The amount of principal to borrow for the loan.\n * @param _collateralTokenAddress The contract address for the collateral token.\n * @param _collateralAmount The amount of collateral to use for the loan.\n * @param _collateralTokenId The tokenId for the collateral (if it is ERC721 or ERC1155).\n * @param _collateralTokenType The type of collateral token (ERC20,ERC721,ERC1177,None).\n * @param _loanDuration The duration of the loan in seconds delta. Must be longer than loan payment cycle for the market.\n * @param _interestRate The amount of interest APY for the loan expressed in basis points.\n */\n function _submitBidFromCommitment(\n address _borrower,\n uint256 _marketId,\n address _principalTokenAddress,\n uint256 _principalAmount,\n address _collateralTokenAddress,\n uint256 _collateralAmount,\n uint256 _collateralTokenId,\n CommitmentCollateralType _collateralTokenType,\n uint32 _loanDuration,\n uint16 _interestRate\n ) internal returns (uint256 bidId) {\n CreateLoanArgs memory createLoanArgs;\n createLoanArgs.marketId = _marketId;\n createLoanArgs.lendingToken = _principalTokenAddress;\n createLoanArgs.principal = _principalAmount;\n createLoanArgs.duration = _loanDuration;\n createLoanArgs.interestRate = _interestRate;\n\n Collateral[] memory collateralInfo;\n if (_collateralTokenType != CommitmentCollateralType.NONE) {\n collateralInfo = new Collateral[](1);\n collateralInfo[0] = Collateral({\n _collateralType: _getEscrowCollateralType(_collateralTokenType),\n _tokenId: _collateralTokenId,\n _amount: _collateralAmount,\n _collateralAddress: _collateralTokenAddress\n });\n }\n\n bidId = _submitBidWithCollateral(\n createLoanArgs,\n collateralInfo,\n _borrower\n );\n }\n\n /**\n * @notice Return the collateral type based on the commitmentcollateral type. Collateral type is used in the base lending protocol.\n * @param _type The type of collateral to be used for the loan.\n */\n function _getEscrowCollateralType(CommitmentCollateralType _type)\n internal\n pure\n returns (CollateralType)\n {\n if (_type == CommitmentCollateralType.ERC20) {\n return CollateralType.ERC20;\n }\n if (\n _type == CommitmentCollateralType.ERC721 ||\n _type == CommitmentCollateralType.ERC721_ANY_ID\n ) {\n return CollateralType.ERC721;\n }\n if (\n _type == CommitmentCollateralType.ERC1155 ||\n _type == CommitmentCollateralType.ERC1155_ANY_ID\n ) {\n return CollateralType.ERC1155;\n }\n\n revert(\"Unknown Collateral Type\");\n }\n}\n" + }, + "contracts/interfaces/allowlist/IAllowlistManager.sol": { + "content": "\n\n\ninterface IAllowlistManager {\n\n \n function addressIsAllowed(uint256 _commitmentId,address _account) external returns (bool allowed_) ;\n \n}" + }, + "contracts/interfaces/allowlist/IEnumerableSetAllowlist.sol": { + "content": "\n\n\ninterface IEnumerableSetAllowlist {\n \n function setAllowlist(\n uint256 _commitmentId,\n address[] calldata _addressList\n ) external;\n \n}" + }, + "contracts/interfaces/ILenderCommitmentForwarder.sol": { + "content": "// SPDX-Licence-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n \ninterface ILenderCommitmentForwarder {\n\n function getCommitmentLender(uint256 _commitmentId) external returns (address lender_);\n\n}\n" + }, + "contracts/allowlist/EnumerableSetAllowlist.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/allowlist/IAllowlistManager.sol\";\nimport \"../interfaces/allowlist/IEnumerableSetAllowlist.sol\";\n\nimport \"../interfaces/ILenderCommitmentForwarder.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol\";\n\n\ncontract EnumerableSetAllowlist is IAllowlistManager,IEnumerableSetAllowlist {\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n\n event UpdatedAllowList(uint256 commitmentId);\n \n address public immutable commitmentManager;\n\n mapping(uint256 => EnumerableSetUpgradeable.AddressSet) internal allowList;\n\n modifier onlyCommitmentOwner(uint256 _commitmentId){\n require(msg.sender == ILenderCommitmentForwarder(commitmentManager).getCommitmentLender(_commitmentId),\"Must be the lender of the commitment.\");\n _;\n }\n\n constructor(address _commitmentManager){ \n commitmentManager = _commitmentManager;\n }\n\n\n function setAllowlist(\n uint256 _commitmentId,\n address[] calldata _addressList\n ) public\n onlyCommitmentOwner(_commitmentId) \n {\n \n delete allowList[_commitmentId];\n _addToAllowlist(_commitmentId, _addressList);\n }\n\n \n /**\n * @notice Adds a addresses to the allowlist for a commmitment.\n * @param _commitmentId The id of the commitment that will allow the new borrower\n * @param _addressList the address array that will be allowed to accept loans using the commitment\n */\n function _addToAllowlist(\n uint256 _commitmentId,\n address[] calldata _addressList\n ) internal virtual {\n \n for (uint256 i = 0; i < _addressList.length; i++) {\n allowList[_commitmentId].add(_addressList[i]);\n }\n emit UpdatedAllowList(_commitmentId);\n }\n\n\n function addressIsAllowed(uint256 _commitmentId, address _account) public virtual returns (bool) {\n return allowList[_commitmentId].contains(_account);\n }\n\n function getAllowedAddresses(uint256 _commitmentId)\n public\n view\n returns (address[] memory borrowers_)\n {\n borrowers_ = allowList[_commitmentId].values();\n }\n\n}" + }, + "contracts/mock/LenderCommitmentForwarderMock.sol": { + "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/ILenderCommitmentForwarder.sol\"; \n\ncontract LenderCommitmentForwarderMock is ILenderCommitmentForwarder {\n \n address lender;\n\n function setLender(address _lender) public {\n lender = _lender;\n }\n\n function getCommitmentLender(uint256 _commitmentId) external returns (address){\n\n return lender;\n\n }\n\n\n\n\n}\n" + }, + "contracts/mock/AllowlistManagerMock.sol": { + "content": "\nimport \"../interfaces/allowlist/IAllowlistManager.sol\";\ncontract AllowlistManagerMock is IAllowlistManager {\n\n\n function addressIsAllowed(uint256 _commitmentId, address _account) public returns (bool _allowed) {\n return true;\n }\n\n\n}\n" + }, + "contracts/allowlist/OpenAllowlist.sol": { + "content": "\npragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\nimport \"../interfaces/allowlist/IAllowlistManager.sol\";\n \n\ncontract OpenAllowlist is IAllowlistManager {\n \n event UpdatedAllowList(uint256 commitmentId); \n\n constructor( ){ \n \n }\n\n function addressIsAllowed(uint256, address) public virtual returns (bool) {\n return true;\n }\n\n \n}" + }, + "contracts/allowlist/ERC721Allowlist.sol": { + "content": "\npragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\nimport \"../interfaces/allowlist/IAllowlistManager.sol\";\n \nimport \"../interfaces/allowlist/IERC721Allowlist.sol\";\n\n import \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\n\ncontract ERC721Allowlist is IAllowlistManager,IERC721Allowlist {\n \n event UpdatedAllowList(uint256 commitmentId);\n\n \n IERC721Upgradeable public immutable accessToken; //IERC721\n\n \n\n constructor(address _accessToken){ \n accessToken = IERC721Upgradeable(_accessToken);\n }\n\n function addressIsAllowed(uint256 _commitmentId, address _account) public virtual returns (bool) {\n return accessToken.balanceOf(_account) >= 1;\n }\n\n /*\n function getAllowedAddresses(uint256 _commitmentId)\n public\n view\n returns (address[] memory borrowers_)\n {\n borrowers_ = allowList[_commitmentId].values();\n }*/\n\n}" + }, + "contracts/interfaces/allowlist/IERC721Allowlist.sol": { + "content": "\n\ninterface IERC721Allowlist {\n\n \n}" + }, + "contracts/escrow/CollateralEscrowV1.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\n// Interfaces\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\";\nimport \"../interfaces/escrow/ICollateralEscrowV1.sol\";\n\ncontract CollateralEscrowV1 is OwnableUpgradeable, ICollateralEscrowV1 {\n uint256 public bidId;\n /* Mappings */\n mapping(address => Collateral) public collateralBalances; // collateral address -> collateral\n\n /* Events */\n event CollateralDeposited(address _collateralAddress, uint256 _amount);\n event CollateralWithdrawn(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n );\n\n /**\n * @notice Initializes an escrow.\n * @notice The id of the associated bid.\n */\n function initialize(uint256 _bidId) public initializer {\n __Ownable_init();\n bidId = _bidId;\n }\n\n function getBid() external view returns (uint256) {\n return bidId;\n }\n\n /**\n * @notice Deposits a collateral ERC20 token into the escrow.\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositToken(address _collateralAddress, uint256 _amount)\n external\n onlyOwner\n {\n require(_amount > 0, \"Deposit amount cannot be zero\");\n _depositCollateral(\n CollateralType.ERC20,\n _collateralAddress,\n _amount,\n 0\n );\n Collateral storage collateral = collateralBalances[_collateralAddress];\n collateral._collateralType = CollateralType.ERC20;\n collateral._amount = _amount;\n emit CollateralDeposited(_collateralAddress, _amount);\n }\n\n /**\n * @notice Deposits a collateral asset into the escrow.\n * @param _collateralType The type of collateral asset to deposit (ERC721, ERC1155).\n * @param _collateralAddress The address of the collateral token.\n * @param _amount The amount to deposit.\n */\n function depositAsset(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) external payable onlyOwner {\n require(_amount > 0, \"Deposit amount cannot be zero\");\n _depositCollateral(\n _collateralType,\n _collateralAddress,\n _amount,\n _tokenId\n );\n Collateral storage collateral = collateralBalances[_collateralAddress];\n collateral._collateralType = _collateralType;\n collateral._amount = _amount;\n collateral._tokenId = _tokenId;\n emit CollateralDeposited(_collateralAddress, _amount);\n }\n\n /**\n * @notice Withdraws a collateral asset from the escrow.\n * @param _collateralAddress The address of the collateral contract.\n * @param _amount The amount to withdraw.\n * @param _recipient The address to send the assets to.\n */\n function withdraw(\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) external onlyOwner {\n require(_amount > 0, \"Withdraw amount cannot be zero\");\n Collateral storage collateral = collateralBalances[_collateralAddress];\n require(\n collateral._amount >= _amount,\n \"No collateral balance for asset\"\n );\n _withdrawCollateral(\n collateral,\n _collateralAddress,\n _amount,\n _recipient\n );\n collateral._amount -= _amount;\n emit CollateralWithdrawn(_collateralAddress, _amount, _recipient);\n }\n\n function _depositCollateral(\n CollateralType _collateralType,\n address _collateralAddress,\n uint256 _amount,\n uint256 _tokenId\n ) internal {\n // Deposit ERC20\n if (_collateralType == CollateralType.ERC20) {\n SafeERC20Upgradeable.safeTransferFrom(\n IERC20Upgradeable(_collateralAddress),\n _msgSender(),\n address(this),\n _amount\n );\n }\n // Deposit ERC721\n else if (_collateralType == CollateralType.ERC721) {\n require(_amount == 1, \"Incorrect deposit amount\");\n IERC721Upgradeable(_collateralAddress).transferFrom(\n _msgSender(),\n address(this),\n _tokenId\n );\n }\n // Deposit ERC1155\n else if (_collateralType == CollateralType.ERC1155) {\n bytes memory data;\n\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\n _msgSender(),\n address(this),\n _tokenId,\n _amount,\n data\n );\n }\n }\n\n function _withdrawCollateral(\n Collateral memory _collateral,\n address _collateralAddress,\n uint256 _amount,\n address _recipient\n ) internal {\n // Withdraw ERC20\n if (_collateral._collateralType == CollateralType.ERC20) {\n IERC20Upgradeable(_collateralAddress).transfer(\n _recipient,\n _collateral._amount\n );\n }\n // Withdraw ERC721\n else if (_collateral._collateralType == CollateralType.ERC721) {\n require(_amount == 1, \"Incorrect withdrawal amount\");\n IERC721Upgradeable(_collateralAddress).transferFrom(\n address(this),\n _recipient,\n _collateral._tokenId\n );\n }\n // Withdraw ERC1155\n else if (_collateral._collateralType == CollateralType.ERC1155) {\n bytes memory data;\n\n IERC1155Upgradeable(_collateralAddress).safeTransferFrom(\n address(this),\n _recipient,\n _collateral._tokenId,\n _amount,\n data\n );\n }\n }\n\n // On NFT Received handlers\n\n function onERC721Received(address, address, uint256, bytes calldata)\n external\n pure\n returns (bytes4)\n {\n return\n bytes4(\n keccak256(\"onERC721Received(address,address,uint256,bytes)\")\n );\n }\n\n function onERC1155Received(\n address,\n address,\n uint256 id,\n uint256 value,\n bytes calldata\n ) external returns (bytes4) {\n return\n bytes4(\n keccak256(\n \"onERC1155Received(address,address,uint256,uint256,bytes)\"\n )\n );\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata _ids,\n uint256[] calldata _values,\n bytes calldata\n ) external returns (bytes4) {\n require(\n _ids.length == 1,\n \"Only allowed one asset batch transfer per transaction.\"\n );\n return\n bytes4(\n keccak256(\n \"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"\n )\n );\n }\n}\n" + }, + "contracts/TellerV2Autopay.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/ITellerV2Autopay.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { Payment } from \"./TellerV2Storage.sol\";\n\n/**\n * @dev Helper contract to autopay loans\n */\ncontract TellerV2Autopay is OwnableUpgradeable, ITellerV2Autopay {\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n\n ITellerV2 public immutable tellerV2;\n\n //bidId => enabled\n mapping(uint256 => bool) public loanAutoPayEnabled;\n\n // Autopay fee set for automatic loan payments\n uint16 private _autopayFee;\n\n /**\n * @notice This event is emitted when a loan is autopaid.\n * @param bidId The id of the bid/loan which was repaid.\n * @param msgsender The account that called the method\n */\n event AutoPaidLoanMinimum(uint256 indexed bidId, address indexed msgsender);\n\n /**\n * @notice This event is emitted when loan autopayments are enabled or disabled.\n * @param bidId The id of the bid/loan.\n * @param enabled Whether the autopayments are enabled or disabled\n */\n event AutoPayEnabled(uint256 indexed bidId, bool enabled);\n\n /**\n * @notice This event is emitted when the autopay fee has been updated.\n * @param newFee The new autopay fee set.\n * @param oldFee The previously set autopay fee.\n */\n event AutopayFeeSet(uint16 newFee, uint16 oldFee);\n\n constructor(address _protocolAddress) {\n tellerV2 = ITellerV2(_protocolAddress);\n }\n\n /**\n * @notice Initialized the proxy.\n * @param _fee The fee collected for automatic payment processing.\n * @param _owner The address of the ownership to be transferred to.\n */\n function initialize(uint16 _fee, address _owner) external initializer {\n _transferOwnership(_owner);\n _setAutopayFee(_fee);\n }\n\n /**\n * @notice Let the owner of the contract set a new autopay fee.\n * @param _newFee The new autopay fee to set.\n */\n function setAutopayFee(uint16 _newFee) public virtual onlyOwner {\n _setAutopayFee(_newFee);\n }\n\n function _setAutopayFee(uint16 _newFee) internal {\n // Skip if the fee is the same\n if (_newFee == _autopayFee) return;\n uint16 oldFee = _autopayFee;\n _autopayFee = _newFee;\n emit AutopayFeeSet(_newFee, oldFee);\n }\n\n /**\n * @notice Returns the current autopay fee.\n */\n function getAutopayFee() public view virtual returns (uint16) {\n return _autopayFee;\n }\n\n /**\n * @notice Function for a borrower to enable or disable autopayments\n * @param _bidId The id of the bid to cancel.\n * @param _autoPayEnabled boolean for allowing autopay on a loan\n */\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external {\n require(\n _msgSender() == tellerV2.getLoanBorrower(_bidId),\n \"Only the borrower can set autopay\"\n );\n\n loanAutoPayEnabled[_bidId] = _autoPayEnabled;\n\n emit AutoPayEnabled(_bidId, _autoPayEnabled);\n }\n\n /**\n * @notice Function for a minimum autopayment to be performed on a loan\n * @param _bidId The id of the bid to repay.\n */\n function autoPayLoanMinimum(uint256 _bidId) external {\n require(\n loanAutoPayEnabled[_bidId],\n \"Autopay is not enabled for that loan\"\n );\n\n address lendingToken = ITellerV2(tellerV2).getLoanLendingToken(_bidId);\n address borrower = ITellerV2(tellerV2).getLoanBorrower(_bidId);\n\n uint256 amountToRepayMinimum = getEstimatedMinimumPayment(_bidId);\n uint256 autopayFeeAmount = amountToRepayMinimum.percent(\n getAutopayFee()\n );\n\n // Pull lendingToken in from the borrower to this smart contract\n ERC20(lendingToken).safeTransferFrom(\n borrower,\n address(this),\n amountToRepayMinimum + autopayFeeAmount\n );\n\n // Transfer fee to msg sender\n ERC20(lendingToken).safeTransfer(_msgSender(), autopayFeeAmount);\n\n // Approve the lendingToken to tellerV2\n ERC20(lendingToken).approve(address(tellerV2), amountToRepayMinimum);\n\n // Use that lendingToken to repay the loan\n tellerV2.repayLoan(_bidId, amountToRepayMinimum);\n\n emit AutoPaidLoanMinimum(_bidId, msg.sender);\n }\n\n function getEstimatedMinimumPayment(uint256 _bidId)\n public\n virtual\n returns (uint256 _amount)\n {\n Payment memory estimatedPayment = tellerV2.calculateAmountDue(_bidId);\n\n _amount = estimatedPayment.principal + estimatedPayment.interest;\n }\n}\n" + }, + "contracts/interfaces/ITellerV2Autopay.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Autopay {\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external;\n\n function autoPayLoanMinimum(uint256 _bidId) external;\n\n function initialize(uint16 _newFee, address _newOwner) external;\n\n function setAutopayFee(uint16 _newFee) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/cryptography/EIP712.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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 if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/EIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-ERC20Permit.sol\";\nimport \"../../../utils/math/Math.sol\";\nimport \"../../../governance/utils/IVotes.sol\";\nimport \"../../../utils/math/SafeCast.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n *\n * _Available since v4.2._\n */\nabstract contract ERC20Votes is IVotes, ERC20Permit {\n struct Checkpoint {\n uint32 fromBlock;\n uint224 votes;\n }\n\n bytes32 private constant _DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address => address) private _delegates;\n mapping(address => Checkpoint[]) private _checkpoints;\n Checkpoint[] private _totalSupplyCheckpoints;\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n return _checkpoints[account][pos];\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return SafeCast.toUint32(_checkpoints[account].length);\n }\n\n /**\n * @dev Get the address `account` is currently delegating to.\n */\n function delegates(address account) public view virtual override returns (address) {\n return _delegates[account];\n }\n\n /**\n * @dev Gets the current votes balance for `account`\n */\n function getVotes(address account) public view virtual override returns (uint256) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;\n }\n\n /**\n * @dev Retrieve the number of votes for `account` at the end of `blockNumber`.\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_checkpoints[account], blockNumber);\n }\n\n /**\n * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances.\n * It is but NOT the sum of all the delegated votes!\n *\n * Requirements:\n *\n * - `blockNumber` must have been already mined\n */\n function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n require(blockNumber < block.number, \"ERC20Votes: block not yet mined\");\n return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n }\n\n /**\n * @dev Lookup a value in a list of (sorted) checkpoints.\n */\n function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n //\n // Initially we check if the block is recent to narrow the search range.\n // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n // out of bounds (in which case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n // the same.\n uint256 length = ckpts.length;\n\n uint256 low = 0;\n uint256 high = length;\n\n if (length > 5) {\n uint256 mid = length - Math.sqrt(length);\n if (_unsafeAccess(ckpts, mid).fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(ckpts, mid).fromBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : _unsafeAccess(ckpts, high - 1).votes;\n }\n\n /**\n * @dev Delegate votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual override {\n _delegate(_msgSender(), delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= expiry, \"ERC20Votes: signature expired\");\n address signer = ECDSA.recover(\n _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n require(nonce == _useNonce(signer), \"ERC20Votes: invalid nonce\");\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n */\n function _maxSupply() internal view virtual returns (uint224) {\n return type(uint224).max;\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been increased.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n super._mint(account, amount);\n require(totalSupply() <= _maxSupply(), \"ERC20Votes: total supply risks overflowing votes\");\n\n _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n }\n\n /**\n * @dev Snapshots the totalSupply after it has been decreased.\n */\n function _burn(address account, uint256 amount) internal virtual override {\n super._burn(account, amount);\n\n _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {IVotes-DelegateVotesChanged} event.\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._afterTokenTransfer(from, to, amount);\n\n _moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Change delegation for `delegator` to `delegatee`.\n *\n * Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.\n */\n function _delegate(address delegator, address delegatee) internal virtual {\n address currentDelegate = delegates(delegator);\n uint256 delegatorBalance = balanceOf(delegator);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n _moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n\n function _moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) private {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n function _writeCheckpoint(\n Checkpoint[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) private returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n\n Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);\n\n oldWeight = oldCkpt.votes;\n newWeight = op(oldWeight, delta);\n\n if (pos > 0 && oldCkpt.fromBlock == block.number) {\n _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);\n } else {\n ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));\n }\n }\n\n function _add(uint256 a, uint256 b) private pure returns (uint256) {\n return a + b;\n }\n\n function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.\n */\n function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result) {\n assembly {\n mstore(0, ckpts.slot)\n result.slot := add(keccak256(0, 0x20), pos)\n }\n }\n}\n" + }, + "@openzeppelin/contracts/governance/utils/IVotes.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n *\n * _Available since v4.5._\n */\ninterface IVotes {\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n" }, "contracts/mock/MarketRegistryMock.sol": { "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IMarketRegistry.sol\";\nimport { PaymentType } from \"../libraries/V2Calculations.sol\";\n\ncontract MarketRegistryMock is IMarketRegistry {\n address marketOwner;\n\n constructor(address _marketOwner) {\n marketOwner = _marketOwner;\n }\n\n function initialize(TellerAS _tellerAS) external {}\n\n function isVerifiedLender(uint256 _marketId, address _lenderAddress)\n public\n view\n returns (bool isVerified_, bytes32 uuid_)\n {\n isVerified_ = true;\n }\n\n function isMarketClosed(uint256 _marketId) public view returns (bool) {\n return false;\n }\n\n function isVerifiedBorrower(uint256 _marketId, address _borrower)\n public\n view\n returns (bool isVerified_, bytes32 uuid_)\n {\n isVerified_ = true;\n }\n\n function getMarketOwner(uint256 _marketId) public view returns (address) {\n return address(marketOwner);\n }\n\n function getMarketFeeRecipient(uint256 _marketId)\n public\n view\n returns (address)\n {\n return address(marketOwner);\n }\n\n function getMarketURI(uint256 _marketId)\n public\n view\n returns (string memory)\n {\n return \"url://\";\n }\n\n function getPaymentCycle(uint256 _marketId)\n public\n view\n returns (uint32, PaymentCycleType)\n {\n return (1000, PaymentCycleType.Seconds);\n }\n\n function getPaymentDefaultDuration(uint256 _marketId)\n public\n view\n returns (uint32)\n {\n return 1000;\n }\n\n function getBidExpirationTime(uint256 _marketId)\n public\n view\n returns (uint32)\n {\n return 1000;\n }\n\n function getMarketplaceFee(uint256 _marketId) public view returns (uint16) {\n return 1000;\n }\n\n function setMarketOwner(address _owner) public {\n marketOwner = _owner;\n }\n\n function getPaymentType(uint256 _marketId)\n public\n view\n returns (PaymentType)\n {}\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n PaymentType _paymentType,\n PaymentCycleType _paymentCycleType,\n string calldata _uri\n ) public returns (uint256) {}\n\n function createMarket(\n address _initialOwner,\n uint32 _paymentCycleDuration,\n uint32 _paymentDefaultDuration,\n uint32 _bidExpirationTime,\n uint16 _feePercent,\n bool _requireLenderAttestation,\n bool _requireBorrowerAttestation,\n string calldata _uri\n ) public returns (uint256) {}\n}\n" @@ -190,29 +268,83 @@ "@openzeppelin/contracts/proxy/utils/Initializable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" }, - "contracts/TellerV2Autopay.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/ITellerV2Autopay.sol\";\n\nimport \"./libraries/NumbersLib.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { Payment } from \"./TellerV2Storage.sol\";\n\n/**\n * @dev Helper contract to autopay loans\n */\ncontract TellerV2Autopay is OwnableUpgradeable, ITellerV2Autopay {\n using SafeERC20 for ERC20;\n using NumbersLib for uint256;\n\n ITellerV2 public immutable tellerV2;\n\n //bidId => enabled\n mapping(uint256 => bool) public loanAutoPayEnabled;\n\n // Autopay fee set for automatic loan payments\n uint16 private _autopayFee;\n\n /**\n * @notice This event is emitted when a loan is autopaid.\n * @param bidId The id of the bid/loan which was repaid.\n * @param msgsender The account that called the method\n */\n event AutoPaidLoanMinimum(uint256 indexed bidId, address indexed msgsender);\n\n /**\n * @notice This event is emitted when loan autopayments are enabled or disabled.\n * @param bidId The id of the bid/loan.\n * @param enabled Whether the autopayments are enabled or disabled\n */\n event AutoPayEnabled(uint256 indexed bidId, bool enabled);\n\n /**\n * @notice This event is emitted when the autopay fee has been updated.\n * @param newFee The new autopay fee set.\n * @param oldFee The previously set autopay fee.\n */\n event AutopayFeeSet(uint16 newFee, uint16 oldFee);\n\n constructor(address _protocolAddress) {\n tellerV2 = ITellerV2(_protocolAddress);\n }\n\n /**\n * @notice Initialized the proxy.\n * @param _fee The fee collected for automatic payment processing.\n * @param _owner The address of the ownership to be transferred to.\n */\n function initialize(uint16 _fee, address _owner) external initializer {\n _transferOwnership(_owner);\n _setAutopayFee(_fee);\n }\n\n /**\n * @notice Let the owner of the contract set a new autopay fee.\n * @param _newFee The new autopay fee to set.\n */\n function setAutopayFee(uint16 _newFee) public virtual onlyOwner {\n _setAutopayFee(_newFee);\n }\n\n function _setAutopayFee(uint16 _newFee) internal {\n // Skip if the fee is the same\n if (_newFee == _autopayFee) return;\n uint16 oldFee = _autopayFee;\n _autopayFee = _newFee;\n emit AutopayFeeSet(_newFee, oldFee);\n }\n\n /**\n * @notice Returns the current autopay fee.\n */\n function getAutopayFee() public view virtual returns (uint16) {\n return _autopayFee;\n }\n\n /**\n * @notice Function for a borrower to enable or disable autopayments\n * @param _bidId The id of the bid to cancel.\n * @param _autoPayEnabled boolean for allowing autopay on a loan\n */\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external {\n require(\n _msgSender() == tellerV2.getLoanBorrower(_bidId),\n \"Only the borrower can set autopay\"\n );\n\n loanAutoPayEnabled[_bidId] = _autoPayEnabled;\n\n emit AutoPayEnabled(_bidId, _autoPayEnabled);\n }\n\n /**\n * @notice Function for a minimum autopayment to be performed on a loan\n * @param _bidId The id of the bid to repay.\n */\n function autoPayLoanMinimum(uint256 _bidId) external {\n require(\n loanAutoPayEnabled[_bidId],\n \"Autopay is not enabled for that loan\"\n );\n\n address lendingToken = ITellerV2(tellerV2).getLoanLendingToken(_bidId);\n address borrower = ITellerV2(tellerV2).getLoanBorrower(_bidId);\n\n uint256 amountToRepayMinimum = getEstimatedMinimumPayment(_bidId);\n uint256 autopayFeeAmount = amountToRepayMinimum.percent(\n getAutopayFee()\n );\n\n // Pull lendingToken in from the borrower to this smart contract\n ERC20(lendingToken).safeTransferFrom(\n borrower,\n address(this),\n amountToRepayMinimum + autopayFeeAmount\n );\n\n // Transfer fee to msg sender\n ERC20(lendingToken).safeTransfer(_msgSender(), autopayFeeAmount);\n\n // Approve the lendingToken to tellerV2\n ERC20(lendingToken).approve(address(tellerV2), amountToRepayMinimum);\n\n // Use that lendingToken to repay the loan\n tellerV2.repayLoan(_bidId, amountToRepayMinimum);\n\n emit AutoPaidLoanMinimum(_bidId, msg.sender);\n }\n\n function getEstimatedMinimumPayment(uint256 _bidId)\n public\n virtual\n returns (uint256 _amount)\n {\n Payment memory estimatedPayment = tellerV2.calculateAmountDue(_bidId);\n\n _amount = estimatedPayment.principal + estimatedPayment.interest;\n }\n}\n" + "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\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 virtual override returns (address) {\n return _roleMembers[role].at(index);\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 virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" }, - "contracts/interfaces/ITellerV2Autopay.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Autopay {\n function setAutoPayEnabled(uint256 _bidId, bool _autoPayEnabled) external;\n\n function autoPayLoanMinimum(uint256 _bidId) external;\n\n function initialize(uint16 _newFee, address _newOwner) external;\n\n function setAutopayFee(uint16 _newFee) external;\n}\n" + "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\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) external view returns (address);\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) external view returns (uint256);\n}\n" }, - "contracts/LenderManager.sol": { - "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/ILenderManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/IMarketRegistry.sol\";\n\ncontract LenderManager is\n Initializable,\n OwnableUpgradeable,\n ERC721Upgradeable,\n ILenderManager\n{\n IMarketRegistry public immutable marketRegistry;\n\n constructor(IMarketRegistry _marketRegistry) {\n marketRegistry = _marketRegistry;\n }\n\n function initialize() external initializer {\n __LenderManager_init();\n }\n\n function __LenderManager_init() internal onlyInitializing {\n __Ownable_init();\n __ERC721_init(\"TellerLoan\", \"TLN\");\n }\n\n /**\n * @notice Registers a new active lender for a loan, minting the nft\n * @param _bidId The id for the loan to set.\n * @param _newLender The address of the new active lender.\n */\n function registerLoan(uint256 _bidId, address _newLender)\n public\n override\n onlyOwner\n {\n _mint(_newLender, _bidId);\n }\n\n /**\n * @notice Returns the address of the lender that owns a given loan/bid.\n * @param _bidId The id of the bid of which to return the market id\n */\n function _getLoanMarketId(uint256 _bidId) internal view returns (uint256) {\n return ITellerV2(owner()).getLoanMarketId(_bidId);\n }\n\n /**\n * @notice Returns the verification status of a lender for a market.\n * @param _lender The address of the lender which should be verified by the market\n * @param _bidId The id of the bid of which to return the market id\n */\n function _hasMarketVerification(address _lender, uint256 _bidId)\n internal\n view\n virtual\n returns (bool isVerified_)\n {\n uint256 _marketId = _getLoanMarketId(_bidId);\n\n (isVerified_, ) = marketRegistry.isVerifiedLender(_marketId, _lender);\n }\n\n /** ERC721 Functions **/\n\n function _beforeTokenTransfer(address, address to, uint256 tokenId, uint256)\n internal\n override\n {\n require(_hasMarketVerification(to, tokenId), \"Not approved by market\");\n }\n\n function _baseURI() internal view override returns (string memory) {\n return \"\";\n }\n}\n" + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" }, - "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC721_init_unchained(name_, symbol_);\n }\n\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721Upgradeable.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256, /* firstTokenId */\n uint256 batchSize\n ) internal virtual {\n if (batchSize > 1) {\n if (from != address(0)) {\n _balances[from] -= batchSize;\n }\n if (to != address(0)) {\n _balances[to] += batchSize;\n }\n }\n }\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 firstTokenId,\n uint256 batchSize\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[44] private __gap;\n}\n" + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" }, - "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" }, - "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/security/Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/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() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../security/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(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.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 /**\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 _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetMinterPauser.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../extensions/ERC20Burnable.sol\";\nimport \"../extensions/ERC20Pausable.sol\";\nimport \"../../../access/AccessControlEnumerable.sol\";\nimport \"../../../utils/Context.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 *\n * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._\n */\ncontract ERC20PresetMinterPauser is Context, AccessControlEnumerable, 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) 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" + }, + "contracts/type-imports.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n//SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\n" + }, + "contracts/TellerV0Storage.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/*\n\n THIS IS ONLY USED FOR SUBGRAPH \n \n\n*/\n\ncontract TellerV0Storage {\n enum BidState {\n NONEXISTENT,\n PENDING,\n CANCELLED,\n ACCEPTED,\n PAID,\n LIQUIDATED\n }\n\n /**\n * @notice Represents a total amount for a payment.\n * @param principal Amount that counts towards the principal.\n * @param interest Amount that counts toward interest.\n */\n struct Payment {\n uint256 principal;\n uint256 interest;\n }\n\n /**\n * @notice Details about the loan.\n * @param lendingToken The token address for the loan.\n * @param principal The amount of tokens initially lent out.\n * @param totalRepaid Payment struct that represents the total principal and interest amount repaid.\n * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower.\n * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender.\n * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made\n * @param loanDuration The duration of the loan.\n */\n struct LoanDetails {\n ERC20 lendingToken;\n uint256 principal;\n Payment totalRepaid;\n uint32 timestamp;\n uint32 acceptedTimestamp;\n uint32 lastRepaidTimestamp;\n uint32 loanDuration;\n }\n\n /**\n * @notice Details about a loan request.\n * @param borrower Account address who is requesting a loan.\n * @param receiver Account address who will receive the loan amount.\n * @param lender Account address who accepted and funded the loan request.\n * @param marketplaceId ID of the marketplace the bid was submitted to.\n * @param metadataURI ID of off chain metadata to find additional information of the loan request.\n * @param loanDetails Struct of the specific loan details.\n * @param terms Struct of the loan request terms.\n * @param state Represents the current state of the loan.\n */\n struct Bid0 {\n address borrower;\n address receiver;\n address _lender; // DEPRECATED\n uint256 marketplaceId;\n bytes32 _metadataURI; // DEPRECATED\n LoanDetails loanDetails;\n Terms terms;\n BidState state;\n }\n\n /**\n * @notice Information on the terms of a loan request\n * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle.\n * @param paymentCycle Duration, in seconds, of how often a payment must be made.\n * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%)\n */\n struct Terms {\n uint256 paymentCycleAmount;\n uint32 paymentCycle;\n uint16 APR;\n }\n\n // Mapping of bidId to bid information.\n mapping(uint256 => Bid0) public bids;\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "contracts/TLR.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract TLR is ERC20Votes, Ownable {\n uint224 private immutable MAX_SUPPLY;\n\n /**\n * @dev Sets the value of the `cap`. This value is immutable, it can only be\n * set once during construction.\n */\n constructor(uint224 _supplyCap, address tokenOwner)\n ERC20(\"Teller\", \"TLR\")\n ERC20Permit(\"Teller\")\n {\n require(_supplyCap > 0, \"ERC20Capped: cap is 0\");\n MAX_SUPPLY = _supplyCap;\n _transferOwnership(tokenOwner);\n }\n\n /**\n * @dev Max supply has been overridden to cap the token supply upon initialization of the contract\n * @dev See OpenZeppelin's implementation of ERC20Votes _mint() function\n */\n function _maxSupply() internal view override returns (uint224) {\n return MAX_SUPPLY;\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function mint(address account, uint256 amount) external onlyOwner {\n _mint(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) external onlyOwner {\n _burn(account, amount);\n }\n}\n" }, "contracts/ReputationManager.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n// Interfaces\nimport \"./interfaces/IReputationManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\n\n// Libraries\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\ncontract ReputationManager is IReputationManager, Initializable {\n using EnumerableSet for EnumerableSet.UintSet;\n\n bytes32 public constant CONTROLLER = keccak256(\"CONTROLLER\");\n\n ITellerV2 public tellerV2;\n mapping(address => EnumerableSet.UintSet) private _delinquencies;\n mapping(address => EnumerableSet.UintSet) private _defaults;\n mapping(address => EnumerableSet.UintSet) private _currentDelinquencies;\n mapping(address => EnumerableSet.UintSet) private _currentDefaults;\n\n event MarkAdded(\n address indexed account,\n RepMark indexed repMark,\n uint256 bidId\n );\n event MarkRemoved(\n address indexed account,\n RepMark indexed repMark,\n uint256 bidId\n );\n\n /**\n * @notice Initializes the proxy.\n */\n function initialize(address _tellerV2) external initializer {\n tellerV2 = ITellerV2(_tellerV2);\n }\n\n function getDelinquentLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _delinquencies[_account].values();\n }\n\n function getDefaultedLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _defaults[_account].values();\n }\n\n function getCurrentDelinquentLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _currentDelinquencies[_account].values();\n }\n\n function getCurrentDefaultLoanIds(address _account)\n public\n override\n returns (uint256[] memory)\n {\n updateAccountReputation(_account);\n return _currentDefaults[_account].values();\n }\n\n function updateAccountReputation(address _account) public override {\n uint256[] memory activeBidIds = tellerV2.getBorrowerActiveLoanIds(\n _account\n );\n for (uint256 i; i < activeBidIds.length; i++) {\n _applyReputation(_account, activeBidIds[i]);\n }\n }\n\n function updateAccountReputation(address _account, uint256 _bidId)\n public\n override\n returns (RepMark)\n {\n return _applyReputation(_account, _bidId);\n }\n\n function _applyReputation(address _account, uint256 _bidId)\n internal\n returns (RepMark mark_)\n {\n mark_ = RepMark.Good;\n\n if (tellerV2.isLoanDefaulted(_bidId)) {\n mark_ = RepMark.Default;\n\n // Remove delinquent status\n _removeMark(_account, _bidId, RepMark.Delinquent);\n } else if (tellerV2.isPaymentLate(_bidId)) {\n mark_ = RepMark.Delinquent;\n }\n\n // Mark status if not \"Good\"\n if (mark_ != RepMark.Good) {\n _addMark(_account, _bidId, mark_);\n }\n }\n\n function _addMark(address _account, uint256 _bidId, RepMark _mark)\n internal\n {\n if (_mark == RepMark.Delinquent) {\n _delinquencies[_account].add(_bidId);\n _currentDelinquencies[_account].add(_bidId);\n } else if (_mark == RepMark.Default) {\n _defaults[_account].add(_bidId);\n _currentDefaults[_account].add(_bidId);\n }\n\n emit MarkAdded(_account, _mark, _bidId);\n }\n\n function _removeMark(address _account, uint256 _bidId, RepMark _mark)\n internal\n {\n if (_mark == RepMark.Delinquent) {\n _currentDelinquencies[_account].remove(_bidId);\n } else if (_mark == RepMark.Default) {\n _currentDefaults[_account].remove(_bidId);\n }\n\n emit MarkRemoved(_account, _mark, _bidId);\n }\n}\n" }, - "contracts/mock/CollateralManagerMock.sol": { - "content": "pragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/ICollateralManager.sol\";\n\ncontract CollateralManagerMock is ICollateralManager {\n function commitCollateral(\n uint256 _bidId,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validation_) {\n return true;\n }\n\n function commitCollateral(\n uint256 _bidId,\n Collateral calldata _collateralInfo\n ) external returns (bool validation_) {\n return true;\n }\n\n function checkBalances(\n address _borrowerAddress,\n Collateral[] calldata _collateralInfo\n ) external returns (bool validated_, bool[] memory checks_) {\n validated_ = true;\n checks_ = new bool[](0);\n }\n\n /**\n * @notice Deploys a new collateral escrow.\n * @param _bidId The associated bidId of the collateral escrow.\n */\n function deployAndDeposit(uint256 _bidId) external {}\n\n /**\n * @notice Gets the address of a deployed escrow.\n * @notice _bidId The bidId to return the escrow for.\n * @return The address of the escrow.\n */\n function getEscrow(uint256 _bidId) external view returns (address) {\n return address(0);\n }\n\n /**\n * @notice Gets the collateral info for a given bid id.\n * @param _bidId The bidId to return the collateral info for.\n */\n function getCollateralInfo(uint256 _bidId)\n external\n view\n returns (Collateral[] memory collateral_)\n {\n collateral_ = new Collateral[](0);\n }\n\n function getCollateralAmount(uint256 _bidId, address collateralAssetAddress)\n external\n view\n returns (uint256 _amount)\n {\n return 500;\n }\n\n /**\n * @notice Withdraws deposited collateral from the created escrow of a bid.\n * @param _bidId The id of the bid to withdraw collateral for.\n */\n function withdraw(uint256 _bidId) external {}\n\n /**\n * @notice Re-checks the validity of a borrower's collateral balance committed to a bid.\n * @param _bidId The id of the associated bid.\n * @return validation_ Boolean indicating if the collateral balance was validated.\n */\n function revalidateCollateral(uint256 _bidId) external returns (bool) {\n return true;\n }\n\n /**\n * @notice Sends the deposited collateral to a liquidator of a bid.\n * @notice Can only be called by the protocol.\n * @param _bidId The id of the liquidated bid.\n * @param _liquidatorAddress The address of the liquidator to send the collateral to.\n */\n function liquidateCollateral(uint256 _bidId, address _liquidatorAddress)\n external\n {}\n}\n" + "contracts/EAS/TellerASEIP712Verifier.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../interfaces/IEASEIP712Verifier.sol\";\n\n/**\n * @title EIP712 typed signatures verifier for EAS delegated attestations.\n */\ncontract TellerASEIP712Verifier is IEASEIP712Verifier {\n error InvalidSignature();\n\n string public constant VERSION = \"0.8\";\n\n // EIP712 domain separator, making signatures from different domains incompatible.\n bytes32 public immutable DOMAIN_SEPARATOR; // solhint-disable-line var-name-mixedcase\n\n // The hash of the data type used to relay calls to the attest function. It's the value of\n // keccak256(\"Attest(address recipient,bytes32 schema,uint256 expirationTime,bytes32 refUUID,bytes data,uint256 nonce)\").\n bytes32 public constant ATTEST_TYPEHASH =\n 0x39c0608dd995a3a25bfecb0fffe6801a81bae611d94438af988caa522d9d1476;\n\n // The hash of the data type used to relay calls to the revoke function. It's the value of\n // keccak256(\"Revoke(bytes32 uuid,uint256 nonce)\").\n bytes32 public constant REVOKE_TYPEHASH =\n 0xbae0931f3a99efd1b97c2f5b6b6e79d16418246b5055d64757e16de5ad11a8ab;\n\n // Replay protection nonces.\n mapping(address => uint256) private _nonces;\n\n /**\n * @dev Creates a new EIP712Verifier instance.\n */\n constructor() {\n uint256 chainId;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n chainId := chainid()\n }\n\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n ),\n keccak256(bytes(\"EAS\")),\n keccak256(bytes(VERSION)),\n chainId,\n address(this)\n )\n );\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function getNonce(address account)\n external\n view\n override\n returns (uint256)\n {\n return _nonces[account];\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function attest(\n address recipient,\n bytes32 schema,\n uint256 expirationTime,\n bytes32 refUUID,\n bytes calldata data,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(\n ATTEST_TYPEHASH,\n recipient,\n schema,\n expirationTime,\n refUUID,\n keccak256(data),\n _nonces[attester]++\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n if (recoveredAddress == address(0) || recoveredAddress != attester) {\n revert InvalidSignature();\n }\n }\n\n /**\n * @inheritdoc IEASEIP712Verifier\n */\n function revoke(\n bytes32 uuid,\n address attester,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR,\n keccak256(\n abi.encode(REVOKE_TYPEHASH, uuid, _nonces[attester]++)\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n if (recoveredAddress == address(0) || recoveredAddress != attester) {\n revert InvalidSignature();\n }\n }\n}\n" + }, + "contracts/EAS/TellerASRegistry.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"../Types.sol\";\nimport \"../interfaces/IASRegistry.sol\";\nimport \"../interfaces/IASResolver.sol\";\n\n/**\n * @title The global AS registry.\n */\ncontract TellerASRegistry is IASRegistry {\n error AlreadyExists();\n\n string public constant VERSION = \"0.8\";\n\n // The global mapping between AS records and their IDs.\n mapping(bytes32 => ASRecord) private _registry;\n\n // The global counter for the total number of attestations.\n uint256 private _asCount;\n\n /**\n * @inheritdoc IASRegistry\n */\n function register(bytes calldata schema, IASResolver resolver)\n external\n override\n returns (bytes32)\n {\n uint256 index = ++_asCount;\n\n ASRecord memory asRecord = ASRecord({\n uuid: EMPTY_UUID,\n index: index,\n schema: schema,\n resolver: resolver\n });\n\n bytes32 uuid = _getUUID(asRecord);\n if (_registry[uuid].uuid != EMPTY_UUID) {\n revert AlreadyExists();\n }\n\n asRecord.uuid = uuid;\n _registry[uuid] = asRecord;\n\n emit Registered(uuid, index, schema, resolver, msg.sender);\n\n return uuid;\n }\n\n /**\n * @inheritdoc IASRegistry\n */\n function getAS(bytes32 uuid)\n external\n view\n override\n returns (ASRecord memory)\n {\n return _registry[uuid];\n }\n\n /**\n * @inheritdoc IASRegistry\n */\n function getASCount() external view override returns (uint256) {\n return _asCount;\n }\n\n /**\n * @dev Calculates a UUID for a given AS.\n *\n * @param asRecord The input AS.\n *\n * @return AS UUID.\n */\n function _getUUID(ASRecord memory asRecord) private pure returns (bytes32) {\n return keccak256(abi.encodePacked(asRecord.schema, asRecord.resolver));\n }\n}\n" + }, + "contracts/LenderManager.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\n// Contracts\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\n\n// Interfaces\nimport \"./interfaces/ILenderManager.sol\";\nimport \"./interfaces/ITellerV2.sol\";\nimport \"./interfaces/IMarketRegistry.sol\";\n\ncontract LenderManager is\n Initializable,\n OwnableUpgradeable,\n ERC721Upgradeable,\n ILenderManager\n{\n IMarketRegistry public immutable marketRegistry;\n\n constructor(IMarketRegistry _marketRegistry) {\n marketRegistry = _marketRegistry;\n }\n\n function initialize() external initializer {\n __LenderManager_init();\n }\n\n function __LenderManager_init() internal onlyInitializing {\n __Ownable_init();\n __ERC721_init(\"TellerLoan\", \"TLN\");\n }\n\n /**\n * @notice Registers a new active lender for a loan, minting the nft\n * @param _bidId The id for the loan to set.\n * @param _newLender The address of the new active lender.\n */\n function registerLoan(uint256 _bidId, address _newLender)\n public\n override\n onlyOwner\n {\n _mint(_newLender, _bidId);\n }\n\n /**\n * @notice Returns the address of the lender that owns a given loan/bid.\n * @param _bidId The id of the bid of which to return the market id\n */\n function _getLoanMarketId(uint256 _bidId) internal view returns (uint256) {\n return ITellerV2(owner()).getLoanMarketId(_bidId);\n }\n\n /**\n * @notice Returns the verification status of a lender for a market.\n * @param _lender The address of the lender which should be verified by the market\n * @param _bidId The id of the bid of which to return the market id\n */\n function _hasMarketVerification(address _lender, uint256 _bidId)\n internal\n view\n virtual\n returns (bool isVerified_)\n {\n uint256 _marketId = _getLoanMarketId(_bidId);\n\n (isVerified_, ) = marketRegistry.isVerifiedLender(_marketId, _lender);\n }\n\n /** ERC721 Functions **/\n\n function _beforeTokenTransfer(address, address to, uint256 tokenId, uint256)\n internal\n override\n {\n require(_hasMarketVerification(to, tokenId), \"Not approved by market\");\n }\n\n function _baseURI() internal view override returns (string memory) {\n return \"\";\n }\n}\n" + }, + "contracts/ProtocolFeeMock.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./ProtocolFee.sol\";\n\ncontract ProtocolFeeMock is ProtocolFee {\n bool public setProtocolFeeCalled;\n\n function initialize(uint16 _initFee) external initializer {\n __ProtocolFee_init(_initFee);\n }\n\n function setProtocolFee(uint16 newFee) public override onlyOwner {\n setProtocolFeeCalled = true;\n\n bool _isInitializing;\n assembly {\n _isInitializing := sload(1)\n }\n\n // Only call the actual function if we are not initializing\n if (!_isInitializing) {\n super.setProtocolFee(newFee);\n }\n }\n}\n" + }, + "contracts/TellerV2Mock.sol": { + "content": "pragma solidity >=0.8.0 <0.9.0;\n// SPDX-License-Identifier: MIT\n\nimport \"./TellerV2.sol\";\n\ncontract TellerV2Mock is TellerV2 {\n constructor(address trustedForwarder) TellerV2(trustedForwarder) {}\n\n function mockBid(Bid calldata _bid) external {\n bids[bidId] = _bid;\n borrowerBids[_msgSender()].push(bidId);\n bidId++;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId, uint32 _timestamp) external {\n require(_timestamp > 0, \"Accepted timestamp 0\");\n bids[_bidId].loanDetails.acceptedTimestamp = _timestamp;\n }\n\n function mockAcceptedTimestamp(uint256 _bidId) external {\n bids[_bidId].loanDetails.acceptedTimestamp = uint32(block.timestamp);\n }\n\n function mockLastRepaidTimestamp(uint256 _bidId, uint32 _timestamp)\n external\n {\n require(_timestamp > 0, \"Repaid timestamp 0\");\n bids[_bidId].loanDetails.lastRepaidTimestamp = _timestamp;\n }\n\n function setVersion(uint256 _version) public {\n version = _version;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (metatx/MinimalForwarder.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../utils/cryptography/EIP712Upgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Simple minimal forwarder to be used together with an ERC2771 compatible contract. See {ERC2771Context}.\n *\n * MinimalForwarder is mainly meant for testing, as it is missing features to be a good production-ready forwarder. This\n * contract does not intend to have all the properties that are needed for a sound forwarding system. A fully\n * functioning forwarding system with good properties requires more complexity. We suggest you look at other projects\n * such as the GSN which do have the goal of building a system like that.\n */\ncontract MinimalForwarderUpgradeable is Initializable, EIP712Upgradeable {\n using ECDSAUpgradeable for bytes32;\n\n struct ForwardRequest {\n address from;\n address to;\n uint256 value;\n uint256 gas;\n uint256 nonce;\n bytes data;\n }\n\n bytes32 private constant _TYPEHASH =\n keccak256(\"ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data)\");\n\n mapping(address => uint256) private _nonces;\n\n function __MinimalForwarder_init() internal onlyInitializing {\n __EIP712_init_unchained(\"MinimalForwarder\", \"0.0.1\");\n }\n\n function __MinimalForwarder_init_unchained() internal onlyInitializing {}\n\n function getNonce(address from) public view returns (uint256) {\n return _nonces[from];\n }\n\n function verify(ForwardRequest calldata req, bytes calldata signature) public view returns (bool) {\n address signer = _hashTypedDataV4(\n keccak256(abi.encode(_TYPEHASH, req.from, req.to, req.value, req.gas, req.nonce, keccak256(req.data)))\n ).recover(signature);\n return _nonces[req.from] == req.nonce && signer == req.from;\n }\n\n function execute(ForwardRequest calldata req, bytes calldata signature)\n public\n payable\n returns (bool, bytes memory)\n {\n require(verify(req, signature), \"MinimalForwarder: signature does not match request\");\n _nonces[req.from] = req.nonce + 1;\n\n (bool success, bytes memory returndata) = req.to.call{gas: req.gas, value: req.value}(\n abi.encodePacked(req.data, req.from)\n );\n\n // Validate that the relayer has sent enough gas for the call.\n // See https://ronan.eth.limo/blog/ethereum-gas-dangers/\n if (gasleft() <= req.gas / 63) {\n // We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since\n // neither revert or assert consume all gas since Solidity 0.8.0\n // https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require\n /// @solidity memory-safe-assembly\n assembly {\n invalid()\n }\n }\n\n return (success, returndata);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "contracts/MetaForwarder.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts-upgradeable/metatx/MinimalForwarderUpgradeable.sol\";\n\ncontract MetaForwarder is MinimalForwarderUpgradeable {\n function initialize() external initializer {\n __EIP712_init_unchained(\"TellerMetaForwarder\", \"0.0.1\");\n }\n}\n" + }, + "contracts/interfaces/ITellerV2Context.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITellerV2Context {\n function setTrustedMarketForwarder(uint256 _marketId, address _forwarder)\n external;\n\n function approveMarketForwarder(uint256 _marketId, address _forwarder)\n external;\n}\n" + }, + "contracts/interfaces/IUniswapV2Router.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n @notice This interface defines the different functions available for a UniswapV2Router.\n @author develop@teller.finance\n */\ninterface IUniswapV2Router {\n function factory() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETH(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function quote(uint256 amountA, uint256 reserveA, uint256 reserveB)\n external\n pure\n returns (uint256 amountB);\n\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountOut);\n\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountIn);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n /**\n @notice It returns the address of the canonical WETH address;\n */\n function WETH() external pure returns (address);\n\n /**\n @notice Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountIn The amount of input tokens to send.\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the output tokens.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n @dev msg.sender should have already given the router an allowance of at least amountIn on the input token.\n */\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /**\n @notice Swaps an exact amount of tokens for as much ETH as possible, along the route determined by the path. The first element of path is the input token, the last must be WETH, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountIn The amount of input tokens to send.\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the ETH.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n @dev If the to address is a smart contract, it must have the ability to receive ETH.\n */\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n /**\n @notice Swaps an exact amount of ETH for as many output tokens as possible, along the route determined by the path. The first element of path must be WETH, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).\n @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.\n @param to Recipient of the output tokens.\n @param deadline Unix timestamp after which the transaction will revert.\n @return amounts The input token amount and all subsequent output token amounts.\n */\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapTokensForExactETH(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapETHForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n}\n" + }, + "contracts/interfaces/IWETH.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @notice It is the interface of functions that we use for the canonical WETH contract.\n *\n * @author develop@teller.finance\n */\ninterface IWETH {\n /**\n * @notice It withdraws ETH from the contract by sending it to the caller and reducing the caller's internal balance of WETH.\n * @param amount The amount of ETH to withdraw.\n */\n function withdraw(uint256 amount) external;\n\n /**\n * @notice It deposits ETH into the contract and increases the caller's internal balance of WETH.\n */\n function deposit() external payable;\n\n /**\n * @notice It gets the ETH deposit balance of an {account}.\n * @param account Address to get balance of.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @notice It transfers the WETH amount specified to the given {account}.\n * @param to Address to transfer to\n * @param value Amount of WETH to transfer\n */\n function transfer(address to, uint256 value) external returns (bool);\n}\n" + }, + "contracts/mock/WethMock.sol": { + "content": "/**\n *Submitted for verification at Etherscan.io on 2017-12-12\n */\n\n// Copyright (C) 2015, 2016, 2017 Dapphub\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program. If not, see .\n\npragma solidity ^0.8.0;\n\n// SPDX-License-Identifier: MIT\n\ncontract WethMock {\n string public name = \"Wrapped Ether\";\n string public symbol = \"WETH\";\n uint8 public decimals = 18;\n\n event Approval(address indexed src, address indexed guy, uint256 wad);\n event Transfer(address indexed src, address indexed dst, uint256 wad);\n event Deposit(address indexed dst, uint256 wad);\n event Withdrawal(address indexed src, uint256 wad);\n\n mapping(address => uint256) public balanceOf;\n mapping(address => mapping(address => uint256)) public allowance;\n\n function deposit() public payable {\n balanceOf[msg.sender] += msg.value;\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 wad) public {\n require(balanceOf[msg.sender] >= wad);\n balanceOf[msg.sender] -= wad;\n payable(msg.sender).transfer(wad);\n emit Withdrawal(msg.sender, wad);\n }\n\n function totalSupply() public view returns (uint256) {\n return address(this).balance;\n }\n\n function approve(address guy, uint256 wad) public returns (bool) {\n allowance[msg.sender][guy] = wad;\n emit Approval(msg.sender, guy, wad);\n return true;\n }\n\n function transfer(address dst, uint256 wad) public returns (bool) {\n return transferFrom(msg.sender, dst, wad);\n }\n\n function transferFrom(address src, address dst, uint256 wad)\n public\n returns (bool)\n {\n require(balanceOf[src] >= wad, \"insufficient balance\");\n\n if (src != msg.sender) {\n require(\n allowance[src][msg.sender] >= wad,\n \"insufficient allowance\"\n );\n allowance[src][msg.sender] -= wad;\n }\n\n balanceOf[src] -= wad;\n balanceOf[dst] += wad;\n\n emit Transfer(src, dst, wad);\n\n return true;\n }\n}\n" } }, "settings": { diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts index 1cfeff5fa..bb077db8d 100644 --- a/packages/contracts/hardhat.config.ts +++ b/packages/contracts/hardhat.config.ts @@ -215,7 +215,7 @@ export default { namedAccounts: { deployer: { default: 0, // here this will by default take the first account as deployer - 31337: '0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5', // use the goerli deployer address for hardhat forking + // 31337: '0xAFe87013dc96edE1E116a288D80FcaA0eFFE5fe5', // use the goerli deployer address for hardhat forking }, borrower: 1, lender: 2, diff --git a/packages/subgraph/config/goerli.json b/packages/subgraph/config/goerli.json index 75a405f07..f541bc051 100644 --- a/packages/subgraph/config/goerli.json +++ b/packages/subgraph/config/goerli.json @@ -1,13 +1,15 @@ { "network": "goerli", - "address_teller_v2": "0x195c6608705546725DF0629dd60690Cf2b367734", - "block_teller_v2": "8538452", - "address_market_registry": "0x74FFC87282ab32c8E0969E26F93C820a213ae146", - "block_market_registry": "8538442", - "address_lender_commitment": "0xB1b668592A4FCA5d0Cd91D4E5D8b33cb95043E43", - "block_lender_commitment": "8538455", - "address_collateral_manager": "0xD66de8b25C4165dA2e7696e15E8436380823B118", - "block_collateral_manager": "8538491", - "address_lender_manager": "0x98Ca52786e967d1469090AdC075416948Ca004A7", - "block_lender_manager": "8538444" + "address_teller_v2": "0x3a8C417a743A60ECfF3988C34783D65362b62915", + "block_teller_v2": "8688915", + "address_market_registry": "0x04F6908B97E4E985b849174f9904FaF0a0E50413", + "block_market_registry": "8688915", + "address_lender_commitment": "0xEb73653c0a3B6BFb65b4DfE3cbc73A961919C8B6", + "block_lender_commitment": "8688915", + "address_collateral_manager": "0x62824Ff0BDbc42874e23f3cA9966866659F39b09", + "block_collateral_manager": "8688915", + "address_lender_manager": "0x786a95b7605E52a6E8E6dA20d44a1E0aDA5E58b1", + "block_lender_manager": "8688915", + "address_enumerable_set_allowlist": "0x5fe160b786a0274e115c2bee948ab60fc0bdab2f", + "block_enumerable_set_allowlist": "8688915" } \ No newline at end of file diff --git a/packages/subgraph/scripts/deploy.sh b/packages/subgraph/scripts/deploy.sh index 93b24c4ca..fc4aeb9f3 100755 --- a/packages/subgraph/scripts/deploy.sh +++ b/packages/subgraph/scripts/deploy.sh @@ -15,5 +15,5 @@ else yarn graph deploy \ --product hosted-service \ --node https://api.thegraph.com/deploy/ \ - "teller-protocol/tellerv2-$network" + "teller-protocol/tellerv2-$network-test" fi diff --git a/packages/subgraph/src/allowlist-mapping.ts b/packages/subgraph/src/allowlist-mapping.ts new file mode 100644 index 000000000..6ba9df661 --- /dev/null +++ b/packages/subgraph/src/allowlist-mapping.ts @@ -0,0 +1,33 @@ +import { UpdatedAllowList,EnumerableSetAllowlist } from "../generated/EnumerableSetAllowlist/EnumerableSetAllowlist"; +import { loadCommitment } from "./helpers/loaders"; +import { Address, BigInt, Bytes, store } from "@graphprotocol/graph-ts"; + + + +export function handleUpdatedAllowLists(events: UpdatedAllowList[]): void { + events.forEach(event => { + handleUpdatedAllowList(event); + }); + } + + + +export function handleUpdatedAllowList(event: UpdatedAllowList): void { + + const enumerableSetAllowlistInstance = EnumerableSetAllowlist.bind( + event.address + ); + + const commitmentId = event.params.commitmentId.toString(); + const commitment = loadCommitment(commitmentId); + + const borrowers = enumerableSetAllowlistInstance.getAllowedAddresses( + BigInt.fromString(commitmentId) + ); + + if (borrowers) { + commitment.commitmentBorrowers = changetype(borrowers); + } + + +} diff --git a/packages/subgraph/src/mapping.ts b/packages/subgraph/src/mapping.ts index 5a64d4026..dffcfa6f1 100644 --- a/packages/subgraph/src/mapping.ts +++ b/packages/subgraph/src/mapping.ts @@ -806,12 +806,12 @@ export function handeUpdatedCommitmentBorrower( const lenderCommitmentForwarderInstance = LenderCommitmentForwarder.bind( event.address ); - const borrowers = lenderCommitmentForwarderInstance.getCommitmentBorrowers( + /*const borrowers = lenderCommitmentForwarderInstance.getCommitmentBorrowers( BigInt.fromString(commitmentId) ); if (borrowers) { commitment.commitmentBorrowers = changetype(borrowers); - } + }*/ commitment.save(); } diff --git a/packages/subgraph/src/subgraph.template.yaml b/packages/subgraph/src/subgraph.template.yaml index c895fe06a..ed36290d4 100644 --- a/packages/subgraph/src/subgraph.template.yaml +++ b/packages/subgraph/src/subgraph.template.yaml @@ -120,9 +120,27 @@ dataSources: handler: handleDeletedCommitment - event: ExercisedCommitment(indexed uint256,address,uint256,uint256) handler: handleExercisedCommitment - - event: UpdatedCommitmentBorrowers(indexed uint256) - handler: handeUpdatedCommitmentBorrower file: ./src/mapping.ts + - kind: ethereum/contract + name: EnumerableSetAllowlist + network: {{network}} + source: + address: '{{address_enumerable_set_allowlist}}' + abi: EnumerableSetAllowlist + startBlock: {{block_enumerable_set_allowlist}} + mapping: + kind: ethereum/events + apiVersion: 0.0.5 + language: wasm/assemblyscript + entities: + - Commitment + abis: + - name: EnumerableSetAllowlist + file: ./abis/{{network}}_EnumerableSetAllowlist.json + eventHandlers: + - event: UpdatedAllowList(uint256) + handler: handleUpdatedAllowLists + file: ./src/allowlist-mapping.ts - kind: ethereum/contract name: CollateralManager network: {{network}}